aspose_pdf_cloud 18.6.0 → 18.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +4 -4
  4. data/aspose_pdf_cloud.gemspec +49 -49
  5. data/lib/aspose_pdf_cloud.rb +145 -145
  6. data/lib/aspose_pdf_cloud/api/pdf_api.rb +11705 -10569
  7. data/lib/aspose_pdf_cloud/api_client.rb +60 -6
  8. data/lib/aspose_pdf_cloud/api_error.rb +47 -47
  9. data/lib/aspose_pdf_cloud/configuration.rb +185 -185
  10. data/lib/aspose_pdf_cloud/models/annotation.rb +260 -260
  11. data/lib/aspose_pdf_cloud/models/annotation_response.rb +222 -222
  12. data/lib/aspose_pdf_cloud/models/annotations.rb +211 -211
  13. data/lib/aspose_pdf_cloud/models/annotations_response.rb +222 -222
  14. data/lib/aspose_pdf_cloud/models/antialiasing_processing_type.rb +43 -43
  15. data/lib/aspose_pdf_cloud/models/append_document.rb +228 -228
  16. data/lib/aspose_pdf_cloud/models/attachment.rb +270 -270
  17. data/lib/aspose_pdf_cloud/models/attachment_response.rb +222 -222
  18. data/lib/aspose_pdf_cloud/models/attachments.rb +211 -211
  19. data/lib/aspose_pdf_cloud/models/attachments_response.rb +222 -222
  20. data/lib/aspose_pdf_cloud/models/color.rb +244 -244
  21. data/lib/aspose_pdf_cloud/models/color_depth.rb +45 -45
  22. data/lib/aspose_pdf_cloud/models/compression_type.rb +46 -46
  23. data/lib/aspose_pdf_cloud/models/doc_format.rb +43 -43
  24. data/lib/aspose_pdf_cloud/models/doc_recognition_mode.rb +43 -43
  25. data/lib/aspose_pdf_cloud/models/document.rb +220 -220
  26. data/lib/aspose_pdf_cloud/models/document_pages_response.rb +222 -222
  27. data/lib/aspose_pdf_cloud/models/document_privilege.rb +298 -298
  28. data/lib/aspose_pdf_cloud/models/document_properties.rb +211 -211
  29. data/lib/aspose_pdf_cloud/models/document_properties_response.rb +222 -222
  30. data/lib/aspose_pdf_cloud/models/document_property.rb +227 -227
  31. data/lib/aspose_pdf_cloud/models/document_property_response.rb +222 -222
  32. data/lib/aspose_pdf_cloud/models/document_response.rb +233 -233
  33. data/lib/aspose_pdf_cloud/models/document_text_replace_response.rb +231 -231
  34. data/lib/aspose_pdf_cloud/models/epub_recognition_mode.rb +44 -44
  35. data/lib/aspose_pdf_cloud/models/field.rb +254 -254
  36. data/lib/aspose_pdf_cloud/models/field_response.rb +222 -222
  37. data/lib/aspose_pdf_cloud/models/field_type.rb +1 -1
  38. data/lib/aspose_pdf_cloud/models/fields.rb +211 -211
  39. data/lib/aspose_pdf_cloud/models/fields_response.rb +222 -222
  40. data/lib/aspose_pdf_cloud/models/font_encoding_rules.rb +43 -43
  41. data/lib/aspose_pdf_cloud/models/font_saving_modes.rb +45 -45
  42. data/lib/aspose_pdf_cloud/models/font_styles.rb +1 -1
  43. data/lib/aspose_pdf_cloud/models/horizontal_alignment.rb +1 -1
  44. data/lib/aspose_pdf_cloud/models/html_document_type.rb +43 -43
  45. data/lib/aspose_pdf_cloud/models/html_markup_generation_modes.rb +43 -43
  46. data/lib/aspose_pdf_cloud/models/http_status_code.rb +1 -1
  47. data/lib/aspose_pdf_cloud/models/image.rb +220 -220
  48. data/lib/aspose_pdf_cloud/models/image_response.rb +222 -222
  49. data/lib/aspose_pdf_cloud/models/image_src_type.rb +43 -43
  50. data/lib/aspose_pdf_cloud/models/image_template.rb +281 -281
  51. data/lib/aspose_pdf_cloud/models/image_templates_request.rb +230 -230
  52. data/lib/aspose_pdf_cloud/models/images.rb +211 -211
  53. data/lib/aspose_pdf_cloud/models/images_list_request.rb +205 -205
  54. data/lib/aspose_pdf_cloud/models/images_response.rb +222 -222
  55. data/lib/aspose_pdf_cloud/models/letters_positioning_methods.rb +43 -43
  56. data/lib/aspose_pdf_cloud/models/line_spacing.rb +43 -43
  57. data/lib/aspose_pdf_cloud/models/link.rb +228 -228
  58. data/lib/aspose_pdf_cloud/models/link_action_type.rb +1 -1
  59. data/lib/aspose_pdf_cloud/models/link_annotation.rb +236 -236
  60. data/lib/aspose_pdf_cloud/models/link_annotation_response.rb +222 -222
  61. data/lib/aspose_pdf_cloud/models/link_annotations.rb +211 -211
  62. data/lib/aspose_pdf_cloud/models/link_annotations_response.rb +222 -222
  63. data/lib/aspose_pdf_cloud/models/link_element.rb +200 -200
  64. data/lib/aspose_pdf_cloud/models/link_highlighting_mode.rb +1 -1
  65. data/lib/aspose_pdf_cloud/models/margin_info.rb +244 -244
  66. data/lib/aspose_pdf_cloud/models/merge_documents.rb +200 -200
  67. data/lib/aspose_pdf_cloud/models/optimize_options.rb +293 -293
  68. data/lib/aspose_pdf_cloud/models/page.rb +228 -228
  69. data/lib/aspose_pdf_cloud/models/page_text_replace_response.rb +231 -231
  70. data/lib/aspose_pdf_cloud/models/page_word_count.rb +218 -218
  71. data/lib/aspose_pdf_cloud/models/pages.rb +211 -211
  72. data/lib/aspose_pdf_cloud/models/paragraph.rb +303 -303
  73. data/lib/aspose_pdf_cloud/models/parts_embedding_modes.rb +44 -44
  74. data/lib/aspose_pdf_cloud/models/pdf_a_type.rb +43 -43
  75. data/lib/aspose_pdf_cloud/models/raster_images_saving_modes.rb +44 -44
  76. data/lib/aspose_pdf_cloud/models/rectangle.rb +244 -244
  77. data/lib/aspose_pdf_cloud/models/rotation.rb +1 -1
  78. data/lib/aspose_pdf_cloud/models/saa_spose_response.rb +213 -213
  79. data/lib/aspose_pdf_cloud/models/segment.rb +206 -206
  80. data/lib/aspose_pdf_cloud/models/shape_type.rb +44 -44
  81. data/lib/aspose_pdf_cloud/models/signature.rb +333 -333
  82. data/lib/aspose_pdf_cloud/models/signature_type.rb +1 -1
  83. data/lib/aspose_pdf_cloud/models/signature_verify_response.rb +223 -223
  84. data/lib/aspose_pdf_cloud/models/split_result.rb +200 -200
  85. data/lib/aspose_pdf_cloud/models/split_result_document.rb +238 -238
  86. data/lib/aspose_pdf_cloud/models/split_result_response.rb +223 -223
  87. data/lib/aspose_pdf_cloud/models/stamp.rb +413 -413
  88. data/lib/aspose_pdf_cloud/models/stamp_type.rb +1 -1
  89. data/lib/aspose_pdf_cloud/models/text_format.rb +227 -227
  90. data/lib/aspose_pdf_cloud/models/text_format_response.rb +222 -222
  91. data/lib/aspose_pdf_cloud/models/text_horizontal_alignment.rb +47 -47
  92. data/lib/aspose_pdf_cloud/models/text_item.rb +218 -218
  93. data/lib/aspose_pdf_cloud/models/text_item_response.rb +222 -222
  94. data/lib/aspose_pdf_cloud/models/text_items.rb +211 -211
  95. data/lib/aspose_pdf_cloud/models/text_items_response.rb +222 -222
  96. data/lib/aspose_pdf_cloud/models/text_line.rb +210 -210
  97. data/lib/aspose_pdf_cloud/models/text_rect.rb +220 -220
  98. data/lib/aspose_pdf_cloud/models/text_rects.rb +199 -199
  99. data/lib/aspose_pdf_cloud/models/text_rects_response.rb +222 -222
  100. data/lib/aspose_pdf_cloud/models/text_replace.rb +253 -253
  101. data/lib/aspose_pdf_cloud/models/text_replace_list_request.rb +232 -232
  102. data/lib/aspose_pdf_cloud/models/text_replace_request.rb +262 -262
  103. data/lib/aspose_pdf_cloud/models/text_replace_response.rb +222 -222
  104. data/lib/aspose_pdf_cloud/models/text_state.rb +248 -248
  105. data/lib/aspose_pdf_cloud/models/tiff_export_options.rb +348 -348
  106. data/lib/aspose_pdf_cloud/models/vertical_alignment.rb +45 -45
  107. data/lib/aspose_pdf_cloud/models/word_count.rb +199 -199
  108. data/lib/aspose_pdf_cloud/models/word_count_response.rb +223 -223
  109. data/lib/aspose_pdf_cloud/models/wrap_mode.rb +44 -44
  110. data/lib/aspose_pdf_cloud/version.rb +24 -24
  111. data/test/pdf_tests.rb +3 -3
  112. data/test_data/.gitattributes +1 -0
  113. data/test_data/TexExample.tex +304 -304
  114. metadata +13 -12
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
  --------------------------------------------------------------------------------------------------------------------
3
- Copyright (c) 2018 Aspose.Pdf for Cloud
3
+ Copyright (c) 2018 Aspose.PDF Cloud
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
6
6
  in the Software without restriction, including without limitation the rights
@@ -126,9 +126,7 @@ module AsposePdfCloud
126
126
 
127
127
  # OAuth 2.0
128
128
  req_opts[:params] = opts[:query_params]
129
- if @config.access_token.nil?
130
- request_token
131
- end
129
+
132
130
  add_o_auth_token(req_opts)
133
131
 
134
132
 
@@ -412,8 +410,13 @@ module AsposePdfCloud
412
410
  end
413
411
 
414
412
 
415
- # Request access and refresh tokens
416
- def request_token
413
+ # Request access and refresh tokens if needed
414
+ def request_token_if_needed
415
+ # check token exists
416
+ if @config.access_token
417
+ return
418
+ end
419
+
417
420
  # resource path
418
421
  local_var_path = "/oauth2/token"
419
422
  url = build_request_url(local_var_path).gsub(@config.base_path, '')
@@ -464,6 +467,57 @@ module AsposePdfCloud
464
467
  @config.refresh_token = data[:refresh_token]
465
468
  end
466
469
 
470
+ # refresh OAuth tokens
471
+ def refresh_token
472
+ # resource path
473
+ local_var_path = "/oauth2/token"
474
+ url = build_request_url(local_var_path).gsub(@config.base_path, '')
475
+
476
+ # header parameters
477
+ header_params = {}
478
+ # HTTP header 'Content-Type'
479
+ header_params['Content-Type'] = select_header_content_type(['application/x-www-form-urlencoded'])
480
+
481
+ query_params = {}
482
+ # form parameters
483
+ form_params = {}
484
+ form_params["grant_type"] = 'refresh_token'
485
+ form_params["refresh_token"] = @config.refresh_token
486
+
487
+ body = {}
488
+
489
+
490
+ req_opts = {
491
+ :headers => header_params,
492
+ :params => query_params,
493
+ :body => body
494
+ }
495
+
496
+
497
+ req_body = build_request_body(header_params, form_params, body)
498
+ req_opts.update :body => req_body
499
+
500
+ req_opts[:params] = query_params
501
+
502
+
503
+ conn = Faraday.new url, {:params => query_params, :headers => header_params} do |f|
504
+ f.request :multipart
505
+ f.request :url_encoded
506
+ f.adapter Faraday.default_adapter
507
+ end
508
+
509
+ if req_opts[:body] == {}
510
+ req_opts[:body] = nil
511
+ end
512
+
513
+
514
+ response = conn.post url, form_params, req_opts[:body]
515
+ data = JSON.parse("[#{response.body}]", :symbolize_names => true)[0]
516
+
517
+ @config.access_token = data[:access_token]
518
+ @config.refresh_token = data[:refresh_token]
519
+ end
520
+
467
521
  # Adds OAuth2.0 token
468
522
  def add_o_auth_token(req_opts)
469
523
  req_opts[:headers][:Authorization] = "Bearer " + @config.access_token
@@ -1,47 +1,47 @@
1
- =begin
2
- --------------------------------------------------------------------------------------------------------------------
3
- Copyright (c) 2018 Aspose.Pdf for Cloud
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
- SOFTWARE.
19
- --------------------------------------------------------------------------------------------------------------------
20
- =end
21
-
22
- module AsposePdfCloud
23
- class ApiError < StandardError
24
- attr_reader :code, :response_headers, :response_body
25
-
26
- # Usage examples:
27
- # ApiError.new
28
- # ApiError.new("message")
29
- # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
30
- # ApiError.new(:code => 404, :message => "Not Found")
31
- def initialize(arg = nil)
32
- if arg.is_a? Hash
33
- if arg.key?(:message) || arg.key?('message')
34
- super(arg[:message] || arg['message'])
35
- else
36
- super arg
37
- end
38
-
39
- arg.each do |k, v|
40
- instance_variable_set "@#{k}", v
41
- end
42
- else
43
- super arg
44
- end
45
- end
46
- end
47
- end
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2018 Aspose.PDF Cloud
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+ =end
21
+
22
+ module AsposePdfCloud
23
+ class ApiError < StandardError
24
+ attr_reader :code, :response_headers, :response_body
25
+
26
+ # Usage examples:
27
+ # ApiError.new
28
+ # ApiError.new("message")
29
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
30
+ # ApiError.new(:code => 404, :message => "Not Found")
31
+ def initialize(arg = nil)
32
+ if arg.is_a? Hash
33
+ if arg.key?(:message) || arg.key?('message')
34
+ super(arg[:message] || arg['message'])
35
+ else
36
+ super arg
37
+ end
38
+
39
+ arg.each do |k, v|
40
+ instance_variable_set "@#{k}", v
41
+ end
42
+ else
43
+ super arg
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,185 +1,185 @@
1
- =begin
2
- --------------------------------------------------------------------------------------------------------------------
3
- Copyright (c) 2018 Aspose.Pdf for Cloud
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
- SOFTWARE.
19
- --------------------------------------------------------------------------------------------------------------------
20
- =end
21
-
22
- require 'uri'
23
-
24
- module AsposePdfCloud
25
- class Configuration
26
-
27
- # App Key
28
- attr_accessor :app_key
29
-
30
- # App SID
31
- attr_accessor :app_sid
32
-
33
- # Defines url scheme
34
- attr_accessor :scheme
35
-
36
- # Defines url host
37
- attr_accessor :host
38
-
39
- # Defines url base path
40
- attr_accessor :base_path
41
-
42
- # Defines the access token (Bearer) used with OAuth2.
43
- attr_accessor :access_token
44
-
45
- # Defines the refresh token (Bearer) used with OAuth2.
46
- attr_accessor :refresh_token
47
-
48
- # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
49
- # details will be logged with `logger.debug` (see the `logger` attribute).
50
- # Default to false.
51
- #
52
- # @return [true, false]
53
- attr_accessor :debugging
54
-
55
- # Defines the logger used for debugging.
56
- # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
57
- #
58
- # @return [#debug]
59
- attr_accessor :logger
60
-
61
- # Defines the temporary folder to store downloaded files
62
- # (for API endpoints that have file response).
63
- # Default to use `Tempfile`.
64
- #
65
- # @return [String]
66
- attr_accessor :temp_folder_path
67
-
68
- # The time limit for HTTP request in seconds.
69
- # Default to 0 (never times out).
70
- attr_accessor :timeout
71
-
72
- # Set this to false to skip client side validation in the operation.
73
- # Default to true.
74
- # @return [true, false]
75
- attr_accessor :client_side_validation
76
-
77
- ### TLS/SSL setting
78
- # Set this to false to skip verifying SSL certificate when calling API from https server.
79
- # Default to true.
80
- #
81
- # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
82
- #
83
- # @return [true, false]
84
- attr_accessor :verify_ssl
85
-
86
- ### TLS/SSL setting
87
- # Set this to false to skip verifying SSL host name
88
- # Default to true.
89
- #
90
- # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
91
- #
92
- # @return [true, false]
93
- attr_accessor :verify_ssl_host
94
-
95
- ### TLS/SSL setting
96
- # Set this to customize the certificate file to verify the peer.
97
- #
98
- # @return [String] the path to the certificate file
99
- #
100
- # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
101
- # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
102
- attr_accessor :ssl_ca_cert
103
-
104
- ### TLS/SSL setting
105
- # Client certificate file (for client certificate)
106
- attr_accessor :cert_file
107
-
108
- ### TLS/SSL setting
109
- # Client private key file (for client certificate)
110
- attr_accessor :key_file
111
-
112
- # Set this to customize parameters encoding of array parameter with multi collectionFormat.
113
- # Default to nil.
114
- #
115
- # @see The params_encoding option of Ethon. Related source code:
116
- # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
117
- attr_accessor :params_encoding
118
-
119
- attr_accessor :inject_format
120
-
121
- attr_accessor :force_ending_format
122
-
123
- def initialize
124
- @scheme = 'https'
125
- @host = 'api.aspose.cloud'
126
- @base_path = '/v1.1'
127
- @timeout = 5 * 60
128
- @client_side_validation = true
129
- @verify_ssl = true
130
- @verify_ssl_host = true
131
- @params_encoding = nil
132
- @cert_file = nil
133
- @key_file = nil
134
- @debugging = false
135
- @inject_format = false
136
- @force_ending_format = false
137
- @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
138
-
139
- yield(self) if block_given?
140
- end
141
-
142
- # The default Configuration object.
143
- def self.default
144
- @@default ||= Configuration.new
145
- end
146
-
147
- def configure
148
- yield(self) if block_given?
149
- end
150
-
151
- def scheme=(scheme)
152
- # remove :// from scheme
153
- @scheme = scheme.sub(/:\/\//, '')
154
- end
155
-
156
- def host=(host)
157
- # remove http(s):// and anything after a slash
158
- @host = host.sub(/https?:\/\//, '').split('/').first
159
- end
160
-
161
- def base_path=(base_path)
162
- # Add leading and trailing slashes to base_path
163
- @base_path = "/#{base_path}".gsub(/\/+/, '/')
164
- @base_path = "" if @base_path == "/"
165
- end
166
-
167
- def base_url
168
- url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
169
- URI.encode(url)
170
- end
171
-
172
- # Returns Auth Settings hash for api client.
173
- def auth_settings
174
- {
175
- 'oauth' =>
176
- {
177
- type: 'oauth2',
178
- in: 'header',
179
- key: 'Authorization',
180
- value: "Bearer #{access_token}"
181
- },
182
- }
183
- end
184
- end
185
- end
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2018 Aspose.PDF Cloud
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+ =end
21
+
22
+ require 'uri'
23
+
24
+ module AsposePdfCloud
25
+ class Configuration
26
+
27
+ # App Key
28
+ attr_accessor :app_key
29
+
30
+ # App SID
31
+ attr_accessor :app_sid
32
+
33
+ # Defines url scheme
34
+ attr_accessor :scheme
35
+
36
+ # Defines url host
37
+ attr_accessor :host
38
+
39
+ # Defines url base path
40
+ attr_accessor :base_path
41
+
42
+ # Defines the access token (Bearer) used with OAuth2.
43
+ attr_accessor :access_token
44
+
45
+ # Defines the refresh token (Bearer) used with OAuth2.
46
+ attr_accessor :refresh_token
47
+
48
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
49
+ # details will be logged with `logger.debug` (see the `logger` attribute).
50
+ # Default to false.
51
+ #
52
+ # @return [true, false]
53
+ attr_accessor :debugging
54
+
55
+ # Defines the logger used for debugging.
56
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
57
+ #
58
+ # @return [#debug]
59
+ attr_accessor :logger
60
+
61
+ # Defines the temporary folder to store downloaded files
62
+ # (for API endpoints that have file response).
63
+ # Default to use `Tempfile`.
64
+ #
65
+ # @return [String]
66
+ attr_accessor :temp_folder_path
67
+
68
+ # The time limit for HTTP request in seconds.
69
+ # Default to 0 (never times out).
70
+ attr_accessor :timeout
71
+
72
+ # Set this to false to skip client side validation in the operation.
73
+ # Default to true.
74
+ # @return [true, false]
75
+ attr_accessor :client_side_validation
76
+
77
+ ### TLS/SSL setting
78
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
79
+ # Default to true.
80
+ #
81
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
82
+ #
83
+ # @return [true, false]
84
+ attr_accessor :verify_ssl
85
+
86
+ ### TLS/SSL setting
87
+ # Set this to false to skip verifying SSL host name
88
+ # Default to true.
89
+ #
90
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
91
+ #
92
+ # @return [true, false]
93
+ attr_accessor :verify_ssl_host
94
+
95
+ ### TLS/SSL setting
96
+ # Set this to customize the certificate file to verify the peer.
97
+ #
98
+ # @return [String] the path to the certificate file
99
+ #
100
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
101
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
102
+ attr_accessor :ssl_ca_cert
103
+
104
+ ### TLS/SSL setting
105
+ # Client certificate file (for client certificate)
106
+ attr_accessor :cert_file
107
+
108
+ ### TLS/SSL setting
109
+ # Client private key file (for client certificate)
110
+ attr_accessor :key_file
111
+
112
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
113
+ # Default to nil.
114
+ #
115
+ # @see The params_encoding option of Ethon. Related source code:
116
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
117
+ attr_accessor :params_encoding
118
+
119
+ attr_accessor :inject_format
120
+
121
+ attr_accessor :force_ending_format
122
+
123
+ def initialize
124
+ @scheme = 'https'
125
+ @host = 'api.aspose.cloud'
126
+ @base_path = '/v1.1'
127
+ @timeout = 5 * 60
128
+ @client_side_validation = true
129
+ @verify_ssl = true
130
+ @verify_ssl_host = true
131
+ @params_encoding = nil
132
+ @cert_file = nil
133
+ @key_file = nil
134
+ @debugging = false
135
+ @inject_format = false
136
+ @force_ending_format = false
137
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
138
+
139
+ yield(self) if block_given?
140
+ end
141
+
142
+ # The default Configuration object.
143
+ def self.default
144
+ @@default ||= Configuration.new
145
+ end
146
+
147
+ def configure
148
+ yield(self) if block_given?
149
+ end
150
+
151
+ def scheme=(scheme)
152
+ # remove :// from scheme
153
+ @scheme = scheme.sub(/:\/\//, '')
154
+ end
155
+
156
+ def host=(host)
157
+ # remove http(s):// and anything after a slash
158
+ @host = host.sub(/https?:\/\//, '').split('/').first
159
+ end
160
+
161
+ def base_path=(base_path)
162
+ # Add leading and trailing slashes to base_path
163
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
164
+ @base_path = "" if @base_path == "/"
165
+ end
166
+
167
+ def base_url
168
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
169
+ URI.encode(url)
170
+ end
171
+
172
+ # Returns Auth Settings hash for api client.
173
+ def auth_settings
174
+ {
175
+ 'oauth' =>
176
+ {
177
+ type: 'oauth2',
178
+ in: 'header',
179
+ key: 'Authorization',
180
+ value: "Bearer #{access_token}"
181
+ },
182
+ }
183
+ end
184
+ end
185
+ end