Class: GroupDocsConversionCloud::ConvertApi

Inherits:
Object
  • Object
show all
Defined in:
lib/groupdocs_conversion_cloud/api/convert_api.rb

Overview

GroupDocs.Conversion Cloud API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConvertApi

Initializes new instance of ConvertApi

Parameters:



43
44
45
46
47
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 43

def initialize(config)
  @config = config
  @api_client = ApiClient.new(config)
  @access_token = nil
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



34
35
36
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 34

def config
  @config
end

Class Method Details

.from_config(config) ⇒ ConvertApi

Initializes new instance of ConvertApi

Parameters:

Returns:



63
64
65
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 63

def self.from_config(config)
  return new(config)
end

.from_keys(app_sid, app_key) ⇒ ConvertApi

Initializes new instance of ConvertApi

Parameters:

  • Application (app_sid)

    identifier (App SID)

  • Application (app_key)

    private key (App Key)

Returns:



54
55
56
57
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 54

def self.from_keys(app_sid, app_key)
  config = Configuration.new(app_sid, app_key)
  return new(config)
end

Instance Method Details

#convert_document(request) ⇒ Array<StoredConvertedResult>

Converts specified input document to format specified in the convertSettings with specified options

Parameters:

  • request

    convert_document_request

Returns:



71
72
73
74
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 71

def convert_document(request)
  data, _status_code, _headers = convert_document_with_http_info(request)
  data
end

#convert_document_direct(request) ⇒ File

Converts input document file to format specified

Parameters:

  • request

    convert_document_direct_request

Returns:

  • (File)


124
125
126
127
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 124

def convert_document_direct(request)
  data, _status_code, _headers = convert_document_direct_with_http_info(request)
  data
end

#convert_document_direct_with_http_info(request) ⇒ Array<(File, Fixnum, Hash)>

Converts input document file to format specified

File data, response status code and response headers

Parameters:

  • request

    convert_document_direct_request

Returns:

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

Raises:

  • (ArgumentError)


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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 134

def convert_document_direct_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? ConvertDocumentDirectRequest

  @api_client.config.logger.debug 'Calling API: ConvertApi.convert_document_direct ...' if @api_client.config.debugging
  # verify the required parameter 'format' is set
  raise ArgumentError, 'Missing the required parameter format when calling ConvertApi.convert_document_direct' if @api_client.config.client_side_validation && request.format.nil?
  # verify the required parameter 'file' is set
  raise ArgumentError, 'Missing the required parameter file when calling ConvertApi.convert_document_direct' if @api_client.config.client_side_validation && request.file.nil?
  # resource path
  local_var_path = '/conversion'

  # query parameters
  query_params = {}
  query_params[downcase_first_letter('format')] = request.format

  if local_var_path.include? ('{' + downcase_first_letter('fromPage') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('fromPage') + '}', request.from_page.to_s)
  else
    query_params[downcase_first_letter('fromPage')] = request.from_page unless request.from_page.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('pagesCount') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('pagesCount') + '}', request.pages_count.to_s)
  else
    query_params[downcase_first_letter('pagesCount')] = request.pages_count unless request.pages_count.nil?
  end

  # 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(['multipart/form-data'])

  # form parameters
  form_params = {}
  form_params[downcase_first_letter('File')] = request.file
  form_params[downcase_first_letter('loadOptions')] = @api_client.object_to_http_body(request.load_options) unless request.load_options.nil?
  form_params[downcase_first_letter('convertOptions')] = @api_client.object_to_http_body(request.convert_options) unless request.convert_options.nil?

  # http body (model)
  post_body = nil
  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,
                                                    access_token: get_access_token,
                                                    return_type: 'File')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    ConvertApi#convert_document_direct\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#convert_document_with_http_info(request) ⇒ Array<(Array<StoredConvertedResult>, Fixnum, Hash)>

Converts specified input document to format specified in the convertSettings with specified options

Array<StoredConvertedResult> data, response status code and response headers

Parameters:

  • request

    convert_document_request

Returns:

Raises:

  • (ArgumentError)


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
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/groupdocs_conversion_cloud/api/convert_api.rb', line 81

def convert_document_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? ConvertDocumentRequest

  @api_client.config.logger.debug 'Calling API: ConversionApi.convert_document ...' if @api_client.config.debugging
  # verify the required parameter 'convert_settings' is set
  raise ArgumentError, 'Missing the required parameter convert_settings when calling ConversionApi.convert_document' if @api_client.config.client_side_validation && request.convert_settings.nil?
  # resource path
  local_var_path = '/conversion'

  # query parameters
  query_params = {}

  # 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(request.convert_settings)
  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,
                                                    access_token: get_access_token,
                                                    return_type: if request.convert_settings.output_path.nil? then 'File' else 'Array<StoredConvertedResult>' end)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    ConversionApi#convert_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end