groupdocs_annotation_cloud 18.7 → 19.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/groupdocs_annotation_cloud.rb +23 -39
  3. data/lib/groupdocs_annotation_cloud/api/annotate_api.rb +664 -0
  4. data/lib/groupdocs_annotation_cloud/api/file_api.rb +729 -0
  5. data/lib/groupdocs_annotation_cloud/api/folder_api.rb +694 -0
  6. data/lib/groupdocs_annotation_cloud/api/{pdf_file_api.rb → info_api.rb} +101 -105
  7. data/lib/groupdocs_annotation_cloud/api/preview_api.rb +380 -0
  8. data/lib/groupdocs_annotation_cloud/api/storage_api.rb +541 -0
  9. data/lib/groupdocs_annotation_cloud/api_client.rb +7 -17
  10. data/lib/groupdocs_annotation_cloud/api_error.rb +5 -3
  11. data/lib/groupdocs_annotation_cloud/configuration.rb +3 -3
  12. data/lib/groupdocs_annotation_cloud/models/annotation_api_link.rb +24 -16
  13. data/lib/groupdocs_annotation_cloud/models/annotation_info.rb +97 -82
  14. data/lib/groupdocs_annotation_cloud/models/annotation_reply_info.rb +31 -23
  15. data/lib/groupdocs_annotation_cloud/models/disc_usage.rb +234 -0
  16. data/lib/groupdocs_annotation_cloud/models/document_info.rb +44 -22
  17. data/lib/groupdocs_annotation_cloud/models/error.rb +244 -0
  18. data/lib/groupdocs_annotation_cloud/models/error_details.rb +229 -0
  19. data/lib/groupdocs_annotation_cloud/models/file_version.rb +289 -0
  20. data/lib/groupdocs_annotation_cloud/models/{value_type.rb → file_versions.rb} +33 -13
  21. data/lib/groupdocs_annotation_cloud/models/files_list.rb +216 -0
  22. data/lib/groupdocs_annotation_cloud/models/files_upload_result.rb +228 -0
  23. data/lib/groupdocs_annotation_cloud/models/format.rb +224 -0
  24. data/lib/groupdocs_annotation_cloud/models/formats_result.rb +216 -0
  25. data/lib/groupdocs_annotation_cloud/models/link.rb +24 -16
  26. data/lib/groupdocs_annotation_cloud/models/link_element.rb +18 -10
  27. data/lib/groupdocs_annotation_cloud/models/object_exist.rb +234 -0
  28. data/lib/groupdocs_annotation_cloud/models/{image_page.rb → page_image.rb} +28 -13
  29. data/lib/groupdocs_annotation_cloud/models/{image_pages.rb → page_images.rb} +26 -14
  30. data/lib/groupdocs_annotation_cloud/models/page_info.rb +41 -23
  31. data/lib/groupdocs_annotation_cloud/models/point.rb +31 -13
  32. data/lib/groupdocs_annotation_cloud/models/rectangle.rb +45 -17
  33. data/lib/groupdocs_annotation_cloud/models/row_info.rb +38 -16
  34. data/lib/groupdocs_annotation_cloud/models/storage_exist.rb +219 -0
  35. data/lib/groupdocs_annotation_cloud/models/storage_file.rb +264 -0
  36. data/lib/groupdocs_annotation_cloud/version.rb +2 -2
  37. metadata +22 -39
  38. data/lib/groupdocs_annotation_cloud/api/annotation_api.rb +0 -344
  39. data/lib/groupdocs_annotation_cloud/api/image_info_api.rb +0 -218
  40. data/lib/groupdocs_annotation_cloud/api/image_pages_api.rb +0 -395
  41. data/lib/groupdocs_annotation_cloud/models/requests/delete_clean_document_request.rb +0 -53
  42. data/lib/groupdocs_annotation_cloud/models/requests/delete_pages_request.rb +0 -49
  43. data/lib/groupdocs_annotation_cloud/models/requests/get_import_request.rb +0 -53
  44. data/lib/groupdocs_annotation_cloud/models/requests/get_info_request.rb +0 -53
  45. data/lib/groupdocs_annotation_cloud/models/requests/get_page_request.rb +0 -53
  46. data/lib/groupdocs_annotation_cloud/models/requests/get_pages_request.rb +0 -49
  47. data/lib/groupdocs_annotation_cloud/models/requests/get_pdf_request.rb +0 -53
  48. data/lib/groupdocs_annotation_cloud/models/requests/get_pdf_stream_request.rb +0 -53
  49. data/lib/groupdocs_annotation_cloud/models/requests/post_pages_request.rb +0 -53
  50. data/lib/groupdocs_annotation_cloud/models/requests/put_export_request.rb +0 -57
@@ -1,218 +0,0 @@
1
- # -----------------------------------------------------------------------------------
2
- # <copyright company="Aspose Pty Ltd" file="imageInfo.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 GroupDocsAnnotationCloud
30
- #
31
- # GroupDocs.Annotation Cloud API
32
- #
33
- class ImageInfoApi
34
- attr_accessor :config
35
-
36
- #make ImageInfoApi.new private
37
- private_class_method :new
38
-
39
- # Initializes new instance of ImageInfoApi
40
- #
41
- # @param [config] Configuration
42
- # @return [ImageInfoApi] New instance of ImageInfoApi
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 ImageInfoApi
52
- #
53
- # @param [app_sid] Application identifier (App SID)
54
- # @param [app_key] Application private key (App Key)
55
- # @return [ImageInfoApi] New instance of ImageInfoApi
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 ImageInfoApi
62
- #
63
- # @param [config] Configuration
64
- # @return [ImageInfoApi] New instance of ImageInfoApi
65
- def self.from_config(config)
66
- return new(config)
67
- end
68
-
69
- # Retrieves document's information.
70
- #
71
- # @param request get_info_request
72
- # @return [DocumentInfo]
73
- def get_info(request)
74
- data, _status_code, _headers = get_info_with_http_info(request)
75
- data
76
- end
77
-
78
- # Retrieves document's information.
79
- #
80
- # @param request get_info_request
81
- # @return [Array<(DocumentInfo, Fixnum, Hash)>]
82
- # DocumentInfo data, response status code and response headers
83
- def get_info_with_http_info(request)
84
- raise ArgumentError, 'Incorrect request type' unless request.is_a? GetInfoRequest
85
-
86
- @api_client.config.logger.debug 'Calling API: ImageInfoApi.get_info ...' if @api_client.config.debugging
87
- # verify the required parameter 'name' is set
88
- raise ArgumentError, 'Missing the required parameter name when calling ImageInfoApi.get_info' if @api_client.config.client_side_validation && request.name.nil?
89
- # resource path
90
- local_var_path = '/annotation/{name}/image/info'
91
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.to_s)
92
-
93
- # query parameters
94
- query_params = {}
95
- if local_var_path.include? ('{' + downcase_first_letter('Folder') + '}')
96
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Folder') + '}', request.folder.to_s)
97
- else
98
- query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
99
- end
100
- if local_var_path.include? ('{' + downcase_first_letter('Password') + '}')
101
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Password') + '}', request.password.to_s)
102
- else
103
- query_params[downcase_first_letter('Password')] = request.password unless request.password.nil?
104
- end
105
-
106
- # header parameters
107
- header_params = {}
108
- # HTTP header 'Accept' (if needed)
109
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
110
- # HTTP header 'Content-Type'
111
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
112
-
113
- # form parameters
114
- form_params = {}
115
-
116
- # http body (model)
117
- post_body = nil
118
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
119
- header_params: header_params,
120
- query_params: query_params,
121
- form_params: form_params,
122
- body: post_body,
123
- access_token: get_access_token,
124
- return_type: 'DocumentInfo')
125
- if @api_client.config.debugging
126
- @api_client.config.logger.debug "API called:
127
- ImageInfoApi#get_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
128
- end
129
- [data, status_code, headers]
130
- end
131
-
132
- #
133
- # Helper method to convert first letter to downcase
134
- #
135
- private def downcase_first_letter(str)
136
- value = str[0].downcase + str[1..-1]
137
- value
138
- end
139
-
140
- #
141
- # Retrieves access token
142
- #
143
- private def get_access_token
144
- if @access_token.nil? then
145
- request_access_token
146
- else
147
- access_token_expired = @access_token_expires_at < DateTime.now
148
- if access_token_expired then
149
- reset_access_token
150
- end
151
- end
152
-
153
- @access_token
154
- end
155
-
156
- #
157
- # Gets a access token from server
158
- #
159
- private def request_access_token
160
- auth_config = Configuration.new(@config.app_sid, @config.app_key)
161
- auth_config.api_base_url = @config.api_base_url
162
- auth_config.debugging = @config.debugging
163
- auth_config.logger = @config.logger
164
- auth_config.temp_folder_path = @config.temp_folder_path
165
- auth_config.client_side_validation = @config.client_side_validation
166
- auth_config.api_version = ''
167
-
168
- auth_api_client = ApiClient.new(auth_config)
169
-
170
- request_url = "/oauth2/token"
171
- post_data = "grant_type=client_credentials&client_id=#{@config.app_sid}&client_secret=#{@config.app_key}"
172
-
173
- data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
174
-
175
- @access_token = data[:access_token]
176
- @refresh_token = data[:refresh_token]
177
-
178
- expires_in_seconds = data[:expires_in].to_i - 5 * 60
179
- expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
180
- @access_token_expires_at = DateTime.now + expires_in_days
181
- end
182
-
183
- #
184
- # Resets access token
185
- #
186
- private def reset_access_token
187
- auth_config = Configuration.new(@config.app_sid, @config.app_key)
188
- auth_config.api_base_url = @config.api_base_url
189
- auth_config.debugging = @config.debugging
190
- auth_config.logger = @config.logger
191
- auth_config.temp_folder_path = @config.temp_folder_path
192
- auth_config.client_side_validation = @config.client_side_validation
193
- auth_config.api_version = ''
194
-
195
- auth_api_client = ApiClient.new(auth_config)
196
-
197
- request_url = "/oauth2/token"
198
- post_data = "grant_type=refresh_token&refresh_token=#{@refresh_token}"
199
-
200
- data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
201
-
202
- @access_token = data[:access_token]
203
- @refresh_token = data[:refresh_token]
204
-
205
- expires_in_seconds = data[:expires_in].to_i - 5 * 60
206
- expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
207
- @access_token_expires_at = DateTime.now + expires_in_days
208
- end
209
-
210
- # requires all files inside a directory from current dir
211
- # @param _dir can be relative path like '/lib' or "../lib"
212
- private def require_all(_dir)
213
- Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), _dir)) + "/*.rb"].each do |file|
214
- require file
215
- end
216
- end
217
- end
218
- end
@@ -1,395 +0,0 @@
1
- # -----------------------------------------------------------------------------------
2
- # <copyright company="Aspose Pty Ltd" file="imagePages.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 GroupDocsAnnotationCloud
30
- #
31
- # GroupDocs.Annotation Cloud API
32
- #
33
- class ImagePagesApi
34
- attr_accessor :config
35
-
36
- #make ImagePagesApi.new private
37
- private_class_method :new
38
-
39
- # Initializes new instance of ImagePagesApi
40
- #
41
- # @param [config] Configuration
42
- # @return [ImagePagesApi] New instance of ImagePagesApi
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 ImagePagesApi
52
- #
53
- # @param [app_sid] Application identifier (App SID)
54
- # @param [app_key] Application private key (App Key)
55
- # @return [ImagePagesApi] New instance of ImagePagesApi
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 ImagePagesApi
62
- #
63
- # @param [config] Configuration
64
- # @return [ImagePagesApi] New instance of ImagePagesApi
65
- def self.from_config(config)
66
- return new(config)
67
- end
68
-
69
- # Removes document's pages as image.
70
- #
71
- # @param request delete_pages_request
72
- # @return [File]
73
- def delete_pages(request)
74
- data, _status_code, _headers = delete_pages_with_http_info(request)
75
- data
76
- end
77
-
78
- # Removes document's pages as image.
79
- #
80
- # @param request delete_pages_request
81
- # @return [Array<(File, Fixnum, Hash)>]
82
- # File data, response status code and response headers
83
- def delete_pages_with_http_info(request)
84
- raise ArgumentError, 'Incorrect request type' unless request.is_a? DeletePagesRequest
85
-
86
- @api_client.config.logger.debug 'Calling API: ImagePagesApi.delete_pages ...' if @api_client.config.debugging
87
- # verify the required parameter 'name' is set
88
- raise ArgumentError, 'Missing the required parameter name when calling ImagePagesApi.delete_pages' if @api_client.config.client_side_validation && request.name.nil?
89
- # resource path
90
- local_var_path = '/annotation/{name}/image/pages'
91
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.to_s)
92
-
93
- # query parameters
94
- query_params = {}
95
- if local_var_path.include? ('{' + downcase_first_letter('Folder') + '}')
96
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Folder') + '}', request.folder.to_s)
97
- else
98
- query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
99
- end
100
-
101
- # header parameters
102
- header_params = {}
103
- # HTTP header 'Accept' (if needed)
104
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
105
- # HTTP header 'Content-Type'
106
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
107
-
108
- # form parameters
109
- form_params = {}
110
-
111
- # http body (model)
112
- post_body = nil
113
- data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
114
- header_params: header_params,
115
- query_params: query_params,
116
- form_params: form_params,
117
- body: post_body,
118
- access_token: get_access_token,
119
- return_type: 'File')
120
- if @api_client.config.debugging
121
- @api_client.config.logger.debug "API called:
122
- ImagePagesApi#delete_pages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
123
- end
124
- [data, status_code, headers]
125
- end
126
-
127
- # Downloads document's page as image.
128
- #
129
- # @param request get_page_request
130
- # @return [ImagePage]
131
- def get_page(request)
132
- data, _status_code, _headers = get_page_with_http_info(request)
133
- data
134
- end
135
-
136
- # Downloads document's page as image.
137
- #
138
- # @param request get_page_request
139
- # @return [Array<(ImagePage, Fixnum, Hash)>]
140
- # ImagePage data, response status code and response headers
141
- def get_page_with_http_info(request)
142
- raise ArgumentError, 'Incorrect request type' unless request.is_a? GetPageRequest
143
-
144
- @api_client.config.logger.debug 'Calling API: ImagePagesApi.get_page ...' if @api_client.config.debugging
145
- # verify the required parameter 'name' is set
146
- raise ArgumentError, 'Missing the required parameter name when calling ImagePagesApi.get_page' if @api_client.config.client_side_validation && request.name.nil?
147
- # verify the required parameter 'page_number' is set
148
- raise ArgumentError, 'Missing the required parameter page_number when calling ImagePagesApi.get_page' if @api_client.config.client_side_validation && request.page_number.nil?
149
- # resource path
150
- local_var_path = '/annotation/{name}/image/pages/{pageNumber}'
151
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.to_s)
152
- local_var_path = local_var_path.sub('{' + downcase_first_letter('PageNumber') + '}', request.page_number.to_s)
153
-
154
- # query parameters
155
- query_params = {}
156
- if local_var_path.include? ('{' + downcase_first_letter('Folder') + '}')
157
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Folder') + '}', request.folder.to_s)
158
- else
159
- query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
160
- end
161
-
162
- # header parameters
163
- header_params = {}
164
- # HTTP header 'Accept' (if needed)
165
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
166
- # HTTP header 'Content-Type'
167
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
168
-
169
- # form parameters
170
- form_params = {}
171
-
172
- # http body (model)
173
- post_body = nil
174
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
175
- header_params: header_params,
176
- query_params: query_params,
177
- form_params: form_params,
178
- body: post_body,
179
- access_token: get_access_token,
180
- return_type: 'ImagePage')
181
- if @api_client.config.debugging
182
- @api_client.config.logger.debug "API called:
183
- ImagePagesApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
184
- end
185
- [data, status_code, headers]
186
- end
187
-
188
- # Retrieves document's pages as images.
189
- #
190
- # @param request get_pages_request
191
- # @return [ImagePages]
192
- def get_pages(request)
193
- data, _status_code, _headers = get_pages_with_http_info(request)
194
- data
195
- end
196
-
197
- # Retrieves document's pages as images.
198
- #
199
- # @param request get_pages_request
200
- # @return [Array<(ImagePages, Fixnum, Hash)>]
201
- # ImagePages data, response status code and response headers
202
- def get_pages_with_http_info(request)
203
- raise ArgumentError, 'Incorrect request type' unless request.is_a? GetPagesRequest
204
-
205
- @api_client.config.logger.debug 'Calling API: ImagePagesApi.get_pages ...' if @api_client.config.debugging
206
- # verify the required parameter 'name' is set
207
- raise ArgumentError, 'Missing the required parameter name when calling ImagePagesApi.get_pages' if @api_client.config.client_side_validation && request.name.nil?
208
- # resource path
209
- local_var_path = '/annotation/{name}/image/pages'
210
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.to_s)
211
-
212
- # query parameters
213
- query_params = {}
214
- if local_var_path.include? ('{' + downcase_first_letter('Folder') + '}')
215
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Folder') + '}', request.folder.to_s)
216
- else
217
- query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
218
- end
219
-
220
- # header parameters
221
- header_params = {}
222
- # HTTP header 'Accept' (if needed)
223
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
224
- # HTTP header 'Content-Type'
225
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
226
-
227
- # form parameters
228
- form_params = {}
229
-
230
- # http body (model)
231
- post_body = nil
232
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
233
- header_params: header_params,
234
- query_params: query_params,
235
- form_params: form_params,
236
- body: post_body,
237
- access_token: get_access_token,
238
- return_type: 'ImagePages')
239
- if @api_client.config.debugging
240
- @api_client.config.logger.debug "API called:
241
- ImagePagesApi#get_pages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
242
- end
243
- [data, status_code, headers]
244
- end
245
-
246
- # Creates document's pages as image.
247
- #
248
- # @param request post_pages_request
249
- # @return [ImagePages]
250
- def post_pages(request)
251
- data, _status_code, _headers = post_pages_with_http_info(request)
252
- data
253
- end
254
-
255
- # Creates document's pages as image.
256
- #
257
- # @param request post_pages_request
258
- # @return [Array<(ImagePages, Fixnum, Hash)>]
259
- # ImagePages data, response status code and response headers
260
- def post_pages_with_http_info(request)
261
- raise ArgumentError, 'Incorrect request type' unless request.is_a? PostPagesRequest
262
-
263
- @api_client.config.logger.debug 'Calling API: ImagePagesApi.post_pages ...' if @api_client.config.debugging
264
- # verify the required parameter 'name' is set
265
- raise ArgumentError, 'Missing the required parameter name when calling ImagePagesApi.post_pages' if @api_client.config.client_side_validation && request.name.nil?
266
- # resource path
267
- local_var_path = '/annotation/{name}/image/pages'
268
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.to_s)
269
-
270
- # query parameters
271
- query_params = {}
272
- if local_var_path.include? ('{' + downcase_first_letter('Folder') + '}')
273
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Folder') + '}', request.folder.to_s)
274
- else
275
- query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
276
- end
277
- if local_var_path.include? ('{' + downcase_first_letter('Password') + '}')
278
- local_var_path = local_var_path.sub('{' + downcase_first_letter('Password') + '}', request.password.to_s)
279
- else
280
- query_params[downcase_first_letter('Password')] = request.password unless request.password.nil?
281
- end
282
-
283
- # header parameters
284
- header_params = {}
285
- # HTTP header 'Accept' (if needed)
286
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
287
- # HTTP header 'Content-Type'
288
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
289
-
290
- # form parameters
291
- form_params = {}
292
-
293
- # http body (model)
294
- post_body = nil
295
- data, status_code, headers = @api_client.call_api(:POST, local_var_path,
296
- header_params: header_params,
297
- query_params: query_params,
298
- form_params: form_params,
299
- body: post_body,
300
- access_token: get_access_token,
301
- return_type: 'ImagePages')
302
- if @api_client.config.debugging
303
- @api_client.config.logger.debug "API called:
304
- ImagePagesApi#post_pages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
305
- end
306
- [data, status_code, headers]
307
- end
308
-
309
- #
310
- # Helper method to convert first letter to downcase
311
- #
312
- private def downcase_first_letter(str)
313
- value = str[0].downcase + str[1..-1]
314
- value
315
- end
316
-
317
- #
318
- # Retrieves access token
319
- #
320
- private def get_access_token
321
- if @access_token.nil? then
322
- request_access_token
323
- else
324
- access_token_expired = @access_token_expires_at < DateTime.now
325
- if access_token_expired then
326
- reset_access_token
327
- end
328
- end
329
-
330
- @access_token
331
- end
332
-
333
- #
334
- # Gets a access token from server
335
- #
336
- private def request_access_token
337
- auth_config = Configuration.new(@config.app_sid, @config.app_key)
338
- auth_config.api_base_url = @config.api_base_url
339
- auth_config.debugging = @config.debugging
340
- auth_config.logger = @config.logger
341
- auth_config.temp_folder_path = @config.temp_folder_path
342
- auth_config.client_side_validation = @config.client_side_validation
343
- auth_config.api_version = ''
344
-
345
- auth_api_client = ApiClient.new(auth_config)
346
-
347
- request_url = "/oauth2/token"
348
- post_data = "grant_type=client_credentials&client_id=#{@config.app_sid}&client_secret=#{@config.app_key}"
349
-
350
- data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
351
-
352
- @access_token = data[:access_token]
353
- @refresh_token = data[:refresh_token]
354
-
355
- expires_in_seconds = data[:expires_in].to_i - 5 * 60
356
- expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
357
- @access_token_expires_at = DateTime.now + expires_in_days
358
- end
359
-
360
- #
361
- # Resets access token
362
- #
363
- private def reset_access_token
364
- auth_config = Configuration.new(@config.app_sid, @config.app_key)
365
- auth_config.api_base_url = @config.api_base_url
366
- auth_config.debugging = @config.debugging
367
- auth_config.logger = @config.logger
368
- auth_config.temp_folder_path = @config.temp_folder_path
369
- auth_config.client_side_validation = @config.client_side_validation
370
- auth_config.api_version = ''
371
-
372
- auth_api_client = ApiClient.new(auth_config)
373
-
374
- request_url = "/oauth2/token"
375
- post_data = "grant_type=refresh_token&refresh_token=#{@refresh_token}"
376
-
377
- data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
378
-
379
- @access_token = data[:access_token]
380
- @refresh_token = data[:refresh_token]
381
-
382
- expires_in_seconds = data[:expires_in].to_i - 5 * 60
383
- expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
384
- @access_token_expires_at = DateTime.now + expires_in_days
385
- end
386
-
387
- # requires all files inside a directory from current dir
388
- # @param _dir can be relative path like '/lib' or "../lib"
389
- private def require_all(_dir)
390
- Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), _dir)) + "/*.rb"].each do |file|
391
- require file
392
- end
393
- end
394
- end
395
- end