Class: AsposeDiagramCloud::DiagramFileApi

Inherits:
Object
  • Object
show all
Defined in:
lib/aspose_diagram_cloud/api/diagram_file_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DiagramFileApi



19
20
21
22
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
  request_token
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#diagram_file_get_diagram(name, opts = {}) ⇒ File

Read document info or export.

Options Hash (opts):

  • :format (String)

    The exported file format.

  • :folder (String)

    The document folder.

  • :storage (String)

    storage name.



47
48
49
50
51
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 47

def diagram_file_get_diagram(name, opts = {})
  data, _status_code, _headers = diagram_file_get_diagram_with_http_info(name, opts)
  request_token if _status_code == 401
  return data
end

#diagram_file_get_diagram_with_http_info(name, opts = {}) ⇒ Array<(File, Fixnum, Hash)>

Read document info or export.

Options Hash (opts):

  • :format (String)

    The exported file format.

  • :folder (String)

    The document folder.

  • :storage (String)

    storage name.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 61

def diagram_file_get_diagram_with_http_info(name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramFileApi.diagram_file_get_diagram ..."
  end
  # verify the required parameter 'name' is set

  if @api_client.config.client_side_validation && name.nil?
    fail ArgumentError, "Missing the required parameter 'name' when calling DiagramFileApi.diagram_file_get_diagram"
  end
  # resource path

  local_var_path = "/diagram/{name}".sub('{' + 'name' + '}', name.to_s)

  # query parameters

  query_params = {}
  query_params[:'format'] = opts[:'format'] if !opts[:'format'].nil?
  query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
  query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?

  # header parameters

  header_params = {}
  # HTTP header 'Accept' (if needed)

  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'

  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters

  form_params = {}

  # http body (model)

  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'File')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramFileApi#diagram_file_get_diagram\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#diagram_file_post_save_as(name, opts = {}) ⇒ SaveResponse

Convert document and save result to storage.

Options Hash (opts):

  • :format (FileFormatRequest)

    Save format.

  • :newfilename (String)

    The new file name.

  • :folder (String)

    The document folder.

  • :is_overwrite (BOOLEAN)

    If true overwrite the same name file.The default value is false. (default to false)

  • :storage (String)

    storage name.



114
115
116
117
118
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 114

def diagram_file_post_save_as(name, opts = {})
  data, _status_code, _headers = diagram_file_post_save_as_with_http_info(name, opts)
  request_token if _status_code == 401
  return data
end

#diagram_file_post_save_as_with_http_info(name, opts = {}) ⇒ Array<(SaveResponse, Fixnum, Hash)>

Convert document and save result to storage.

Options Hash (opts):

  • :format (FileFormatRequest)

    Save format.

  • :newfilename (String)

    The new file name.

  • :folder (String)

    The document folder.

  • :is_overwrite (BOOLEAN)

    If true overwrite the same name file.The default value is false.

  • :storage (String)

    storage name.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 130

def diagram_file_post_save_as_with_http_info(name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramFileApi.diagram_file_post_save_as ..."
  end
  # verify the required parameter 'name' is set

  if @api_client.config.client_side_validation && name.nil?
    fail ArgumentError, "Missing the required parameter 'name' when calling DiagramFileApi.diagram_file_post_save_as"
  end
  # resource path

  local_var_path = "/diagram/{name}/SaveAs".sub('{' + 'name' + '}', name.to_s)

  # query parameters

  query_params = {}
  query_params[:'newfilename'] = opts[:'newfilename'] if !opts[:'newfilename'].nil?
  query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
  query_params[:'IsOverwrite'] = opts[:'is_overwrite'] if !opts[:'is_overwrite'].nil?
  query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?

  # header parameters

  header_params = {}
  # HTTP header 'Accept' (if needed)

  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'

  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters

  form_params = {}

  # http body (model)

  post_body = @api_client.object_to_http_body(opts[:'format'])
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SaveResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramFileApi#diagram_file_post_save_as\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#diagram_file_put_create(name, opts = {}) ⇒ SaaSposeResponse

Create new diagram and save result to storage.

Options Hash (opts):

  • :folder (String)

    The new document folder.

  • :is_overwrite (BOOLEAN)

    If true overwrite the same name file.The default value is false. (default to false)

  • :storage (String)

    storage name.



182
183
184
185
186
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 182

def diagram_file_put_create(name, opts = {})
  data, _status_code, _headers = diagram_file_put_create_with_http_info(name, opts)
  request_token if _status_code == 401
  return data
end

#diagram_file_put_create_with_http_info(name, opts = {}) ⇒ Array<(SaaSposeResponse, Fixnum, Hash)>

Create new diagram and save result to storage.

Options Hash (opts):

  • :folder (String)

    The new document folder.

  • :is_overwrite (BOOLEAN)

    If true overwrite the same name file.The default value is false.

  • :storage (String)

    storage name.



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 196

def diagram_file_put_create_with_http_info(name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramFileApi.diagram_file_put_create ..."
  end
  # verify the required parameter 'name' is set

  if @api_client.config.client_side_validation && name.nil?
    fail ArgumentError, "Missing the required parameter 'name' when calling DiagramFileApi.diagram_file_put_create"
  end
  # resource path

  local_var_path = "/diagram/{name}".sub('{' + 'name' + '}', name.to_s)

  # query parameters

  query_params = {}
  query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
  query_params[:'IsOverwrite'] = opts[:'is_overwrite'] if !opts[:'is_overwrite'].nil?
  query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?

  # header parameters

  header_params = {}
  # HTTP header 'Accept' (if needed)

  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'

  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters

  form_params = {}

  # http body (model)

  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SaaSposeResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramFileApi#diagram_file_put_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#diagram_file_put_upload(name, opts = {}) ⇒ SaaSposeResponse

Upload file and save result to storage.

Options Hash (opts):

  • :folder (String)

    The document folder.

  • :is_overwrite (BOOLEAN)

    If true overwrite the same name file.The default value is false. (default to false)

  • :storage (String)

    storage name.



247
248
249
250
251
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 247

def diagram_file_put_upload(name, opts = {})
  data, _status_code, _headers = diagram_file_put_upload_with_http_info(name, opts)
  request_token if _status_code == 401
  return data
end

#diagram_file_put_upload_with_http_info(name, opts = {}) ⇒ Array<(SaaSposeResponse, Fixnum, Hash)>

Upload file and save result to storage.

Options Hash (opts):

  • :folder (String)

    The document folder.

  • :is_overwrite (BOOLEAN)

    If true overwrite the same name file.The default value is false.

  • :storage (String)

    storage name.



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 261

def diagram_file_put_upload_with_http_info(name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramFileApi.diagram_file_put_upload ..."
  end
  # verify the required parameter 'name' is set

  if @api_client.config.client_side_validation && name.nil?
    fail ArgumentError, "Missing the required parameter 'name' when calling DiagramFileApi.diagram_file_put_upload"
  end
  # resource path

  local_var_path = "/diagram/{name}/upload".sub('{' + 'name' + '}', name.to_s)

  # query parameters

  query_params = {}
  query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
  query_params[:'IsOverwrite'] = opts[:'is_overwrite'] if !opts[:'is_overwrite'].nil?
  query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?

  # header parameters

  header_params = {}
  # HTTP header 'Accept' (if needed)

  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'

  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters

  form_params = {}

  # http body (model)

  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SaaSposeResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramFileApi#diagram_file_put_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#request_tokenObject

Gets a request token from server



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/aspose_diagram_cloud/api/diagram_file_api.rb', line 27

def request_token
  config = @api_client.config
  base_path = config.base_path 
  config.base_path = '/'
  request_url = "/oauth2/token"
  post_data = "grant_type=client_credentials" + "&client_id=" + config.api_key['app_sid'] + "&client_secret=" + config.api_key['api_key']
  data, status_code, header = @api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
  @api_client.config.access_token = data[:access_token]
  @api_client.config.base_path = base_path
  @api_client.default_headers["Authorization"] ="Bearer " + data[:access_token]
end