groupdocs_comparison_cloud 18.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/lib/groupdocs_comparison_cloud.rb +76 -0
  3. data/lib/groupdocs_comparison_cloud/api/changes_api.rb +470 -0
  4. data/lib/groupdocs_comparison_cloud/api/comparison_api.rb +365 -0
  5. data/lib/groupdocs_comparison_cloud/api_client.rb +390 -0
  6. data/lib/groupdocs_comparison_cloud/api_error.rb +56 -0
  7. data/lib/groupdocs_comparison_cloud/configuration.rb +95 -0
  8. data/lib/groupdocs_comparison_cloud/models/color.rb +1404 -0
  9. data/lib/groupdocs_comparison_cloud/models/comparison_change.rb +265 -0
  10. data/lib/groupdocs_comparison_cloud/models/comparison_changes_category_dto.rb +218 -0
  11. data/lib/groupdocs_comparison_cloud/models/comparison_file_info.rb +226 -0
  12. data/lib/groupdocs_comparison_cloud/models/comparison_metadata_values.rb +226 -0
  13. data/lib/groupdocs_comparison_cloud/models/comparison_request.rb +240 -0
  14. data/lib/groupdocs_comparison_cloud/models/comparison_request_settings.rb +378 -0
  15. data/lib/groupdocs_comparison_cloud/models/comparison_style_change.rb +206 -0
  16. data/lib/groupdocs_comparison_cloud/models/link.rb +236 -0
  17. data/lib/groupdocs_comparison_cloud/models/requests/comparison_images_request.rb +49 -0
  18. data/lib/groupdocs_comparison_cloud/models/requests/comparison_images_stream_request.rb +45 -0
  19. data/lib/groupdocs_comparison_cloud/models/requests/comparison_request.rb +49 -0
  20. data/lib/groupdocs_comparison_cloud/models/requests/comparison_stream_request.rb +45 -0
  21. data/lib/groupdocs_comparison_cloud/models/requests/post_categories_changes_request.rb +49 -0
  22. data/lib/groupdocs_comparison_cloud/models/requests/post_changes_request.rb +45 -0
  23. data/lib/groupdocs_comparison_cloud/models/requests/put_changes_document_request.rb +49 -0
  24. data/lib/groupdocs_comparison_cloud/models/requests/put_changes_document_stream_request.rb +45 -0
  25. data/lib/groupdocs_comparison_cloud/models/requests/put_changes_images_request.rb +49 -0
  26. data/lib/groupdocs_comparison_cloud/models/requests/put_changes_images_stream_request.rb +45 -0
  27. data/lib/groupdocs_comparison_cloud/models/style_settings_values.rb +231 -0
  28. data/lib/groupdocs_comparison_cloud/models/value_type.rb +196 -0
  29. data/lib/groupdocs_comparison_cloud/version.rb +29 -0
  30. metadata +160 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 031e0ebd57fdcec3da78c30ed43a52ad3b743f6c
4
+ data.tar.gz: 5e004954197669c2a488d028d6959d7a26132623
5
+ SHA512:
6
+ metadata.gz: be5c9d5c448728199745f4175414855843f721ef01b2562ddc053f95a5bf3869b8eb26edf83ad75aefe5cb6b41bf843f8ac99672e19b6e88e04d728c940b69f7
7
+ data.tar.gz: eb397692fa0fbceeaf6fd819a720d967491eb95995979585dee1fefc7c73b66b0f5cc16ba2ee1fcbbacdefd78af553d0275d55b2ebabf8cbcda270225e30e80a
@@ -0,0 +1,76 @@
1
+ # ------------------------------------------------------------------------------------
2
+ # <copyright company="Aspose Pty Ltd" file="groupdocs_comparison_cloud.rb">
3
+ # Copyright (c) 2003-2018 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
+ # Common files
27
+ require_relative 'groupdocs_comparison_cloud/api_client'
28
+ require_relative 'groupdocs_comparison_cloud/api_error'
29
+ require_relative 'groupdocs_comparison_cloud/version'
30
+ require_relative 'groupdocs_comparison_cloud/configuration'
31
+
32
+ # Models
33
+ require_relative 'groupdocs_comparison_cloud/models/comparison_change'
34
+ require_relative 'groupdocs_comparison_cloud/models/comparison_changes_category_dto'
35
+ require_relative 'groupdocs_comparison_cloud/models/comparison_file_info'
36
+ require_relative 'groupdocs_comparison_cloud/models/comparison_metadata_values'
37
+ require_relative 'groupdocs_comparison_cloud/models/comparison_request'
38
+ require_relative 'groupdocs_comparison_cloud/models/comparison_request_settings'
39
+ require_relative 'groupdocs_comparison_cloud/models/comparison_style_change'
40
+ require_relative 'groupdocs_comparison_cloud/models/link'
41
+ require_relative 'groupdocs_comparison_cloud/models/style_settings_values'
42
+ require_relative 'groupdocs_comparison_cloud/models/value_type'
43
+ require_relative 'groupdocs_comparison_cloud/models/color'
44
+
45
+ # APIs
46
+ require_relative 'groupdocs_comparison_cloud/api/changes_api'
47
+ require_relative 'groupdocs_comparison_cloud/api/comparison_api'
48
+
49
+ module GroupDocsComparisonCloud
50
+ # Main module
51
+ class << self
52
+ # Initialize SDK with API keys.
53
+ #
54
+ # app_sid = "xxx"
55
+ # app_key = "xxx"
56
+ #
57
+ # GroupDocsComparisonCloud.from_keys(app_sid, app_key)
58
+ def from_keys(app_sid, app_key)
59
+ ComparisonApi.from_keys(app_sid, app_key)
60
+ end
61
+
62
+ # Initialize SDK with Configuration.
63
+ #
64
+ # app_sid = "xxx"
65
+ # app_key = "xxx"
66
+ #
67
+ # config = GroupDocsComparisonCloud::Configuration.new(app_sid, app_key)
68
+ # config.debugging = true
69
+ # config.temp_folder_path = "./temp"
70
+ #
71
+ # GroupDocsComparisonCloud.from_config(config)
72
+ def from_config(config)
73
+ ComparisonApi.from_config(config)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,470 @@
1
+ # -----------------------------------------------------------------------------------
2
+ # <copyright company="Aspose Pty Ltd" file="changes.rb">
3
+ # Copyright (c) 2003-2018 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 GroupDocsComparisonCloud
30
+ #
31
+ # GroupDocs.Comparison Cloud API
32
+ #
33
+ class ChangesApi
34
+ attr_accessor :config
35
+
36
+ #make ChangesApi.new private
37
+ private_class_method :new
38
+
39
+ # Initializes new instance of ChangesApi
40
+ #
41
+ # @param [config] Configuration
42
+ # @return [ChangesApi] New instance of ChangesApi
43
+ def initialize(config)
44
+ @config = config
45
+ @api_client = ApiClient.new(config)
46
+ require_all '../models/requests'
47
+
48
+ @access_token = nil
49
+ end
50
+
51
+ # Initializes new instance of ChangesApi
52
+ #
53
+ # @param [app_sid] Application identifier (App SID)
54
+ # @param [app_key] Application private key (App Key)
55
+ # @return [ChangesApi] New instance of ChangesApi
56
+ def self.from_keys(app_sid, app_key)
57
+ config = Configuration.new(app_sid, app_key)
58
+ return new(config)
59
+ end
60
+
61
+ # Initializes new instance of ChangesApi
62
+ #
63
+ # @param [config] Configuration
64
+ # @return [ChangesApi] New instance of ChangesApi
65
+ def self.from_config(config)
66
+ return new(config)
67
+ end
68
+
69
+ # Posts the categories changes.
70
+ #
71
+ # @param request post_categories_changes_request
72
+ # @return [Array<ComparisonChangesCategoryDto>]
73
+ def post_categories_changes(request)
74
+ data, _status_code, _headers = post_categories_changes_with_http_info(request)
75
+ data
76
+ end
77
+
78
+ # Posts the categories changes.
79
+ #
80
+ # @param request post_categories_changes_request
81
+ # @return [Array<(Array<ComparisonChangesCategoryDto>, Fixnum, Hash)>]
82
+ # Array<ComparisonChangesCategoryDto> data, response status code and response headers
83
+ def post_categories_changes_with_http_info(request)
84
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? PostCategoriesChangesRequest
85
+
86
+ @api_client.config.logger.debug 'Calling API: ChangesApi.post_categories_changes ...' if @api_client.config.debugging
87
+ # resource path
88
+ local_var_path = '/comparison/compareDocuments/changes/categories'
89
+
90
+ # query parameters
91
+ query_params = {}
92
+ if local_var_path.include? ('{' + downcase_first_letter('CategoriesType') + '}')
93
+ local_var_path = local_var_path.sub('{' + downcase_first_letter('CategoriesType') + '}', request.categories_type.to_s)
94
+ else
95
+ query_params[downcase_first_letter('CategoriesType')] = request.categories_type unless request.categories_type.nil?
96
+ end
97
+
98
+ # header parameters
99
+ header_params = {}
100
+ # HTTP header 'Accept' (if needed)
101
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
102
+ # HTTP header 'Content-Type'
103
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
104
+
105
+ # form parameters
106
+ form_params = {}
107
+
108
+ # http body (model)
109
+ post_body = @api_client.object_to_http_body(request.request)
110
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
111
+ header_params: header_params,
112
+ query_params: query_params,
113
+ form_params: form_params,
114
+ body: post_body,
115
+ access_token: get_access_token,
116
+ return_type: 'Array<ComparisonChangesCategoryDto>')
117
+ if @api_client.config.debugging
118
+ @api_client.config.logger.debug "API called:
119
+ ChangesApi#post_categories_changes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
120
+ end
121
+ [data, status_code, headers]
122
+ end
123
+
124
+ # Returns json result with set of changes between documents
125
+ #
126
+ # @param request post_changes_request
127
+ # @return [Array<ComparisonChange>]
128
+ def post_changes(request)
129
+ data, _status_code, _headers = post_changes_with_http_info(request)
130
+ data
131
+ end
132
+
133
+ # Returns json result with set of changes between documents
134
+ #
135
+ # @param request post_changes_request
136
+ # @return [Array<(Array<ComparisonChange>, Fixnum, Hash)>]
137
+ # Array<ComparisonChange> data, response status code and response headers
138
+ def post_changes_with_http_info(request)
139
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? PostChangesRequest
140
+
141
+ @api_client.config.logger.debug 'Calling API: ChangesApi.post_changes ...' if @api_client.config.debugging
142
+ # resource path
143
+ local_var_path = '/comparison/compareDocuments/changes'
144
+
145
+ # query parameters
146
+ query_params = {}
147
+
148
+ # header parameters
149
+ header_params = {}
150
+ # HTTP header 'Accept' (if needed)
151
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
152
+ # HTTP header 'Content-Type'
153
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
154
+
155
+ # form parameters
156
+ form_params = {}
157
+
158
+ # http body (model)
159
+ post_body = @api_client.object_to_http_body(request.request)
160
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
161
+ header_params: header_params,
162
+ query_params: query_params,
163
+ form_params: form_params,
164
+ body: post_body,
165
+ access_token: get_access_token,
166
+ return_type: 'Array<ComparisonChange>')
167
+ if @api_client.config.debugging
168
+ @api_client.config.logger.debug "API called:
169
+ ChangesApi#post_changes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
170
+ end
171
+ [data, status_code, headers]
172
+ end
173
+
174
+ # Applies changes to the document and returns document with the result of comparison
175
+ #
176
+ # @param request put_changes_document_request
177
+ # @return [Link]
178
+ def put_changes_document(request)
179
+ data, _status_code, _headers = put_changes_document_with_http_info(request)
180
+ data
181
+ end
182
+
183
+ # Applies changes to the document and returns document with the result of comparison
184
+ #
185
+ # @param request put_changes_document_request
186
+ # @return [Array<(Link, Fixnum, Hash)>]
187
+ # Link data, response status code and response headers
188
+ def put_changes_document_with_http_info(request)
189
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? PutChangesDocumentRequest
190
+
191
+ @api_client.config.logger.debug 'Calling API: ChangesApi.put_changes_document ...' if @api_client.config.debugging
192
+ # resource path
193
+ local_var_path = '/comparison/compareDocuments/changes/update'
194
+
195
+ # query parameters
196
+ query_params = {}
197
+ if local_var_path.include? ('{' + downcase_first_letter('OutPath') + '}')
198
+ local_var_path = local_var_path.sub('{' + downcase_first_letter('OutPath') + '}', request.out_path.to_s)
199
+ else
200
+ query_params[downcase_first_letter('OutPath')] = request.out_path unless request.out_path.nil?
201
+ end
202
+
203
+ # header parameters
204
+ header_params = {}
205
+ # HTTP header 'Accept' (if needed)
206
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
207
+ # HTTP header 'Content-Type'
208
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
209
+
210
+ # form parameters
211
+ form_params = {}
212
+
213
+ # http body (model)
214
+ post_body = @api_client.object_to_http_body(request.request)
215
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
216
+ header_params: header_params,
217
+ query_params: query_params,
218
+ form_params: form_params,
219
+ body: post_body,
220
+ access_token: get_access_token,
221
+ return_type: 'Link')
222
+ if @api_client.config.debugging
223
+ @api_client.config.logger.debug "API called:
224
+ ChangesApi#put_changes_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
225
+ end
226
+ [data, status_code, headers]
227
+ end
228
+
229
+ # Applies changes to the document and returns stream of document with the result of comparison
230
+ #
231
+ # @param request put_changes_document_stream_request
232
+ # @return [File]
233
+ def put_changes_document_stream(request)
234
+ data, _status_code, _headers = put_changes_document_stream_with_http_info(request)
235
+ data
236
+ end
237
+
238
+ # Applies changes to the document and returns stream of document with the result of comparison
239
+ #
240
+ # @param request put_changes_document_stream_request
241
+ # @return [Array<(File, Fixnum, Hash)>]
242
+ # File data, response status code and response headers
243
+ def put_changes_document_stream_with_http_info(request)
244
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? PutChangesDocumentStreamRequest
245
+
246
+ @api_client.config.logger.debug 'Calling API: ChangesApi.put_changes_document_stream ...' if @api_client.config.debugging
247
+ # resource path
248
+ local_var_path = '/comparison/compareDocuments/changes/stream'
249
+
250
+ # query parameters
251
+ query_params = {}
252
+
253
+ # header parameters
254
+ header_params = {}
255
+ # HTTP header 'Accept' (if needed)
256
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
257
+ # HTTP header 'Content-Type'
258
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
259
+
260
+ # form parameters
261
+ form_params = {}
262
+
263
+ # http body (model)
264
+ post_body = @api_client.object_to_http_body(request.request)
265
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
266
+ header_params: header_params,
267
+ query_params: query_params,
268
+ form_params: form_params,
269
+ body: post_body,
270
+ access_token: get_access_token,
271
+ return_type: 'File')
272
+ if @api_client.config.debugging
273
+ @api_client.config.logger.debug "API called:
274
+ ChangesApi#put_changes_document_stream\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
275
+ end
276
+ [data, status_code, headers]
277
+ end
278
+
279
+ # Applies changes to the document and returns images of document with the result of comparison
280
+ #
281
+ # @param request put_changes_images_request
282
+ # @return [Array<Link>]
283
+ def put_changes_images(request)
284
+ data, _status_code, _headers = put_changes_images_with_http_info(request)
285
+ data
286
+ end
287
+
288
+ # Applies changes to the document and returns images of document with the result of comparison
289
+ #
290
+ # @param request put_changes_images_request
291
+ # @return [Array<(Array<Link>, Fixnum, Hash)>]
292
+ # Array<Link> data, response status code and response headers
293
+ def put_changes_images_with_http_info(request)
294
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? PutChangesImagesRequest
295
+
296
+ @api_client.config.logger.debug 'Calling API: ChangesApi.put_changes_images ...' if @api_client.config.debugging
297
+ # resource path
298
+ local_var_path = '/comparison/compareDocuments/changes/images'
299
+
300
+ # query parameters
301
+ query_params = {}
302
+ if local_var_path.include? ('{' + downcase_first_letter('OutFolder') + '}')
303
+ local_var_path = local_var_path.sub('{' + downcase_first_letter('OutFolder') + '}', request.out_folder.to_s)
304
+ else
305
+ query_params[downcase_first_letter('OutFolder')] = request.out_folder unless request.out_folder.nil?
306
+ end
307
+
308
+ # header parameters
309
+ header_params = {}
310
+ # HTTP header 'Accept' (if needed)
311
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
312
+ # HTTP header 'Content-Type'
313
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
314
+
315
+ # form parameters
316
+ form_params = {}
317
+
318
+ # http body (model)
319
+ post_body = @api_client.object_to_http_body(request.request)
320
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
321
+ header_params: header_params,
322
+ query_params: query_params,
323
+ form_params: form_params,
324
+ body: post_body,
325
+ access_token: get_access_token,
326
+ return_type: 'Array<Link>')
327
+ if @api_client.config.debugging
328
+ @api_client.config.logger.debug "API called:
329
+ ChangesApi#put_changes_images\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
330
+ end
331
+ [data, status_code, headers]
332
+ end
333
+
334
+ # Applies changes to the document and returns image's streams of document with the result of comparison
335
+ #
336
+ # @param request put_changes_images_stream_request
337
+ # @return [File]
338
+ def put_changes_images_stream(request)
339
+ data, _status_code, _headers = put_changes_images_stream_with_http_info(request)
340
+ data
341
+ end
342
+
343
+ # Applies changes to the document and returns image&#39;s streams of document with the result of comparison
344
+ #
345
+ # @param request put_changes_images_stream_request
346
+ # @return [Array<(File, Fixnum, Hash)>]
347
+ # File data, response status code and response headers
348
+ def put_changes_images_stream_with_http_info(request)
349
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? PutChangesImagesStreamRequest
350
+
351
+ @api_client.config.logger.debug 'Calling API: ChangesApi.put_changes_images_stream ...' if @api_client.config.debugging
352
+ # resource path
353
+ local_var_path = '/comparison/compareDocuments/changes/stream/images'
354
+
355
+ # query parameters
356
+ query_params = {}
357
+
358
+ # header parameters
359
+ header_params = {}
360
+ # HTTP header 'Accept' (if needed)
361
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
362
+ # HTTP header 'Content-Type'
363
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
364
+
365
+ # form parameters
366
+ form_params = {}
367
+
368
+ # http body (model)
369
+ post_body = @api_client.object_to_http_body(request.request)
370
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
371
+ header_params: header_params,
372
+ query_params: query_params,
373
+ form_params: form_params,
374
+ body: post_body,
375
+ access_token: get_access_token,
376
+ return_type: 'File')
377
+ if @api_client.config.debugging
378
+ @api_client.config.logger.debug "API called:
379
+ ChangesApi#put_changes_images_stream\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
380
+ end
381
+ [data, status_code, headers]
382
+ end
383
+
384
+ #
385
+ # Helper method to convert first letter to downcase
386
+ #
387
+ private def downcase_first_letter(str)
388
+ value = str[0].downcase + str[1..-1]
389
+ value
390
+ end
391
+
392
+ #
393
+ # Retrieves access token
394
+ #
395
+ private def get_access_token
396
+ if @access_token.nil? then
397
+ request_access_token
398
+ else
399
+ access_token_expired = @access_token_expires_at < DateTime.now
400
+ if access_token_expired then
401
+ reset_access_token
402
+ end
403
+ end
404
+
405
+ @access_token
406
+ end
407
+
408
+ #
409
+ # Gets a access token from server
410
+ #
411
+ private def request_access_token
412
+ auth_config = Configuration.new(@config.app_sid, @config.app_key)
413
+ auth_config.api_base_url = @config.api_base_url
414
+ auth_config.debugging = @config.debugging
415
+ auth_config.logger = @config.logger
416
+ auth_config.temp_folder_path = @config.temp_folder_path
417
+ auth_config.client_side_validation = @config.client_side_validation
418
+ auth_config.api_version = ''
419
+
420
+ auth_api_client = ApiClient.new(auth_config)
421
+
422
+ request_url = "/oauth2/token"
423
+ post_data = "grant_type=client_credentials&client_id=#{@config.app_sid}&client_secret=#{@config.app_key}"
424
+
425
+ data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
426
+
427
+ @access_token = data[:access_token]
428
+ @refresh_token = data[:refresh_token]
429
+
430
+ expires_in_seconds = data[:expires_in].to_i - 5 * 60
431
+ expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
432
+ @access_token_expires_at = DateTime.now + expires_in_days
433
+ end
434
+
435
+ #
436
+ # Resets access token
437
+ #
438
+ private def reset_access_token
439
+ auth_config = Configuration.new(@config.app_sid, @config.app_key)
440
+ auth_config.api_base_url = @config.api_base_url
441
+ auth_config.debugging = @config.debugging
442
+ auth_config.logger = @config.logger
443
+ auth_config.temp_folder_path = @config.temp_folder_path
444
+ auth_config.client_side_validation = @config.client_side_validation
445
+ auth_config.api_version = ''
446
+
447
+ auth_api_client = ApiClient.new(auth_config)
448
+
449
+ request_url = "/oauth2/token"
450
+ post_data = "grant_type=refresh_token&refresh_token=#{@refresh_token}"
451
+
452
+ data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
453
+
454
+ @access_token = data[:access_token]
455
+ @refresh_token = data[:refresh_token]
456
+
457
+ expires_in_seconds = data[:expires_in].to_i - 5 * 60
458
+ expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
459
+ @access_token_expires_at = DateTime.now + expires_in_days
460
+ end
461
+
462
+ # requires all files inside a directory from current dir
463
+ # @param _dir can be relative path like '/lib' or "../lib"
464
+ private def require_all(_dir)
465
+ Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), _dir)) + "/*.rb"].each do |file|
466
+ require file
467
+ end
468
+ end
469
+ end
470
+ end