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,48 @@
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 generated asset is a media asset created by the Create API. You can use native or third party providers to generate video, audio and image files using Generative AI services like text-to-speech and text-to-avatar. The following providers are currently available: <ul> <li><a href=\"#tocs_shotstackgeneratedasset\">ShotstackGeneratedAsset</a></li> <li><a href=\"#tocs_didgeneratedasset\">DIDGeneratedAsset</a></li> <li><a href=\"#tocs_elevenlabsgeneratedasset\">ElevenLabsGeneratedAsset</a></li> <li><a href=\"#tocs_heygengeneratedasset\">HeyGenGeneratedAsset</a></li> <li><a href=\"#tocs_openaigeneratedasset\">OpenAiGeneratedAsset</a></li> <li><a href=\"#tocs_stabilityaigeneratedasset\">StabilityAiGeneratedAsset</a></li> </ul>
18
+ module GeneratedAsset
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'DIDGeneratedAsset',
24
+ :'ElevenLabsGeneratedAsset',
25
+ :'HeyGenGeneratedAsset',
26
+ :'OpenAiGeneratedAsset',
27
+ :'ShotstackGeneratedAsset',
28
+ :'StabilityAiGeneratedAsset'
29
+ ]
30
+ end
31
+
32
+ # Discriminator's property name (OpenAPI v3)
33
+ def openapi_discriminator_name
34
+ :'provider'
35
+ end
36
+
37
+ # Builds the object
38
+ # @param [Mixed] Data to be matched against the list of oneOf items
39
+ # @return [Object] Returns the model or the data itself
40
+ def build(data)
41
+ discriminator_value = data[openapi_discriminator_name]
42
+ return nil if discriminator_value.nil?
43
+ Shotstack.const_get(discriminator_value).build_from_hash(data)
44
+ end
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,225 @@
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
+ # Error response data for validation and other errors returned by the Create API.
18
+ class GeneratedAssetErrorResponse
19
+ # An array of errors.
20
+ attr_accessor :errors
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'errors' => :'errors'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'errors' => :'Array<GeneratedAssetErrorResponseData>'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ ])
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::GeneratedAssetErrorResponse` initialize method"
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::GeneratedAssetErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ end
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:'errors')
63
+ if (value = attributes[:'errors']).is_a?(Array)
64
+ self.errors = value
65
+ end
66
+ else
67
+ self.errors = nil
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
75
+ invalid_properties = Array.new
76
+ if @errors.nil?
77
+ invalid_properties.push('invalid value for "errors", errors cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ warn '[DEPRECATED] the `valid?` method is obsolete'
87
+ return false if @errors.nil?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ errors == o.errors
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [errors].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ transformed_hash = {}
118
+ openapi_types.each_pair do |key, type|
119
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
120
+ transformed_hash["#{key}"] = nil
121
+ elsif type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[attribute_map[key]].is_a?(Array)
125
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
126
+ end
127
+ elsif !attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
129
+ end
130
+ end
131
+ new(transformed_hash)
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def self._deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Shotstack.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -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
+ # Individual errors returned by the Create API.
18
+ class GeneratedAssetErrorResponseData
19
+ # The http status code.
20
+ attr_accessor :status
21
+
22
+ # A short summary of the error.
23
+ attr_accessor :title
24
+
25
+ # A detailed description of the error.
26
+ attr_accessor :detail
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'status' => :'status',
32
+ :'title' => :'title',
33
+ :'detail' => :'detail'
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
+ :'status' => :'String',
46
+ :'title' => :'String',
47
+ :'detail' => :'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::GeneratedAssetErrorResponseData` 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::GeneratedAssetErrorResponseData`. 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?(:'status')
73
+ self.status = attributes[:'status']
74
+ else
75
+ self.status = nil
76
+ end
77
+
78
+ if attributes.key?(:'title')
79
+ self.title = attributes[:'title']
80
+ else
81
+ self.title = nil
82
+ end
83
+
84
+ if attributes.key?(:'detail')
85
+ self.detail = attributes[:'detail']
86
+ else
87
+ self.detail = 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 @status.nil?
97
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
98
+ end
99
+
100
+ if @title.nil?
101
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
102
+ end
103
+
104
+ if @detail.nil?
105
+ invalid_properties.push('invalid value for "detail", detail 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 @status.nil?
116
+ return false if @title.nil?
117
+ return false if @detail.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
+ status == o.status &&
127
+ title == o.title &&
128
+ detail == o.detail
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
+ [status, title, detail].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