Skip to content

Commit e29e2bd

Browse files
committed
Updated sources
1 parent d23a294 commit e29e2bd

36 files changed

Lines changed: 3065 additions & 127 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem install groupdocs_conversion_cloud
1212
To add dependency to your app copy following into your Gemfile and run `bundle install`:
1313

1414
```
15-
gem "groupdocs_conversion_cloud", "~> 19.4"
15+
gem "groupdocs_conversion_cloud", "~> 19.5"
1616
```
1717

1818
## Getting Started
@@ -27,7 +27,7 @@ app_sid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
2727
app_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
2828

2929
# Create instance of the API class
30-
api = GroupDocsConversionCloud::ConversionApi.from_keys(app_sid, app_key)
30+
api = GroupDocsConversionCloud::InfoApi.from_keys(app_sid, app_key)
3131

3232
# Retrieve supported converison types
3333
request = GroupDocsConversionCloud::GetSupportedConversionTypesRequest.new

lib/groupdocs_conversion_cloud.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
require_relative 'groupdocs_conversion_cloud/models/convert_options'
3434
require_relative 'groupdocs_conversion_cloud/models/convert_settings'
3535
require_relative 'groupdocs_conversion_cloud/models/disc_usage'
36+
require_relative 'groupdocs_conversion_cloud/models/document_metadata'
3637
require_relative 'groupdocs_conversion_cloud/models/error'
3738
require_relative 'groupdocs_conversion_cloud/models/error_details'
3839
require_relative 'groupdocs_conversion_cloud/models/file_versions'
@@ -199,7 +200,8 @@
199200
require_relative 'groupdocs_conversion_cloud/models/tif_convert_options'
200201

201202
# APIs
202-
require_relative 'groupdocs_conversion_cloud/api/conversion_api'
203+
require_relative 'groupdocs_conversion_cloud/api/convert_api'
203204
require_relative 'groupdocs_conversion_cloud/api/file_api'
204205
require_relative 'groupdocs_conversion_cloud/api/folder_api'
206+
require_relative 'groupdocs_conversion_cloud/api/info_api'
205207
require_relative 'groupdocs_conversion_cloud/api/storage_api'
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# -----------------------------------------------------------------------------------
2+
# <copyright company="Aspose Pty Ltd" file="convert.rb">
3+
# Copyright (c) 2003-2019 Aspose Pty Ltd
4+
# </copyright>
5+
# <summary>
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# </summary>
24+
# -----------------------------------------------------------------------------------
25+
26+
require 'uri'
27+
require 'date'
28+
29+
module GroupDocsConversionCloud
30+
#
31+
# GroupDocs.Conversion Cloud API
32+
#
33+
class ConvertApi
34+
attr_accessor :config
35+
36+
#make ConvertApi.new private
37+
private_class_method :new
38+
39+
# Initializes new instance of ConvertApi
40+
#
41+
# @param [config] Configuration
42+
# @return [ConvertApi] New instance of ConvertApi
43+
def initialize(config)
44+
@config = config
45+
@api_client = ApiClient.new(config)
46+
@access_token = nil
47+
end
48+
49+
# Initializes new instance of ConvertApi
50+
#
51+
# @param [app_sid] Application identifier (App SID)
52+
# @param [app_key] Application private key (App Key)
53+
# @return [ConvertApi] New instance of ConvertApi
54+
def self.from_keys(app_sid, app_key)
55+
config = Configuration.new(app_sid, app_key)
56+
return new(config)
57+
end
58+
59+
# Initializes new instance of ConvertApi
60+
#
61+
# @param [config] Configuration
62+
# @return [ConvertApi] New instance of ConvertApi
63+
def self.from_config(config)
64+
return new(config)
65+
end
66+
67+
# Converts specified input document to format specified in the convertSettings with specified options
68+
#
69+
# @param request convert_document_request
70+
# @return [Array<StoredConvertedResult>]
71+
def convert_document(request)
72+
data, _status_code, _headers = convert_document_with_http_info(request)
73+
data
74+
end
75+
76+
# Converts specified input document to format specified in the convertSettings with specified options
77+
#
78+
# @param request convert_document_request
79+
# @return [Array<(Array<StoredConvertedResult>, Fixnum, Hash)>]
80+
# Array<StoredConvertedResult> data, response status code and response headers
81+
def convert_document_with_http_info(request)
82+
raise ArgumentError, 'Incorrect request type' unless request.is_a? ConvertDocumentRequest
83+
84+
@api_client.config.logger.debug 'Calling API: ConversionApi.convert_document ...' if @api_client.config.debugging
85+
# verify the required parameter 'convert_settings' is set
86+
raise ArgumentError, 'Missing the required parameter convert_settings when calling ConversionApi.convert_document' if @api_client.config.client_side_validation && request.convert_settings.nil?
87+
# resource path
88+
local_var_path = '/conversion'
89+
90+
# query parameters
91+
query_params = {}
92+
93+
# header parameters
94+
header_params = {}
95+
# HTTP header 'Accept' (if needed)
96+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
97+
# HTTP header 'Content-Type'
98+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
99+
100+
# form parameters
101+
form_params = {}
102+
103+
# http body (model)
104+
post_body = @api_client.object_to_http_body(request.convert_settings)
105+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
106+
header_params: header_params,
107+
query_params: query_params,
108+
form_params: form_params,
109+
body: post_body,
110+
access_token: get_access_token,
111+
return_type: if request.convert_settings.output_path.nil? then 'File' else 'Array<StoredConvertedResult>' end)
112+
if @api_client.config.debugging
113+
@api_client.config.logger.debug "API called:
114+
ConversionApi#convert_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
115+
end
116+
[data, status_code, headers]
117+
end
118+
119+
120+
#
121+
# Helper method to convert first letter to downcase
122+
#
123+
private def downcase_first_letter(str)
124+
value = str[0].downcase + str[1..-1]
125+
value
126+
end
127+
128+
#
129+
# Retrieves access token
130+
#
131+
private def get_access_token
132+
if @access_token.nil? then
133+
request_access_token
134+
end
135+
136+
@access_token
137+
end
138+
139+
#
140+
# Gets a access token from server
141+
#
142+
private def request_access_token
143+
auth_config = Configuration.new(@config.app_sid, @config.app_key)
144+
auth_config.api_base_url = @config.api_base_url
145+
auth_config.debugging = @config.debugging
146+
auth_config.logger = @config.logger
147+
auth_config.temp_folder_path = @config.temp_folder_path
148+
auth_config.client_side_validation = @config.client_side_validation
149+
auth_config.api_version = ''
150+
151+
auth_api_client = ApiClient.new(auth_config)
152+
153+
request_url = "/connect/token"
154+
post_data = "grant_type=client_credentials&client_id=#{@config.app_sid}&client_secret=#{@config.app_key}"
155+
156+
data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
157+
158+
@access_token = data[:access_token]
159+
160+
expires_in_seconds = data[:expires_in].to_i - 5 * 60
161+
expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
162+
@access_token_expires_at = DateTime.now + expires_in_days
163+
end
164+
165+
# requires all files inside a directory from current dir
166+
# @param _dir can be relative path like '/lib' or "../lib"
167+
private def require_all(_dir)
168+
Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), _dir)) + "/*.rb"].each do |file|
169+
require file
170+
end
171+
end
172+
end
173+
end
174+
#
175+
# --------------------------------------------------------------------------------------------------------------------
176+
# <copyright company="Aspose Pty Ltd" file="convert_document_request.rb">
177+
# Copyright (c) 2003-2019 Aspose Pty Ltd
178+
# </copyright>
179+
# <summary>
180+
# Permission is hereby granted, free of charge, to any person obtaining a copy
181+
# of this software and associated documentation files (the "Software"), to deal
182+
# in the Software without restriction, including without limitation the rights
183+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
184+
# copies of the Software, and to permit persons to whom the Software is
185+
# furnished to do so, subject to the following conditions:
186+
#
187+
# The above copyright notice and this permission notice shall be included in all
188+
# copies or substantial portions of the Software.
189+
#
190+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
191+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
192+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
193+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
194+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
195+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
196+
# SOFTWARE.
197+
# </summary>
198+
# --------------------------------------------------------------------------------------------------------------------
199+
#
200+
201+
module GroupDocsConversionCloud
202+
203+
#
204+
# Request model for convert_document operation.
205+
#
206+
class ConvertDocumentRequest
207+
208+
# Gets or sets convert_settings
209+
attr_accessor :convert_settings
210+
211+
#
212+
# Initializes a new instance.
213+
# @param convert_settings
214+
def initialize(convert_settings)
215+
self.convert_settings = convert_settings
216+
end
217+
end
218+
end

lib/groupdocs_conversion_cloud/api/file_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def upload_file_with_http_info(request)
378378

379379
# http body (model)
380380
post_body = nil
381-
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
381+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
382382
header_params: header_params,
383383
query_params: query_params,
384384
form_params: form_params,

lib/groupdocs_conversion_cloud/api/folder_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def create_folder_with_http_info(request)
174174

175175
# http body (model)
176176
post_body = nil
177-
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
177+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
178178
header_params: header_params,
179179
query_params: query_params,
180180
form_params: form_params,

0 commit comments

Comments
 (0)