shotstack 0.2.2 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/Rakefile +10 -0
  4. data/lib/shotstack/api/create_api.rb +158 -0
  5. data/lib/shotstack/api/edit_api.rb +20 -20
  6. data/lib/shotstack/api/ingest_api.rb +338 -0
  7. data/lib/shotstack/api/serve_api.rb +76 -8
  8. data/lib/shotstack/api_client.rb +28 -24
  9. data/lib/shotstack/api_error.rb +3 -2
  10. data/lib/shotstack/configuration.rb +55 -9
  11. data/lib/shotstack/models/asset.rb +3 -3
  12. data/lib/shotstack/models/asset_render_response.rb +18 -20
  13. data/lib/shotstack/models/asset_response.rb +18 -20
  14. data/lib/shotstack/models/asset_response_attributes.rb +23 -21
  15. data/lib/shotstack/models/asset_response_data.rb +20 -20
  16. data/lib/shotstack/models/audio_asset.rb +57 -21
  17. data/lib/shotstack/models/audio_enhancement.rb +43 -0
  18. data/lib/shotstack/models/clip.rb +27 -25
  19. data/lib/shotstack/models/crop.rb +40 -28
  20. data/lib/shotstack/models/destinations.rb +78 -243
  21. data/lib/shotstack/models/did_generated_asset.rb +273 -0
  22. data/lib/shotstack/models/did_generated_asset_options.rb +54 -0
  23. data/lib/shotstack/models/did_text_to_avatar_options.rb +313 -0
  24. data/lib/shotstack/models/dolby_enhancement.rb +239 -0
  25. data/lib/shotstack/models/dolby_enhancement_options.rb +257 -0
  26. data/lib/shotstack/models/edit.rb +22 -22
  27. data/lib/shotstack/models/eleven_labs_generated_asset.rb +273 -0
  28. data/lib/shotstack/models/eleven_labs_generated_asset_options.rb +54 -0
  29. data/lib/shotstack/models/eleven_labs_text_to_speech_options.rb +303 -0
  30. data/lib/shotstack/models/enhancements.rb +215 -0
  31. data/lib/shotstack/models/flip_transformation.rb +16 -20
  32. data/lib/shotstack/models/font.rb +18 -20
  33. data/lib/shotstack/models/generated_asset.rb +48 -0
  34. data/lib/shotstack/models/generated_asset_error_response.rb +225 -0
  35. data/lib/shotstack/models/generated_asset_error_response_data.rb +257 -0
  36. data/lib/shotstack/models/generated_asset_response.rb +222 -0
  37. data/lib/shotstack/models/generated_asset_response_attributes.rb +376 -0
  38. data/lib/shotstack/models/generated_asset_response_data.rb +256 -0
  39. data/lib/shotstack/models/google_cloud_storage_destination.rb +232 -0
  40. data/lib/shotstack/models/google_cloud_storage_destination_options.rb +243 -0
  41. data/lib/shotstack/models/google_drive_destination.rb +239 -0
  42. data/lib/shotstack/models/google_drive_destination_options.rb +233 -0
  43. data/lib/shotstack/models/hey_gen_generated_asset.rb +273 -0
  44. data/lib/shotstack/models/hey_gen_generated_asset_options.rb +54 -0
  45. data/lib/shotstack/models/hey_gen_text_to_avatar_options.rb +396 -0
  46. data/lib/shotstack/models/html_asset.rb +20 -22
  47. data/lib/shotstack/models/image_asset.rb +18 -20
  48. data/lib/shotstack/models/ingest_error_response.rb +225 -0
  49. data/lib/shotstack/models/ingest_error_response_data.rb +257 -0
  50. data/lib/shotstack/models/luma_asset.rb +18 -20
  51. data/lib/shotstack/models/merge_field.rb +20 -20
  52. data/lib/shotstack/models/mux_destination.rb +18 -22
  53. data/lib/shotstack/models/mux_destination_options.rb +50 -25
  54. data/lib/shotstack/models/offset.rb +28 -24
  55. data/lib/shotstack/models/open_ai_generated_asset.rb +273 -0
  56. data/lib/shotstack/models/open_ai_generated_asset_options.rb +54 -0
  57. data/lib/shotstack/models/open_ai_text_generator_options.rb +313 -0
  58. data/lib/shotstack/models/output.rb +27 -29
  59. data/lib/shotstack/models/outputs.rb +227 -0
  60. data/lib/shotstack/models/outputs_response.rb +218 -0
  61. data/lib/shotstack/models/poster.rb +18 -20
  62. data/lib/shotstack/models/probe_response.rb +22 -20
  63. data/lib/shotstack/models/queued_response.rb +22 -20
  64. data/lib/shotstack/models/queued_response_data.rb +20 -20
  65. data/lib/shotstack/models/queued_source_response.rb +222 -0
  66. data/lib/shotstack/models/queued_source_response_data.rb +240 -0
  67. data/lib/shotstack/models/range.rb +26 -22
  68. data/lib/shotstack/models/render_response.rb +22 -20
  69. data/lib/shotstack/models/render_response_data.rb +22 -20
  70. data/lib/shotstack/models/rendition.rb +429 -0
  71. data/lib/shotstack/models/rendition_response_attributes.rb +336 -0
  72. data/lib/shotstack/models/rotate_transformation.rb +16 -20
  73. data/lib/shotstack/models/s3_destination.rb +18 -22
  74. data/lib/shotstack/models/s3_destination_options.rb +21 -21
  75. data/lib/shotstack/models/shotstack_destination.rb +19 -23
  76. data/lib/shotstack/models/shotstack_generated_asset.rb +273 -0
  77. data/lib/shotstack/models/shotstack_generated_asset_options.rb +60 -0
  78. data/lib/shotstack/models/shotstack_image_to_video_options.rb +298 -0
  79. data/lib/shotstack/models/shotstack_text_generator_options.rb +274 -0
  80. data/lib/shotstack/models/shotstack_text_to_image_options.rb +308 -0
  81. data/lib/shotstack/models/shotstack_text_to_speech_options.rb +339 -0
  82. data/lib/shotstack/models/size.rb +36 -32
  83. data/lib/shotstack/models/skew_transformation.rb +16 -20
  84. data/lib/shotstack/models/soundtrack.rb +18 -20
  85. data/lib/shotstack/models/source.rb +244 -0
  86. data/lib/shotstack/models/source_list_response.rb +225 -0
  87. data/lib/shotstack/models/source_response.rb +222 -0
  88. data/lib/shotstack/models/source_response_attributes.rb +373 -0
  89. data/lib/shotstack/models/source_response_data.rb +256 -0
  90. data/lib/shotstack/models/speed.rb +254 -0
  91. data/lib/shotstack/models/stability_ai_generated_asset.rb +273 -0
  92. data/lib/shotstack/models/stability_ai_generated_asset_options.rb +54 -0
  93. data/lib/shotstack/models/stability_ai_text_to_image_options.rb +390 -0
  94. data/lib/shotstack/models/template.rb +18 -20
  95. data/lib/shotstack/models/template_data_response.rb +23 -21
  96. data/lib/shotstack/models/template_data_response_data.rb +24 -20
  97. data/lib/shotstack/models/template_list_response.rb +24 -22
  98. data/lib/shotstack/models/template_list_response_data.rb +20 -20
  99. data/lib/shotstack/models/template_list_response_item.rb +20 -20
  100. data/lib/shotstack/models/template_render.rb +18 -20
  101. data/lib/shotstack/models/template_response.rb +22 -20
  102. data/lib/shotstack/models/template_response_data.rb +20 -20
  103. data/lib/shotstack/models/thumbnail.rb +20 -20
  104. data/lib/shotstack/models/timeline.rb +19 -21
  105. data/lib/shotstack/models/title_asset.rb +18 -20
  106. data/lib/shotstack/models/track.rb +18 -20
  107. data/lib/shotstack/models/transcription.rb +250 -0
  108. data/lib/shotstack/models/transfer.rb +259 -0
  109. data/lib/shotstack/models/transfer_response.rb +222 -0
  110. data/lib/shotstack/models/transfer_response_attributes.rb +280 -0
  111. data/lib/shotstack/models/transfer_response_data.rb +225 -0
  112. data/lib/shotstack/models/transformation.rb +16 -20
  113. data/lib/shotstack/models/transition.rb +16 -20
  114. data/lib/shotstack/models/upload_response.rb +222 -0
  115. data/lib/shotstack/models/upload_response_attributes.rb +257 -0
  116. data/lib/shotstack/models/upload_response_data.rb +256 -0
  117. data/lib/shotstack/models/video_asset.rb +57 -21
  118. data/lib/shotstack/version.rb +3 -3
  119. data/lib/shotstack.rb +61 -2
  120. data/shotstack.gemspec +8 -8
  121. metadata +69 -16
@@ -0,0 +1,429 @@
1
+ =begin
2
+ #Shotstack
3
+
4
+ # Official Ruby SDK for the Shotstack Cloud Video Editing API
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Shotstack
17
+ # A rendition is a new output file that is generated from the source. The rendition can be encoded to a different format and have transformations applied to it such as resizing, cropping, etc...
18
+ class Rendition
19
+ # The output format to encode the file to. You can only encode a file to the same type, i.e. a video to a video or an image to an image. You can't encode a video as an image. The following formats are available: <ul> <li>`mp4` - mp4 video file (video only)</li> <li>`webm` - webm video file (video only)</li> <li>`mov` - mov video file (video only)</li> <li>`avi` - avi video file (video only)</li> <li>`mkv` - mkv video file (video only)</li> <li>`ogv` - ogv video file (video only)</li> <li>`wmv` - wmv video file (video only)</li> <li>`avif` - avif video file (video only)</li> <li>`gif` - animated gif file (video only)</li> <li>`jpg` - jpg image file (image only)</li> <li>`png` - png image file (image only)</li> <li>`webp` - webp image file (image only)</li> <li>`tif` - tif image file (image only)</li> <li>`mp3` - mp3 audio file (audio only)</li> <li>`wav` - wav audio file (audio only)</li> </ul>
20
+ attr_accessor :format
21
+
22
+ attr_accessor :size
23
+
24
+ # Set how the rendition should be scaled and cropped when using a size with an aspect ratio that is different from the source. Fit applies to both videos and images. <ul> <li>`crop` <b>(default)</b> - scale the rendition to fill the output area while maintaining the aspect ratio. The rendition will be cropped if it exceeds the bounds of the output.</li> <li>`cover` - stretch the rendition to fill the output without maintaining the aspect ratio.</li> <li>`contain` - fit the entire rendition within the output while maintaining the original aspect ratio.</li> </ul>
25
+ attr_accessor :fit
26
+
27
+ # The preset output resolution of the video or image. This is a convenience property that sets the width and height based on industry standard resolutions. The following resolutions are available: <ul> <li>`preview` - 512px x 288px</li> <li>`mobile` - 640px x 360px</li> <li>`sd` - 1024px x 576px</li> <li>`hd` - 1280px x 720px</li> <li>`fhd` - 1920px x 1080px</li> </ul>
28
+ attr_accessor :resolution
29
+
30
+ # Adjust the visual quality of the video or image. The higher the value, the sharper the image quality but the larger file size and slower the encoding process. When specifying quality, the goal is to balance file size vs visual quality. Quality is a value between 1 and 100 where 1 is fully compressed with low image quality and 100 is close to lossless with high image quality and large file size. Sane values are between 50 and 75. Omitting the quality parameter will result in an asset optimised for encoding speed, file size and visual quality.
31
+ attr_accessor :quality
32
+
33
+ # Change the frame rate of a video asset. <ul> <li>`12` - 12fps</li> <li>`15` - 15fps</li> <li>`24` - 24fps</li> <li>`23.976` - 23.976fps</li> <li>`25` (default) - 25fps</li> <li>`29.97` - 29.97fps</li> <li>`30` - 30fps</li> <li>`48` - 48fps</li> <li>`50` - 50fps</li> <li>`59.94` - 59.94fps</li> <li>`60` - 60fps</li> </ul>
34
+ attr_accessor :fps
35
+
36
+ attr_accessor :speed
37
+
38
+ # The keyframe interval is useful to optimize playback, seeking and smoother scrubbing in browsers. The value sets the number of frames between a keyframe. The lower the number, the larger the file. Try a value between 10 and 25 for smooth scrubbing.
39
+ attr_accessor :keyframe_interval
40
+
41
+ attr_accessor :enhance
42
+
43
+ # A custom name for the generated rendition file. The file extension will be automatically added based on the format of the rendition. If no filename is provided, the rendition ID will be used.
44
+ attr_accessor :filename
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'format' => :'format',
72
+ :'size' => :'size',
73
+ :'fit' => :'fit',
74
+ :'resolution' => :'resolution',
75
+ :'quality' => :'quality',
76
+ :'fps' => :'fps',
77
+ :'speed' => :'speed',
78
+ :'keyframe_interval' => :'keyframeInterval',
79
+ :'enhance' => :'enhance',
80
+ :'filename' => :'filename'
81
+ }
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.openapi_types
91
+ {
92
+ :'format' => :'String',
93
+ :'size' => :'Size',
94
+ :'fit' => :'String',
95
+ :'resolution' => :'String',
96
+ :'quality' => :'Integer',
97
+ :'fps' => :'Float',
98
+ :'speed' => :'Speed',
99
+ :'keyframe_interval' => :'Integer',
100
+ :'enhance' => :'Enhancements',
101
+ :'filename' => :'String'
102
+ }
103
+ end
104
+
105
+ # List of attributes with nullable: true
106
+ def self.openapi_nullable
107
+ Set.new([
108
+ ])
109
+ end
110
+
111
+ # Initializes the object
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ def initialize(attributes = {})
114
+ if (!attributes.is_a?(Hash))
115
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Rendition` initialize method"
116
+ end
117
+
118
+ # check to see if the attribute exists and convert string to symbol for hash key
119
+ attributes = attributes.each_with_object({}) { |(k, v), h|
120
+ if (!self.class.attribute_map.key?(k.to_sym))
121
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Rendition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
122
+ end
123
+ h[k.to_sym] = v
124
+ }
125
+
126
+ if attributes.key?(:'format')
127
+ self.format = attributes[:'format']
128
+ end
129
+
130
+ if attributes.key?(:'size')
131
+ self.size = attributes[:'size']
132
+ end
133
+
134
+ if attributes.key?(:'fit')
135
+ self.fit = attributes[:'fit']
136
+ end
137
+
138
+ if attributes.key?(:'resolution')
139
+ self.resolution = attributes[:'resolution']
140
+ end
141
+
142
+ if attributes.key?(:'quality')
143
+ self.quality = attributes[:'quality']
144
+ end
145
+
146
+ if attributes.key?(:'fps')
147
+ self.fps = attributes[:'fps']
148
+ end
149
+
150
+ if attributes.key?(:'speed')
151
+ self.speed = attributes[:'speed']
152
+ end
153
+
154
+ if attributes.key?(:'keyframe_interval')
155
+ self.keyframe_interval = attributes[:'keyframe_interval']
156
+ end
157
+
158
+ if attributes.key?(:'enhance')
159
+ self.enhance = attributes[:'enhance']
160
+ end
161
+
162
+ if attributes.key?(:'filename')
163
+ self.filename = attributes[:'filename']
164
+ end
165
+ end
166
+
167
+ # Show invalid properties with the reasons. Usually used together with valid?
168
+ # @return Array for valid properties with the reasons
169
+ def list_invalid_properties
170
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
171
+ invalid_properties = Array.new
172
+ if !@quality.nil? && @quality > 100
173
+ invalid_properties.push('invalid value for "quality", must be smaller than or equal to 100.')
174
+ end
175
+
176
+ if !@quality.nil? && @quality < 1
177
+ invalid_properties.push('invalid value for "quality", must be greater than or equal to 1.')
178
+ end
179
+
180
+ if !@keyframe_interval.nil? && @keyframe_interval > 300
181
+ invalid_properties.push('invalid value for "keyframe_interval", must be smaller than or equal to 300.')
182
+ end
183
+
184
+ if !@keyframe_interval.nil? && @keyframe_interval < 1
185
+ invalid_properties.push('invalid value for "keyframe_interval", must be greater than or equal to 1.')
186
+ end
187
+
188
+ invalid_properties
189
+ end
190
+
191
+ # Check to see if the all the properties in the model are valid
192
+ # @return true if the model is valid
193
+ def valid?
194
+ warn '[DEPRECATED] the `valid?` method is obsolete'
195
+ format_validator = EnumAttributeValidator.new('String', ["mp4", "webm", "mov", "avi", "mkv", "ogv", "wmv", "avif", "gif", "mp3", "wav", "jpg", "png", "webp", "tif"])
196
+ return false unless format_validator.valid?(@format)
197
+ fit_validator = EnumAttributeValidator.new('String', ["cover", "contain", "crop"])
198
+ return false unless fit_validator.valid?(@fit)
199
+ resolution_validator = EnumAttributeValidator.new('String', ["preview", "mobile", "sd", "hd", "fhd"])
200
+ return false unless resolution_validator.valid?(@resolution)
201
+ return false if !@quality.nil? && @quality > 100
202
+ return false if !@quality.nil? && @quality < 1
203
+ fps_validator = EnumAttributeValidator.new('Float', [12, 15, 23.976, 24, 25, 29.97, 30, 48, 50, 59.94, 60])
204
+ return false unless fps_validator.valid?(@fps)
205
+ return false if !@keyframe_interval.nil? && @keyframe_interval > 300
206
+ return false if !@keyframe_interval.nil? && @keyframe_interval < 1
207
+ true
208
+ end
209
+
210
+ # Custom attribute writer method checking allowed values (enum).
211
+ # @param [Object] format Object to be assigned
212
+ def format=(format)
213
+ validator = EnumAttributeValidator.new('String', ["mp4", "webm", "mov", "avi", "mkv", "ogv", "wmv", "avif", "gif", "mp3", "wav", "jpg", "png", "webp", "tif"])
214
+ unless validator.valid?(format)
215
+ fail ArgumentError, "invalid value for \"format\", must be one of #{validator.allowable_values}."
216
+ end
217
+ @format = format
218
+ end
219
+
220
+ # Custom attribute writer method checking allowed values (enum).
221
+ # @param [Object] fit Object to be assigned
222
+ def fit=(fit)
223
+ validator = EnumAttributeValidator.new('String', ["cover", "contain", "crop"])
224
+ unless validator.valid?(fit)
225
+ fail ArgumentError, "invalid value for \"fit\", must be one of #{validator.allowable_values}."
226
+ end
227
+ @fit = fit
228
+ end
229
+
230
+ # Custom attribute writer method checking allowed values (enum).
231
+ # @param [Object] resolution Object to be assigned
232
+ def resolution=(resolution)
233
+ validator = EnumAttributeValidator.new('String', ["preview", "mobile", "sd", "hd", "fhd"])
234
+ unless validator.valid?(resolution)
235
+ fail ArgumentError, "invalid value for \"resolution\", must be one of #{validator.allowable_values}."
236
+ end
237
+ @resolution = resolution
238
+ end
239
+
240
+ # Custom attribute writer method with validation
241
+ # @param [Object] quality Value to be assigned
242
+ def quality=(quality)
243
+ if quality.nil?
244
+ fail ArgumentError, 'quality cannot be nil'
245
+ end
246
+
247
+ if quality > 100
248
+ fail ArgumentError, 'invalid value for "quality", must be smaller than or equal to 100.'
249
+ end
250
+
251
+ if quality < 1
252
+ fail ArgumentError, 'invalid value for "quality", must be greater than or equal to 1.'
253
+ end
254
+
255
+ @quality = quality
256
+ end
257
+
258
+ # Custom attribute writer method checking allowed values (enum).
259
+ # @param [Object] fps Object to be assigned
260
+ def fps=(fps)
261
+ validator = EnumAttributeValidator.new('Float', [12, 15, 23.976, 24, 25, 29.97, 30, 48, 50, 59.94, 60])
262
+ unless validator.valid?(fps)
263
+ fail ArgumentError, "invalid value for \"fps\", must be one of #{validator.allowable_values}."
264
+ end
265
+ @fps = fps
266
+ end
267
+
268
+ # Custom attribute writer method with validation
269
+ # @param [Object] keyframe_interval Value to be assigned
270
+ def keyframe_interval=(keyframe_interval)
271
+ if keyframe_interval.nil?
272
+ fail ArgumentError, 'keyframe_interval cannot be nil'
273
+ end
274
+
275
+ if keyframe_interval > 300
276
+ fail ArgumentError, 'invalid value for "keyframe_interval", must be smaller than or equal to 300.'
277
+ end
278
+
279
+ if keyframe_interval < 1
280
+ fail ArgumentError, 'invalid value for "keyframe_interval", must be greater than or equal to 1.'
281
+ end
282
+
283
+ @keyframe_interval = keyframe_interval
284
+ end
285
+
286
+ # Checks equality by comparing each attribute.
287
+ # @param [Object] Object to be compared
288
+ def ==(o)
289
+ return true if self.equal?(o)
290
+ self.class == o.class &&
291
+ format == o.format &&
292
+ size == o.size &&
293
+ fit == o.fit &&
294
+ resolution == o.resolution &&
295
+ quality == o.quality &&
296
+ fps == o.fps &&
297
+ speed == o.speed &&
298
+ keyframe_interval == o.keyframe_interval &&
299
+ enhance == o.enhance &&
300
+ filename == o.filename
301
+ end
302
+
303
+ # @see the `==` method
304
+ # @param [Object] Object to be compared
305
+ def eql?(o)
306
+ self == o
307
+ end
308
+
309
+ # Calculates hash code according to all attributes.
310
+ # @return [Integer] Hash code
311
+ def hash
312
+ [format, size, fit, resolution, quality, fps, speed, keyframe_interval, enhance, filename].hash
313
+ end
314
+
315
+ # Builds the object from hash
316
+ # @param [Hash] attributes Model attributes in the form of hash
317
+ # @return [Object] Returns the model itself
318
+ def self.build_from_hash(attributes)
319
+ return nil unless attributes.is_a?(Hash)
320
+ attributes = attributes.transform_keys(&:to_sym)
321
+ transformed_hash = {}
322
+ openapi_types.each_pair do |key, type|
323
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
324
+ transformed_hash["#{key}"] = nil
325
+ elsif type =~ /\AArray<(.*)>/i
326
+ # check to ensure the input is an array given that the attribute
327
+ # is documented as an array but the input is not
328
+ if attributes[attribute_map[key]].is_a?(Array)
329
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
330
+ end
331
+ elsif !attributes[attribute_map[key]].nil?
332
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
333
+ end
334
+ end
335
+ new(transformed_hash)
336
+ end
337
+
338
+ # Deserializes the data based on type
339
+ # @param string type Data type
340
+ # @param string value Value to be deserialized
341
+ # @return [Object] Deserialized data
342
+ def self._deserialize(type, value)
343
+ case type.to_sym
344
+ when :Time
345
+ Time.parse(value)
346
+ when :Date
347
+ Date.parse(value)
348
+ when :String
349
+ value.to_s
350
+ when :Integer
351
+ value.to_i
352
+ when :Float
353
+ value.to_f
354
+ when :Boolean
355
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
356
+ true
357
+ else
358
+ false
359
+ end
360
+ when :Object
361
+ # generic object (usually a Hash), return directly
362
+ value
363
+ when /\AArray<(?<inner_type>.+)>\z/
364
+ inner_type = Regexp.last_match[:inner_type]
365
+ value.map { |v| _deserialize(inner_type, v) }
366
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
367
+ k_type = Regexp.last_match[:k_type]
368
+ v_type = Regexp.last_match[:v_type]
369
+ {}.tap do |hash|
370
+ value.each do |k, v|
371
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
372
+ end
373
+ end
374
+ else # model
375
+ # models (e.g. Pet) or oneOf
376
+ klass = Shotstack.const_get(type)
377
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
378
+ end
379
+ end
380
+
381
+ # Returns the string representation of the object
382
+ # @return [String] String presentation of the object
383
+ def to_s
384
+ to_hash.to_s
385
+ end
386
+
387
+ # to_body is an alias to to_hash (backward compatibility)
388
+ # @return [Hash] Returns the object in the form of hash
389
+ def to_body
390
+ to_hash
391
+ end
392
+
393
+ # Returns the object in the form of hash
394
+ # @return [Hash] Returns the object in the form of hash
395
+ def to_hash
396
+ hash = {}
397
+ self.class.attribute_map.each_pair do |attr, param|
398
+ value = self.send(attr)
399
+ if value.nil?
400
+ is_nullable = self.class.openapi_nullable.include?(attr)
401
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
402
+ end
403
+
404
+ hash[param] = _to_hash(value)
405
+ end
406
+ hash
407
+ end
408
+
409
+ # Outputs non-array value in the form of hash
410
+ # For object, use to_hash. Otherwise, just return the value
411
+ # @param [Object] value Any valid value
412
+ # @return [Hash] Returns the value in the form of hash
413
+ def _to_hash(value)
414
+ if value.is_a?(Array)
415
+ value.compact.map { |v| _to_hash(v) }
416
+ elsif value.is_a?(Hash)
417
+ {}.tap do |hash|
418
+ value.each { |k, v| hash[k] = _to_hash(v) }
419
+ end
420
+ elsif value.respond_to? :to_hash
421
+ value.to_hash
422
+ else
423
+ value
424
+ end
425
+ end
426
+
427
+ end
428
+
429
+ end