shotstack 0.2.1 → 0.2.6

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 (122) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/README.md +387 -23
  4. data/Rakefile +10 -0
  5. data/lib/shotstack/api/create_api.rb +158 -0
  6. data/lib/shotstack/api/edit_api.rb +20 -20
  7. data/lib/shotstack/api/ingest_api.rb +338 -0
  8. data/lib/shotstack/api/serve_api.rb +76 -8
  9. data/lib/shotstack/api_client.rb +28 -24
  10. data/lib/shotstack/api_error.rb +3 -2
  11. data/lib/shotstack/configuration.rb +55 -9
  12. data/lib/shotstack/models/asset.rb +4 -4
  13. data/lib/shotstack/models/asset_render_response.rb +23 -20
  14. data/lib/shotstack/models/asset_response.rb +23 -20
  15. data/lib/shotstack/models/asset_response_attributes.rb +38 -21
  16. data/lib/shotstack/models/asset_response_data.rb +30 -20
  17. data/lib/shotstack/models/audio_asset.rb +57 -23
  18. data/lib/shotstack/models/audio_enhancement.rb +43 -0
  19. data/lib/shotstack/models/clip.rb +29 -33
  20. data/lib/shotstack/models/crop.rb +40 -28
  21. data/lib/shotstack/models/destinations.rb +78 -244
  22. data/lib/shotstack/models/did_generated_asset.rb +273 -0
  23. data/lib/shotstack/models/did_generated_asset_options.rb +54 -0
  24. data/lib/shotstack/models/did_text_to_avatar_options.rb +313 -0
  25. data/lib/shotstack/models/dolby_enhancement.rb +239 -0
  26. data/lib/shotstack/models/dolby_enhancement_options.rb +257 -0
  27. data/lib/shotstack/models/edit.rb +22 -24
  28. data/lib/shotstack/models/eleven_labs_generated_asset.rb +273 -0
  29. data/lib/shotstack/models/eleven_labs_generated_asset_options.rb +54 -0
  30. data/lib/shotstack/models/eleven_labs_text_to_speech_options.rb +303 -0
  31. data/lib/shotstack/models/enhancements.rb +215 -0
  32. data/lib/shotstack/models/flip_transformation.rb +16 -24
  33. data/lib/shotstack/models/font.rb +18 -20
  34. data/lib/shotstack/models/generated_asset.rb +48 -0
  35. data/lib/shotstack/models/generated_asset_error_response.rb +225 -0
  36. data/lib/shotstack/models/generated_asset_error_response_data.rb +257 -0
  37. data/lib/shotstack/models/generated_asset_response.rb +222 -0
  38. data/lib/shotstack/models/generated_asset_response_attributes.rb +376 -0
  39. data/lib/shotstack/models/generated_asset_response_data.rb +256 -0
  40. data/lib/shotstack/models/google_cloud_storage_destination.rb +232 -0
  41. data/lib/shotstack/models/google_cloud_storage_destination_options.rb +243 -0
  42. data/lib/shotstack/models/google_drive_destination.rb +239 -0
  43. data/lib/shotstack/models/google_drive_destination_options.rb +233 -0
  44. data/lib/shotstack/models/hey_gen_generated_asset.rb +273 -0
  45. data/lib/shotstack/models/hey_gen_generated_asset_options.rb +54 -0
  46. data/lib/shotstack/models/hey_gen_text_to_avatar_options.rb +396 -0
  47. data/lib/shotstack/models/html_asset.rb +20 -26
  48. data/lib/shotstack/models/image_asset.rb +18 -20
  49. data/lib/shotstack/models/ingest_error_response.rb +225 -0
  50. data/lib/shotstack/models/ingest_error_response_data.rb +257 -0
  51. data/lib/shotstack/models/luma_asset.rb +18 -20
  52. data/lib/shotstack/models/merge_field.rb +20 -20
  53. data/lib/shotstack/models/mux_destination.rb +18 -22
  54. data/lib/shotstack/models/mux_destination_options.rb +50 -25
  55. data/lib/shotstack/models/offset.rb +46 -46
  56. data/lib/shotstack/models/open_ai_generated_asset.rb +273 -0
  57. data/lib/shotstack/models/open_ai_generated_asset_options.rb +54 -0
  58. data/lib/shotstack/models/open_ai_text_generator_options.rb +313 -0
  59. data/lib/shotstack/models/output.rb +40 -35
  60. data/lib/shotstack/models/outputs.rb +227 -0
  61. data/lib/shotstack/models/outputs_response.rb +218 -0
  62. data/lib/shotstack/models/poster.rb +18 -20
  63. data/lib/shotstack/models/probe_response.rb +22 -20
  64. data/lib/shotstack/models/queued_response.rb +22 -20
  65. data/lib/shotstack/models/queued_response_data.rb +20 -20
  66. data/lib/shotstack/models/queued_source_response.rb +222 -0
  67. data/lib/shotstack/models/queued_source_response_data.rb +240 -0
  68. data/lib/shotstack/models/range.rb +26 -22
  69. data/lib/shotstack/models/render_response.rb +22 -20
  70. data/lib/shotstack/models/render_response_data.rb +24 -35
  71. data/lib/shotstack/models/rendition.rb +429 -0
  72. data/lib/shotstack/models/rendition_response_attributes.rb +336 -0
  73. data/lib/shotstack/models/rotate_transformation.rb +16 -22
  74. data/lib/shotstack/models/s3_destination.rb +232 -0
  75. data/lib/shotstack/models/s3_destination_options.rb +270 -0
  76. data/lib/shotstack/models/shotstack_destination.rb +19 -25
  77. data/lib/shotstack/models/shotstack_generated_asset.rb +273 -0
  78. data/lib/shotstack/models/shotstack_generated_asset_options.rb +60 -0
  79. data/lib/shotstack/models/shotstack_image_to_video_options.rb +298 -0
  80. data/lib/shotstack/models/shotstack_text_generator_options.rb +274 -0
  81. data/lib/shotstack/models/shotstack_text_to_image_options.rb +308 -0
  82. data/lib/shotstack/models/shotstack_text_to_speech_options.rb +339 -0
  83. data/lib/shotstack/models/size.rb +39 -35
  84. data/lib/shotstack/models/skew_transformation.rb +16 -24
  85. data/lib/shotstack/models/soundtrack.rb +18 -22
  86. data/lib/shotstack/models/source.rb +244 -0
  87. data/lib/shotstack/models/source_list_response.rb +225 -0
  88. data/lib/shotstack/models/source_response.rb +222 -0
  89. data/lib/shotstack/models/source_response_attributes.rb +373 -0
  90. data/lib/shotstack/models/source_response_data.rb +256 -0
  91. data/lib/shotstack/models/speed.rb +254 -0
  92. data/lib/shotstack/models/stability_ai_generated_asset.rb +273 -0
  93. data/lib/shotstack/models/stability_ai_generated_asset_options.rb +54 -0
  94. data/lib/shotstack/models/stability_ai_text_to_image_options.rb +390 -0
  95. data/lib/shotstack/models/template.rb +18 -20
  96. data/lib/shotstack/models/template_data_response.rb +24 -22
  97. data/lib/shotstack/models/template_data_response_data.rb +25 -22
  98. data/lib/shotstack/models/template_list_response.rb +24 -22
  99. data/lib/shotstack/models/template_list_response_data.rb +20 -20
  100. data/lib/shotstack/models/template_list_response_item.rb +20 -30
  101. data/lib/shotstack/models/template_render.rb +19 -21
  102. data/lib/shotstack/models/template_response.rb +23 -21
  103. data/lib/shotstack/models/template_response_data.rb +20 -20
  104. data/lib/shotstack/models/thumbnail.rb +20 -20
  105. data/lib/shotstack/models/timeline.rb +19 -25
  106. data/lib/shotstack/models/title_asset.rb +19 -27
  107. data/lib/shotstack/models/track.rb +18 -20
  108. data/lib/shotstack/models/transcription.rb +250 -0
  109. data/lib/shotstack/models/transfer.rb +259 -0
  110. data/lib/shotstack/models/transfer_response.rb +222 -0
  111. data/lib/shotstack/models/transfer_response_attributes.rb +280 -0
  112. data/lib/shotstack/models/transfer_response_data.rb +225 -0
  113. data/lib/shotstack/models/transformation.rb +16 -20
  114. data/lib/shotstack/models/transition.rb +16 -20
  115. data/lib/shotstack/models/upload_response.rb +222 -0
  116. data/lib/shotstack/models/upload_response_attributes.rb +257 -0
  117. data/lib/shotstack/models/upload_response_data.rb +256 -0
  118. data/lib/shotstack/models/video_asset.rb +102 -22
  119. data/lib/shotstack/version.rb +3 -3
  120. data/lib/shotstack.rb +63 -2
  121. data/shotstack.gemspec +8 -8
  122. metadata +80 -24
@@ -0,0 +1,257 @@
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
+ # The id and attributes of the upload file including the signed URL to send the binary file data to.
18
+ class UploadResponseAttributes
19
+ # The source id.
20
+ attr_accessor :id
21
+
22
+ # The signed URL to use in a PUT request to send the binary file to.
23
+ attr_accessor :url
24
+
25
+ # The time the upload request will expire. The signed URL will expire after one hour. Upload must complete within one hour.
26
+ attr_accessor :expires
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'id' => :'id',
32
+ :'url' => :'url',
33
+ :'expires' => :'expires'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'id' => :'String',
46
+ :'url' => :'String',
47
+ :'expires' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::UploadResponseAttributes` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::UploadResponseAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'id')
73
+ self.id = attributes[:'id']
74
+ else
75
+ self.id = nil
76
+ end
77
+
78
+ if attributes.key?(:'url')
79
+ self.url = attributes[:'url']
80
+ else
81
+ self.url = nil
82
+ end
83
+
84
+ if attributes.key?(:'expires')
85
+ self.expires = attributes[:'expires']
86
+ else
87
+ self.expires = nil
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @id.nil?
97
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
98
+ end
99
+
100
+ if @url.nil?
101
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
102
+ end
103
+
104
+ if @expires.nil?
105
+ invalid_properties.push('invalid value for "expires", expires cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @id.nil?
116
+ return false if @url.nil?
117
+ return false if @expires.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ id == o.id &&
127
+ url == o.url &&
128
+ expires == o.expires
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [id, url, expires].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = Shotstack.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end
@@ -0,0 +1,256 @@
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
+ # The type of resource (an upload), it's id and attributes of the upload request.
18
+ class UploadResponseData
19
+ # The type of resource, in this case it is an upload.
20
+ attr_accessor :type
21
+
22
+ # The upload file id.
23
+ attr_accessor :id
24
+
25
+ attr_accessor :attributes
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'type' => :'type',
31
+ :'id' => :'id',
32
+ :'attributes' => :'attributes'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'type' => :'String',
45
+ :'id' => :'String',
46
+ :'attributes' => :'UploadResponseAttributes'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::UploadResponseData` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::UploadResponseData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'type')
72
+ self.type = attributes[:'type']
73
+ else
74
+ self.type = nil
75
+ end
76
+
77
+ if attributes.key?(:'id')
78
+ self.id = attributes[:'id']
79
+ else
80
+ self.id = nil
81
+ end
82
+
83
+ if attributes.key?(:'attributes')
84
+ self.attributes = attributes[:'attributes']
85
+ else
86
+ self.attributes = nil
87
+ end
88
+ end
89
+
90
+ # Show invalid properties with the reasons. Usually used together with valid?
91
+ # @return Array for valid properties with the reasons
92
+ def list_invalid_properties
93
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
94
+ invalid_properties = Array.new
95
+ if @type.nil?
96
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
97
+ end
98
+
99
+ if @id.nil?
100
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
101
+ end
102
+
103
+ if @attributes.nil?
104
+ invalid_properties.push('invalid value for "attributes", attributes cannot be nil.')
105
+ end
106
+
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ warn '[DEPRECATED] the `valid?` method is obsolete'
114
+ return false if @type.nil?
115
+ return false if @id.nil?
116
+ return false if @attributes.nil?
117
+ true
118
+ end
119
+
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
122
+ def ==(o)
123
+ return true if self.equal?(o)
124
+ self.class == o.class &&
125
+ type == o.type &&
126
+ id == o.id &&
127
+ attributes == o.attributes
128
+ end
129
+
130
+ # @see the `==` method
131
+ # @param [Object] Object to be compared
132
+ def eql?(o)
133
+ self == o
134
+ end
135
+
136
+ # Calculates hash code according to all attributes.
137
+ # @return [Integer] Hash code
138
+ def hash
139
+ [type, id, attributes].hash
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def self.build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ attributes = attributes.transform_keys(&:to_sym)
148
+ transformed_hash = {}
149
+ openapi_types.each_pair do |key, type|
150
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
151
+ transformed_hash["#{key}"] = nil
152
+ elsif type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[attribute_map[key]].is_a?(Array)
156
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
157
+ end
158
+ elsif !attributes[attribute_map[key]].nil?
159
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
160
+ end
161
+ end
162
+ new(transformed_hash)
163
+ end
164
+
165
+ # Deserializes the data based on type
166
+ # @param string type Data type
167
+ # @param string value Value to be deserialized
168
+ # @return [Object] Deserialized data
169
+ def self._deserialize(type, value)
170
+ case type.to_sym
171
+ when :Time
172
+ Time.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :Boolean
182
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when :Object
188
+ # generic object (usually a Hash), return directly
189
+ value
190
+ when /\AArray<(?<inner_type>.+)>\z/
191
+ inner_type = Regexp.last_match[:inner_type]
192
+ value.map { |v| _deserialize(inner_type, v) }
193
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
194
+ k_type = Regexp.last_match[:k_type]
195
+ v_type = Regexp.last_match[:v_type]
196
+ {}.tap do |hash|
197
+ value.each do |k, v|
198
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
199
+ end
200
+ end
201
+ else # model
202
+ # models (e.g. Pet) or oneOf
203
+ klass = Shotstack.const_get(type)
204
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ end