Class: AsposeDiagramCloud::DiagramApi

Inherits:
Object
  • Object
show all
Defined in:
lib/AsposeDiagramCloud/api/diagram_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grant_type, app_sid, app_key, api_client = ApiClient.default) ⇒ DiagramApi

Returns a new instance of DiagramApi.



19
20
21
22
23
24
25
26
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 19

def initialize(grant_type,app_sid,app_key,api_client = ApiClient.default)
  @api_client = api_client
  @api_client.config.api_key['api_key'] = app_key
  @api_client.config.api_key['app_sid'] = app_sid
  @api_client.config.api_key['grant_type'] = grant_type
  request_token

end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#convert_document(name, file, opts = {}) ⇒ File

Converts document from the request’s content to the specified format.

Parameters:

  • name

    Download document name.

  • file

    File to upload

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :source_filename (String)

    Source document name.

Returns:

  • (File)


48
49
50
51
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 48

def convert_document(name, file, opts = {})
  data, _status_code, _headers = convert_document_with_http_info(name, file, opts)
  return data
end

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

Converts document from the request&#39;s content to the specified format.

Parameters:

  • name

    Download document name.

  • file

    File to upload

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :source_filename (String)

    Source document name.

Returns:

  • (Array<(File, Fixnum, Hash)>)

    File data, response status code and response headers



60
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
103
104
105
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 60

def convert_document_with_http_info(name, file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramApi.convert_document ..."
  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 DiagramApi.convert_document"
  end
  # verify the required parameter 'file' is set

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

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

  # query parameters

  query_params = {}
  query_params[:'sourceFilename'] = opts[:'source_filename'] if !opts[:'source_filename'].nil?

  # header parameters

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

  header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])
  # HTTP header 'Content-Type'

  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream'])

  # form parameters

  form_params = {}
  #form_params["File"] = file


  # http body (model)

  post_body = file
  auth_names = ['JWT']
  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 => 'File')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramApi#convert_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_new(name, opts = {}) ⇒ CreateNewResponse

Create Empty file into the specified format.

Parameters:

  • name

    The document name.

  • opts (Hash) (defaults to: {})

    the optional parameters

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)

Returns:



114
115
116
117
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 114

def create_new(name, opts = {})
  data, _status_code, _headers = create_new_with_http_info(name, opts)
  return data
end

#create_new_with_http_info(name, opts = {}) ⇒ Array<(CreateNewResponse, Fixnum, Hash)>

Create Empty file into the specified format.

Parameters:

  • name

    The document name.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :folder (String)

    The document folder.

  • :is_overwrite (BOOLEAN)

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

Returns:

  • (Array<(CreateNewResponse, Fixnum, Hash)>)

    CreateNewResponse data, response status code and response headers



126
127
128
129
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
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 126

def create_new_with_http_info(name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramApi.create_new ..."
  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 DiagramApi.create_new"
  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?

  # 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 = ['JWT']
  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 => 'CreateNewResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramApi#create_new\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#download_file_with_format(name, format, opts = {}) ⇒ File

Exports the document into the specified format.

Parameters:

  • name

    The document name.

  • format

    The destination format.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :folder (String)

    Original document folder.

Returns:

  • (File)


175
176
177
178
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 175

def download_file_with_format(name, format, opts = {})
  data, _status_code, _headers = download_file_with_format_with_http_info(name, format, opts)
  return data
end

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

Exports the document into the specified format.

Parameters:

  • name

    The document name.

  • format

    The destination format.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :folder (String)

    Original document folder.

Returns:

  • (Array<(File, Fixnum, Hash)>)

    File data, response status code and response headers



187
188
189
190
191
192
193
194
195
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
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 187

def download_file_with_format_with_http_info(name, format, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramApi.download_file_with_format ..."
  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 DiagramApi.download_file_with_format"
  end
  # verify the required parameter 'format' is set

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

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

  # query parameters

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

  # header parameters

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

  header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])
  # 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 = ['JWT']
  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: DiagramApi#download_file_with_format\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#request_tokenObject

Gets a request token from server



31
32
33
34
35
36
37
38
39
40
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 31

def request_token
  authconfig=Configuration.new
  authconfig.base_path=""
  authClient=ApiClient.new(authconfig)
  authApi=AsposeDiagramCloud::OAuthApi.new(authClient)
  config=@api_client.config
  data, _status_code, _headers=authApi.o_auth_post(config.api_key['grant_type'],config.api_key['app_sid'],config.api_key['api_key'])
  #print(data.access_token)

  @api_client.default_headers["Authorization"] ="Bearer " + data.access_token
end

#save_as(name, save_options_request, opts = {}) ⇒ SaveAsResponse

Converts document to destination format with detailed settings and saves result to storage.

Parameters:

  • name

    Original document name.

  • save_options_request

    Save options.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :folder (String)

    Original document folder.

  • :is_overwrite (BOOLEAN)

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

Returns:



241
242
243
244
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 241

def save_as(name, save_options_request, opts = {})
  data, _status_code, _headers = save_as_with_http_info(name, save_options_request, opts)
  return data
end

#save_as_with_http_info(name, save_options_request, opts = {}) ⇒ Array<(SaveAsResponse, Fixnum, Hash)>

Converts document to destination format with detailed settings and saves result to storage.

Parameters:

  • name

    Original document name.

  • save_options_request

    Save options.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :folder (String)

    Original document folder.

  • :is_overwrite (BOOLEAN)

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

Returns:

  • (Array<(SaveAsResponse, Fixnum, Hash)>)

    SaveAsResponse data, response status code and response headers



254
255
256
257
258
259
260
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
# File 'lib/AsposeDiagramCloud/api/diagram_api.rb', line 254

def save_as_with_http_info(name, save_options_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DiagramApi.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 DiagramApi.save_as"
  end
  # verify the required parameter 'save_options_request' is set

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

  local_var_path = "/diagram/{name}/saveAs".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?

  # 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(save_options_request)
  auth_names = ['JWT']
  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 => 'SaveAsResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DiagramApi#save_as\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end