aspose_pdf_cloud 18.7.0 → 18.9.0

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 (124) hide show
  1. checksums.yaml +4 -4
  2. data/aspose_pdf_cloud.gemspec +53 -49
  3. data/lib/aspose_pdf_cloud.rb +150 -145
  4. data/lib/aspose_pdf_cloud/api/pdf_api.rb +12907 -11705
  5. data/lib/aspose_pdf_cloud/api_client.rb +2 -2
  6. data/lib/aspose_pdf_cloud/api_error.rb +47 -47
  7. data/lib/aspose_pdf_cloud/configuration.rb +175 -185
  8. data/lib/aspose_pdf_cloud/models/annotation.rb +332 -260
  9. data/lib/aspose_pdf_cloud/models/annotation_flags.rb +52 -0
  10. data/lib/aspose_pdf_cloud/models/annotation_info.rb +342 -0
  11. data/lib/aspose_pdf_cloud/models/annotation_state.rb +49 -0
  12. data/lib/aspose_pdf_cloud/models/annotation_type.rb +69 -0
  13. data/lib/aspose_pdf_cloud/models/{annotations.rb → annotations_info.rb} +211 -211
  14. data/lib/aspose_pdf_cloud/models/{annotations_response.rb → annotations_info_response.rb} +222 -222
  15. data/lib/aspose_pdf_cloud/models/antialiasing_processing_type.rb +43 -43
  16. data/lib/aspose_pdf_cloud/models/append_document.rb +233 -228
  17. data/lib/aspose_pdf_cloud/models/{saa_spose_response.rb → aspose_response.rb} +213 -213
  18. data/lib/aspose_pdf_cloud/models/attachment.rb +270 -270
  19. data/lib/aspose_pdf_cloud/models/attachment_response.rb +222 -222
  20. data/lib/aspose_pdf_cloud/models/attachments.rb +211 -211
  21. data/lib/aspose_pdf_cloud/models/attachments_response.rb +222 -222
  22. data/lib/aspose_pdf_cloud/models/color.rb +244 -244
  23. data/lib/aspose_pdf_cloud/models/color_depth.rb +45 -45
  24. data/lib/aspose_pdf_cloud/models/compression_type.rb +46 -46
  25. data/lib/aspose_pdf_cloud/models/doc_format.rb +43 -43
  26. data/lib/aspose_pdf_cloud/models/doc_recognition_mode.rb +43 -43
  27. data/lib/aspose_pdf_cloud/models/document.rb +220 -220
  28. data/lib/aspose_pdf_cloud/models/{text_item_response.rb → document_page_response.rb} +222 -222
  29. data/lib/aspose_pdf_cloud/models/document_pages_response.rb +222 -222
  30. data/lib/aspose_pdf_cloud/models/document_privilege.rb +298 -298
  31. data/lib/aspose_pdf_cloud/models/document_properties.rb +211 -211
  32. data/lib/aspose_pdf_cloud/models/document_properties_response.rb +222 -222
  33. data/lib/aspose_pdf_cloud/models/document_property.rb +227 -227
  34. data/lib/aspose_pdf_cloud/models/document_property_response.rb +222 -222
  35. data/lib/aspose_pdf_cloud/models/document_response.rb +233 -233
  36. data/lib/aspose_pdf_cloud/models/epub_recognition_mode.rb +44 -44
  37. data/lib/aspose_pdf_cloud/models/field.rb +254 -254
  38. data/lib/aspose_pdf_cloud/models/field_response.rb +222 -222
  39. data/lib/aspose_pdf_cloud/models/field_type.rb +45 -44
  40. data/lib/aspose_pdf_cloud/models/fields.rb +211 -211
  41. data/lib/aspose_pdf_cloud/models/fields_response.rb +222 -222
  42. data/lib/aspose_pdf_cloud/models/font_encoding_rules.rb +43 -43
  43. data/lib/aspose_pdf_cloud/models/font_saving_modes.rb +45 -45
  44. data/lib/aspose_pdf_cloud/models/font_styles.rb +45 -43
  45. data/lib/aspose_pdf_cloud/models/free_text_annotation.rb +382 -0
  46. data/lib/aspose_pdf_cloud/models/{annotation_response.rb → free_text_annotation_response.rb} +222 -222
  47. data/lib/aspose_pdf_cloud/models/{text_items.rb → free_text_annotations.rb} +211 -211
  48. data/lib/aspose_pdf_cloud/models/{text_items_response.rb → free_text_annotations_response.rb} +222 -222
  49. data/lib/aspose_pdf_cloud/models/free_text_intent.rb +44 -0
  50. data/lib/aspose_pdf_cloud/models/horizontal_alignment.rb +45 -44
  51. data/lib/aspose_pdf_cloud/models/html_document_type.rb +43 -43
  52. data/lib/aspose_pdf_cloud/models/html_markup_generation_modes.rb +43 -43
  53. data/lib/aspose_pdf_cloud/models/image.rb +250 -220
  54. data/lib/aspose_pdf_cloud/models/image_response.rb +222 -222
  55. data/lib/aspose_pdf_cloud/models/image_src_type.rb +43 -43
  56. data/lib/aspose_pdf_cloud/models/image_template.rb +281 -281
  57. data/lib/aspose_pdf_cloud/models/image_templates_request.rb +230 -230
  58. data/lib/aspose_pdf_cloud/models/images.rb +211 -211
  59. data/lib/aspose_pdf_cloud/models/images_response.rb +222 -222
  60. data/lib/aspose_pdf_cloud/models/justification.rb +44 -0
  61. data/lib/aspose_pdf_cloud/models/letters_positioning_methods.rb +43 -43
  62. data/lib/aspose_pdf_cloud/models/line_spacing.rb +43 -43
  63. data/lib/aspose_pdf_cloud/models/link.rb +228 -228
  64. data/lib/aspose_pdf_cloud/models/link_action_type.rb +47 -46
  65. data/lib/aspose_pdf_cloud/models/link_annotation.rb +254 -236
  66. data/lib/aspose_pdf_cloud/models/link_annotation_response.rb +222 -222
  67. data/lib/aspose_pdf_cloud/models/link_annotations.rb +211 -211
  68. data/lib/aspose_pdf_cloud/models/link_annotations_response.rb +222 -222
  69. data/lib/aspose_pdf_cloud/models/link_element.rb +200 -200
  70. data/lib/aspose_pdf_cloud/models/link_highlighting_mode.rb +46 -45
  71. data/lib/aspose_pdf_cloud/models/margin_info.rb +244 -244
  72. data/lib/aspose_pdf_cloud/models/markup_annotation.rb +342 -0
  73. data/lib/aspose_pdf_cloud/models/merge_documents.rb +205 -200
  74. data/lib/aspose_pdf_cloud/models/optimize_options.rb +293 -293
  75. data/lib/aspose_pdf_cloud/models/page.rb +228 -228
  76. data/lib/aspose_pdf_cloud/models/page_word_count.rb +218 -218
  77. data/lib/aspose_pdf_cloud/models/pages.rb +211 -211
  78. data/lib/aspose_pdf_cloud/models/paragraph.rb +303 -303
  79. data/lib/aspose_pdf_cloud/models/parts_embedding_modes.rb +44 -44
  80. data/lib/aspose_pdf_cloud/models/pdf_a_type.rb +43 -43
  81. data/lib/aspose_pdf_cloud/models/raster_images_saving_modes.rb +44 -44
  82. data/lib/aspose_pdf_cloud/models/{document_text_replace_response.rb → rectangle_pdf.rb} +244 -231
  83. data/lib/aspose_pdf_cloud/models/rotation.rb +45 -44
  84. data/lib/aspose_pdf_cloud/models/segment.rb +211 -206
  85. data/lib/aspose_pdf_cloud/models/shape_type.rb +44 -44
  86. data/lib/aspose_pdf_cloud/models/signature.rb +338 -333
  87. data/lib/aspose_pdf_cloud/models/signature_type.rb +44 -42
  88. data/lib/aspose_pdf_cloud/models/signature_verify_response.rb +223 -223
  89. data/lib/aspose_pdf_cloud/models/split_result.rb +200 -200
  90. data/lib/aspose_pdf_cloud/models/split_result_document.rb +238 -238
  91. data/lib/aspose_pdf_cloud/models/split_result_response.rb +223 -223
  92. data/lib/aspose_pdf_cloud/models/stamp.rb +413 -413
  93. data/lib/aspose_pdf_cloud/models/stamp_type.rb +45 -44
  94. data/lib/aspose_pdf_cloud/models/{tiff_export_options.rb → text_annotation.rb} +382 -348
  95. data/lib/aspose_pdf_cloud/models/text_annotation_response.rb +222 -0
  96. data/lib/aspose_pdf_cloud/models/{text_item.rb → text_annotations.rb} +211 -218
  97. data/lib/aspose_pdf_cloud/models/text_annotations_response.rb +222 -0
  98. data/lib/aspose_pdf_cloud/models/text_horizontal_alignment.rb +47 -47
  99. data/lib/aspose_pdf_cloud/models/text_icon.rb +52 -0
  100. data/lib/aspose_pdf_cloud/models/text_line.rb +215 -210
  101. data/lib/aspose_pdf_cloud/models/text_rect.rb +220 -220
  102. data/lib/aspose_pdf_cloud/models/text_rects.rb +199 -199
  103. data/lib/aspose_pdf_cloud/models/text_rects_response.rb +222 -222
  104. data/lib/aspose_pdf_cloud/models/text_replace.rb +253 -253
  105. data/lib/aspose_pdf_cloud/models/text_replace_list_request.rb +232 -232
  106. data/lib/aspose_pdf_cloud/models/text_replace_response.rb +222 -222
  107. data/lib/aspose_pdf_cloud/models/text_state.rb +248 -248
  108. data/lib/aspose_pdf_cloud/models/{text_format.rb → text_style.rb} +233 -227
  109. data/lib/aspose_pdf_cloud/models/vertical_alignment.rb +45 -45
  110. data/lib/aspose_pdf_cloud/models/word_count.rb +199 -199
  111. data/lib/aspose_pdf_cloud/models/word_count_response.rb +223 -223
  112. data/lib/aspose_pdf_cloud/models/wrap_mode.rb +44 -44
  113. data/lib/aspose_pdf_cloud/version.rb +24 -24
  114. data/test/pdf_tests.rb +1496 -1325
  115. data/test_data/TexExample.tex +304 -304
  116. metadata +24 -21
  117. data/.gitignore +0 -46
  118. data/.swagger-codegen-ignore +0 -58
  119. data/lib/aspose_pdf_cloud/models/http_status_code.rb +0 -87
  120. data/lib/aspose_pdf_cloud/models/images_list_request.rb +0 -205
  121. data/lib/aspose_pdf_cloud/models/page_text_replace_response.rb +0 -231
  122. data/lib/aspose_pdf_cloud/models/rectangle.rb +0 -244
  123. data/lib/aspose_pdf_cloud/models/text_format_response.rb +0 -222
  124. data/lib/aspose_pdf_cloud/models/text_replace_request.rb +0 -262
@@ -419,7 +419,7 @@ module AsposePdfCloud
419
419
 
420
420
  # resource path
421
421
  local_var_path = "/oauth2/token"
422
- url = build_request_url(local_var_path).gsub(@config.base_path, '')
422
+ url = build_request_url(local_var_path).gsub('/v2.0', '')
423
423
 
424
424
  # header parameters
425
425
  header_params = {}
@@ -471,7 +471,7 @@ module AsposePdfCloud
471
471
  def refresh_token
472
472
  # resource path
473
473
  local_var_path = "/oauth2/token"
474
- url = build_request_url(local_var_path).gsub(@config.base_path, '')
474
+ url = build_request_url(local_var_path).gsub('/v2.0', '')
475
475
 
476
476
  # header parameters
477
477
  header_params = {}
@@ -1,47 +1,47 @@
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
+ =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,175 @@
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
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 the access token (Bearer) used with OAuth2.
40
+ attr_accessor :access_token
41
+
42
+ # Defines the refresh token (Bearer) used with OAuth2.
43
+ attr_accessor :refresh_token
44
+
45
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
46
+ # details will be logged with `logger.debug` (see the `logger` attribute).
47
+ # Default to false.
48
+ #
49
+ # @return [true, false]
50
+ attr_accessor :debugging
51
+
52
+ # Defines the logger used for debugging.
53
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
54
+ #
55
+ # @return [#debug]
56
+ attr_accessor :logger
57
+
58
+ # Defines the temporary folder to store downloaded files
59
+ # (for API endpoints that have file response).
60
+ # Default to use `Tempfile`.
61
+ #
62
+ # @return [String]
63
+ attr_accessor :temp_folder_path
64
+
65
+ # The time limit for HTTP request in seconds.
66
+ # Default to 0 (never times out).
67
+ attr_accessor :timeout
68
+
69
+ # Set this to false to skip client side validation in the operation.
70
+ # Default to true.
71
+ # @return [true, false]
72
+ attr_accessor :client_side_validation
73
+
74
+ ### TLS/SSL setting
75
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
76
+ # Default to true.
77
+ #
78
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
79
+ #
80
+ # @return [true, false]
81
+ attr_accessor :verify_ssl
82
+
83
+ ### TLS/SSL setting
84
+ # Set this to false to skip verifying SSL host name
85
+ # Default to true.
86
+ #
87
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
88
+ #
89
+ # @return [true, false]
90
+ attr_accessor :verify_ssl_host
91
+
92
+ ### TLS/SSL setting
93
+ # Set this to customize the certificate file to verify the peer.
94
+ #
95
+ # @return [String] the path to the certificate file
96
+ #
97
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
98
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
99
+ attr_accessor :ssl_ca_cert
100
+
101
+ ### TLS/SSL setting
102
+ # Client certificate file (for client certificate)
103
+ attr_accessor :cert_file
104
+
105
+ ### TLS/SSL setting
106
+ # Client private key file (for client certificate)
107
+ attr_accessor :key_file
108
+
109
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
110
+ # Default to nil.
111
+ #
112
+ # @see The params_encoding option of Ethon. Related source code:
113
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
114
+ attr_accessor :params_encoding
115
+
116
+ attr_accessor :inject_format
117
+
118
+ attr_accessor :force_ending_format
119
+
120
+ def initialize
121
+ @scheme = 'https'
122
+ @host = 'api.aspose.cloud'
123
+ @timeout = 5 * 60
124
+ @client_side_validation = true
125
+ @verify_ssl = true
126
+ @verify_ssl_host = true
127
+ @params_encoding = nil
128
+ @cert_file = nil
129
+ @key_file = nil
130
+ @debugging = false
131
+ @inject_format = false
132
+ @force_ending_format = false
133
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
134
+
135
+ yield(self) if block_given?
136
+ end
137
+
138
+ # The default Configuration object.
139
+ def self.default
140
+ @@default ||= Configuration.new
141
+ end
142
+
143
+ def configure
144
+ yield(self) if block_given?
145
+ end
146
+
147
+ def scheme=(scheme)
148
+ # remove :// from scheme
149
+ @scheme = scheme.sub(/:\/\//, '')
150
+ end
151
+
152
+ def host=(host)
153
+ # remove http(s):// and anything after a slash
154
+ @host = host.sub(/https?:\/\//, '').split('/').first
155
+ end
156
+
157
+ def base_url
158
+ url = "#{scheme}://#{[host, '/v2.0'].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
159
+ URI.encode(url)
160
+ end
161
+
162
+ # Returns Auth Settings hash for api client.
163
+ def auth_settings
164
+ {
165
+ 'oauth' =>
166
+ {
167
+ type: 'oauth2',
168
+ in: 'header',
169
+ key: 'Authorization',
170
+ value: "Bearer #{access_token}"
171
+ },
172
+ }
173
+ end
174
+ end
175
+ end