slidize_cloud 24.9.0 → 24.10.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/README.md +118 -0
  4. data/Rakefile +10 -0
  5. data/TestData/macros.pptm +0 -0
  6. data/TestData/master.pptx +0 -0
  7. data/TestData/protected.pptx +0 -0
  8. data/TestData/test.pptx +0 -0
  9. data/TestData/watermark.png +0 -0
  10. data/git_push.sh +57 -0
  11. data/lib/slidize_cloud/api/slidize_api.rb +829 -0
  12. data/lib/slidize_cloud/api_client.rb +451 -0
  13. data/lib/slidize_cloud/api_error.rb +75 -0
  14. data/lib/slidize_cloud/configuration.rb +389 -0
  15. data/lib/slidize_cloud/models/convert_request.rb +238 -0
  16. data/lib/slidize_cloud/models/convert_to_video_request.rb +245 -0
  17. data/lib/slidize_cloud/models/export_format.rb +83 -0
  18. data/lib/slidize_cloud/models/image_watermark_options.rb +247 -0
  19. data/lib/slidize_cloud/models/image_watermark_request.rb +256 -0
  20. data/lib/slidize_cloud/models/merge_options.rb +246 -0
  21. data/lib/slidize_cloud/models/merge_request.rb +247 -0
  22. data/lib/slidize_cloud/models/protect_request.rb +245 -0
  23. data/lib/slidize_cloud/models/protection_options.rb +256 -0
  24. data/lib/slidize_cloud/models/replace_text_options.rb +256 -0
  25. data/lib/slidize_cloud/models/replace_text_request.rb +247 -0
  26. data/lib/slidize_cloud/models/split_options.rb +237 -0
  27. data/lib/slidize_cloud/models/split_request.rb +245 -0
  28. data/lib/slidize_cloud/models/text_watermark_options.rb +277 -0
  29. data/lib/slidize_cloud/models/text_watermark_request.rb +247 -0
  30. data/lib/slidize_cloud/models/unprotect_request.rb +236 -0
  31. data/lib/slidize_cloud/models/video_options.rb +287 -0
  32. data/lib/slidize_cloud/models/video_resolution_type.rb +59 -0
  33. data/lib/slidize_cloud/models/video_transition_type.rb +63 -0
  34. data/lib/slidize_cloud/version.rb +32 -0
  35. data/lib/slidize_cloud.rb +76 -0
  36. data/slidize_cloud.gemspec +56 -0
  37. data/spec/api_client_spec.rb +240 -0
  38. data/spec/configuration_spec.rb +99 -0
  39. data/spec/spec_helper.rb +128 -0
  40. metadata +44 -3
@@ -0,0 +1,389 @@
1
+ =begin
2
+ /**
3
+ * --------------------------------------------------------------------------------------------------------------------
4
+ * <copyright company="Smallize">
5
+ * Copyright (c) 2024 Slidize for Cloud
6
+ * </copyright>
7
+ * <summary>
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ * </summary>
26
+ * --------------------------------------------------------------------------------------------------------------------
27
+ */
28
+ =end
29
+
30
+ module SlidizeCloud
31
+ class Configuration
32
+ # Defines url scheme
33
+ attr_accessor :scheme
34
+
35
+ # Defines url host
36
+ attr_accessor :host
37
+
38
+ # Defines url base path
39
+ attr_accessor :base_path
40
+
41
+ # Define server configuration index
42
+ attr_accessor :server_index
43
+
44
+ # Define server operation configuration index
45
+ attr_accessor :server_operation_index
46
+
47
+ # Default server variables
48
+ attr_accessor :server_variables
49
+
50
+ # Default server operation variables
51
+ attr_accessor :server_operation_variables
52
+
53
+ # Defines API keys used with API Key authentications.
54
+ #
55
+ # @return [Hash] key: parameter name, value: parameter value (API key)
56
+ #
57
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
58
+ # config.api_key['api_key'] = 'xxx'
59
+ attr_accessor :api_key
60
+
61
+ # Defines API key prefixes used with API Key authentications.
62
+ #
63
+ # @return [Hash] key: parameter name, value: API key prefix
64
+ #
65
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
66
+ # config.api_key_prefix['api_key'] = 'Token'
67
+ attr_accessor :api_key_prefix
68
+
69
+ # Defines the username used with HTTP basic authentication.
70
+ #
71
+ # @return [String]
72
+ attr_accessor :username
73
+
74
+ # Defines the password used with HTTP basic authentication.
75
+ #
76
+ # @return [String]
77
+ attr_accessor :password
78
+
79
+ # Defines the access token (Bearer) used with OAuth2.
80
+ attr_accessor :access_token
81
+
82
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
83
+ # Overrides the access_token if set
84
+ # @return [Proc]
85
+ attr_accessor :access_token_getter
86
+
87
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
88
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
89
+ # Default to false.
90
+ attr_accessor :return_binary_data
91
+
92
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
93
+ # details will be logged with `logger.debug` (see the `logger` attribute).
94
+ # Default to false.
95
+ #
96
+ # @return [true, false]
97
+ attr_accessor :debugging
98
+
99
+ # Defines the logger used for debugging.
100
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
101
+ #
102
+ # @return [#debug]
103
+ attr_accessor :logger
104
+
105
+ # Defines the temporary folder to store downloaded files
106
+ # (for API endpoints that have file response).
107
+ # Default to use `Tempfile`.
108
+ #
109
+ # @return [String]
110
+ attr_accessor :temp_folder_path
111
+
112
+ # The time limit for HTTP request in seconds.
113
+ # Default to 0 (never times out).
114
+ attr_accessor :timeout
115
+
116
+ # Set this to false to skip client side validation in the operation.
117
+ # Default to true.
118
+ # @return [true, false]
119
+ attr_accessor :client_side_validation
120
+
121
+ ### TLS/SSL setting
122
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
123
+ # Default to true.
124
+ #
125
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
126
+ #
127
+ # @return [true, false]
128
+ attr_accessor :ssl_verify
129
+
130
+ ### TLS/SSL setting
131
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
132
+ #
133
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
134
+ #
135
+ attr_accessor :ssl_verify_mode
136
+
137
+ ### TLS/SSL setting
138
+ # Set this to customize the certificate file to verify the peer.
139
+ #
140
+ # @return [String] the path to the certificate file
141
+ attr_accessor :ssl_ca_file
142
+
143
+ ### TLS/SSL setting
144
+ # Client certificate file (for client certificate)
145
+ attr_accessor :ssl_client_cert
146
+
147
+ ### TLS/SSL setting
148
+ # Client private key file (for client certificate)
149
+ attr_accessor :ssl_client_key
150
+
151
+ ### Proxy setting
152
+ # HTTP Proxy settings
153
+ attr_accessor :proxy
154
+
155
+ # Set this to customize parameters encoder of array parameter.
156
+ # Default to nil. Faraday uses NestedParamsEncoder when nil.
157
+ #
158
+ # @see The params_encoder option of Faraday. Related source code:
159
+ # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
160
+ attr_accessor :params_encoder
161
+
162
+
163
+ attr_accessor :inject_format
164
+
165
+ attr_accessor :force_ending_format
166
+
167
+ def initialize
168
+ @scheme = 'https'
169
+ @host = 'api.slidize.cloud'
170
+ @base_path = '/v1.0/slides'
171
+ @server_index = 0
172
+ @server_operation_index = {}
173
+ @server_variables = {}
174
+ @server_operation_variables = {}
175
+ @api_key = {}
176
+ @api_key_prefix = {}
177
+ @client_side_validation = true
178
+ @ssl_verify = true
179
+ @ssl_verify_mode = nil
180
+ @ssl_ca_file = nil
181
+ @ssl_client_cert = nil
182
+ @ssl_client_key = nil
183
+ @middlewares = Hash.new { |h, k| h[k] = [] }
184
+ @configure_connection_blocks = []
185
+ @timeout = 60
186
+ # return data as binary instead of file
187
+ @return_binary_data = false
188
+ @params_encoder = nil
189
+ @debugging = false
190
+ @inject_format = false
191
+ @force_ending_format = false
192
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
193
+
194
+ yield(self) if block_given?
195
+ end
196
+
197
+ # The default Configuration object.
198
+ def self.default
199
+ @@default ||= Configuration.new
200
+ end
201
+
202
+ def configure
203
+ yield(self) if block_given?
204
+ end
205
+
206
+ def scheme=(scheme)
207
+ # remove :// from scheme
208
+ @scheme = scheme.sub(/:\/\//, '')
209
+ end
210
+
211
+ def host=(host)
212
+ # remove http(s):// and anything after a slash
213
+ @host = host.sub(/https?:\/\//, '').split('/').first
214
+ end
215
+
216
+ def base_path=(base_path)
217
+ # Add leading and trailing slashes to base_path
218
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
219
+ @base_path = '' if @base_path == '/'
220
+ end
221
+
222
+ # Returns base URL for specified operation based on server settings
223
+ def base_url(operation = nil)
224
+ index = server_operation_index[operation]
225
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
226
+
227
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
228
+ end
229
+
230
+ # Gets API key (with prefix if set).
231
+ # @param [String] param_name the parameter name of API key auth
232
+ def api_key_with_prefix(param_name, param_alias = nil)
233
+ key = @api_key[param_name]
234
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
235
+ if @api_key_prefix[param_name]
236
+ "#{@api_key_prefix[param_name]} #{key}"
237
+ else
238
+ key
239
+ end
240
+ end
241
+
242
+ # Gets access_token using access_token_getter or uses the static access_token
243
+ def access_token_with_refresh
244
+ return access_token if access_token_getter.nil?
245
+ access_token_getter.call
246
+ end
247
+
248
+ # Gets Basic Auth token string
249
+ def basic_auth_token
250
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
251
+ end
252
+
253
+ # Returns Auth Settings hash for api client.
254
+ def auth_settings
255
+ {
256
+ }
257
+ end
258
+
259
+ # Returns an array of Server setting
260
+ def server_settings
261
+ [
262
+ {
263
+ url: "https://api.slidize.cloud/v1.0/slides",
264
+ description: "API production server",
265
+ }
266
+ ]
267
+ end
268
+
269
+ def operation_server_settings
270
+ {
271
+ }
272
+ end
273
+
274
+ # Returns URL based on server settings
275
+ #
276
+ # @param index array index of the server settings
277
+ # @param variables hash of variable and the corresponding value
278
+ def server_url(index, variables = {}, servers = nil)
279
+ servers = server_settings if servers == nil
280
+
281
+ # check array index out of bound
282
+ if (index < 0 || index >= servers.size)
283
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
284
+ end
285
+
286
+ server = servers[index]
287
+ url = server[:url]
288
+
289
+ return url unless server.key? :variables
290
+
291
+ # go through variable and assign a value
292
+ server[:variables].each do |name, variable|
293
+ if variables.key?(name)
294
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
295
+ url.gsub! "{" + name.to_s + "}", variables[name]
296
+ else
297
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
298
+ end
299
+ else
300
+ # use default value
301
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
302
+ end
303
+ end
304
+
305
+ url
306
+ end
307
+
308
+ # Configure Faraday connection directly.
309
+ #
310
+ # ```
311
+ # c.configure_faraday_connection do |conn|
312
+ # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
313
+ # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
314
+ # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
315
+ # end
316
+ # end
317
+ #
318
+ # c.configure_faraday_connection do |conn|
319
+ # conn.adapter :typhoeus
320
+ # end
321
+ # ```
322
+ #
323
+ # @param block [Proc] `#call`able object that takes one arg, the connection
324
+ def configure_faraday_connection(&block)
325
+ @configure_connection_blocks << block
326
+ end
327
+
328
+ def configure_connection(conn)
329
+ @configure_connection_blocks.each do |block|
330
+ block.call(conn)
331
+ end
332
+ end
333
+
334
+ # Adds middleware to the stack
335
+ def use(*middleware)
336
+ set_faraday_middleware(:use, *middleware)
337
+ end
338
+
339
+ # Adds request middleware to the stack
340
+ def request(*middleware)
341
+ set_faraday_middleware(:request, *middleware)
342
+ end
343
+
344
+ # Adds response middleware to the stack
345
+ def response(*middleware)
346
+ set_faraday_middleware(:response, *middleware)
347
+ end
348
+
349
+ # Adds Faraday middleware setting information to the stack
350
+ #
351
+ # @example Use the `set_faraday_middleware` method to set middleware information
352
+ # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
353
+ # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
354
+ # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
355
+ # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
356
+ # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
357
+ # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
358
+ #
359
+ # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
360
+ def set_faraday_middleware(operation, key, *args, &block)
361
+ unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
362
+ fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
363
+ " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
364
+ end
365
+
366
+ @middlewares[operation] << [key, args, block]
367
+ end
368
+ ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
369
+
370
+ # Set up middleware on the connection
371
+ def configure_middleware(connection)
372
+ return if @middlewares.empty?
373
+
374
+ [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
375
+ next unless @middlewares.key?(operation)
376
+
377
+ @middlewares[operation].each do |key, args, block|
378
+ connection.builder.send(operation, key, *args, &block)
379
+ end
380
+ end
381
+
382
+ if @middlewares.key?(:delete)
383
+ @middlewares[:delete].each do |key, _args, _block|
384
+ connection.builder.delete(key)
385
+ end
386
+ end
387
+ end
388
+ end
389
+ end
@@ -0,0 +1,238 @@
1
+ =begin
2
+ /**
3
+ * --------------------------------------------------------------------------------------------------------------------
4
+ * <copyright company="Smallize">
5
+ * Copyright (c) 2024 Slidize for Cloud
6
+ * </copyright>
7
+ * <summary>
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ * </summary>
26
+ * --------------------------------------------------------------------------------------------------------------------
27
+ */
28
+ =end
29
+
30
+ require 'date'
31
+ require 'time'
32
+
33
+ module SlidizeCloud
34
+ class ConvertRequest
35
+ attr_accessor :documents
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'documents' => :'documents'
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ :'documents' => :'Array<File>'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SlidizeCloud::ConvertRequest` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SlidizeCloud::ConvertRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'documents')
78
+ if (value = attributes[:'documents']).is_a?(Array)
79
+ self.documents = value
80
+ end
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ documents == o.documents
103
+ end
104
+
105
+ # @see the `==` method
106
+ # @param [Object] Object to be compared
107
+ def eql?(o)
108
+ self == o
109
+ end
110
+
111
+ # Calculates hash code according to all attributes.
112
+ # @return [Integer] Hash code
113
+ def hash
114
+ [documents].hash
115
+ end
116
+
117
+ # Builds the object from hash
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ # @return [Object] Returns the model itself
120
+ def self.build_from_hash(attributes)
121
+ new.build_from_hash(attributes)
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ attributes = attributes.transform_keys(&:to_sym)
130
+ self.class.openapi_types.each_pair do |key, type|
131
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
132
+ self.send("#{key}=", nil)
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
137
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
138
+ end
139
+ elsif !attributes[self.class.attribute_map[key]].nil?
140
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
141
+ end
142
+ end
143
+
144
+ self
145
+ end
146
+
147
+ # Deserializes the data based on type
148
+ # @param string type Data type
149
+ # @param string value Value to be deserialized
150
+ # @return [Object] Deserialized data
151
+ def _deserialize(type, value)
152
+ case type.to_sym
153
+ when :Time
154
+ Time.parse(value)
155
+ when :Date
156
+ Date.parse(value)
157
+ when :String
158
+ value.to_s
159
+ when :Integer
160
+ value.to_i
161
+ when :Float
162
+ value.to_f
163
+ when :Boolean
164
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
165
+ true
166
+ else
167
+ false
168
+ end
169
+ when :Object
170
+ # generic object (usually a Hash), return directly
171
+ value
172
+ when /\AArray<(?<inner_type>.+)>\z/
173
+ inner_type = Regexp.last_match[:inner_type]
174
+ value.map { |v| _deserialize(inner_type, v) }
175
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
176
+ k_type = Regexp.last_match[:k_type]
177
+ v_type = Regexp.last_match[:v_type]
178
+ {}.tap do |hash|
179
+ value.each do |k, v|
180
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
181
+ end
182
+ end
183
+ else # model
184
+ # models (e.g. Pet) or oneOf
185
+ klass = SlidizeCloud.const_get(type)
186
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ if value.nil?
209
+ is_nullable = self.class.openapi_nullable.include?(attr)
210
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
211
+ end
212
+
213
+ hash[param] = _to_hash(value)
214
+ end
215
+ hash
216
+ end
217
+
218
+ # Outputs non-array value in the form of hash
219
+ # For object, use to_hash. Otherwise, just return the value
220
+ # @param [Object] value Any valid value
221
+ # @return [Hash] Returns the value in the form of hash
222
+ def _to_hash(value)
223
+ if value.is_a?(Array)
224
+ value.compact.map { |v| _to_hash(v) }
225
+ elsif value.is_a?(Hash)
226
+ {}.tap do |hash|
227
+ value.each { |k, v| hash[k] = _to_hash(v) }
228
+ end
229
+ elsif value.respond_to? :to_hash
230
+ value.to_hash
231
+ else
232
+ value
233
+ end
234
+ end
235
+
236
+ end
237
+
238
+ end