shotstack 0.1.0 → 0.1.5
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.
- checksums.yaml +4 -4
- data/README.md +17 -12
- data/lib/shotstack.rb +3 -1
- data/lib/shotstack/api/endpoints_api.rb +20 -11
- data/lib/shotstack/api_client.rb +49 -45
- data/lib/shotstack/api_error.rb +1 -1
- data/lib/shotstack/configuration.rb +35 -8
- data/lib/shotstack/models/audio_asset.rb +70 -12
- data/lib/shotstack/models/clip.rb +27 -13
- data/lib/shotstack/models/crop.rb +346 -0
- data/lib/shotstack/models/edit.rb +19 -7
- data/lib/shotstack/models/font.rb +19 -7
- data/lib/shotstack/models/html_asset.rb +25 -13
- data/lib/shotstack/models/image_asset.rb +34 -13
- data/lib/shotstack/models/luma_asset.rb +20 -8
- data/lib/shotstack/models/offset.rb +23 -7
- data/lib/shotstack/models/output.rb +60 -15
- data/lib/shotstack/models/poster.rb +19 -7
- data/lib/shotstack/models/queued_response.rb +21 -7
- data/lib/shotstack/models/queued_response_data.rb +21 -9
- data/lib/shotstack/models/range.rb +260 -0
- data/lib/shotstack/models/render_response.rb +21 -7
- data/lib/shotstack/models/render_response_data.rb +100 -28
- data/lib/shotstack/models/soundtrack.rb +22 -8
- data/lib/shotstack/models/thumbnail.rb +19 -7
- data/lib/shotstack/models/timeline.rb +19 -7
- data/lib/shotstack/models/title_asset.rb +24 -12
- data/lib/shotstack/models/track.rb +19 -7
- data/lib/shotstack/models/transition.rb +25 -13
- data/lib/shotstack/models/video_asset.rb +33 -12
- data/lib/shotstack/version.rb +2 -2
- data/shotstack.gemspec +6 -7
- metadata +9 -28
- data/shotstack-0.0.11.gem +0 -0
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
The version of the OpenAPI document: v1
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
OpenAPI Generator version:
|
|
9
|
+
OpenAPI Generator version: 5.0.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
13
|
require 'date'
|
|
14
|
+
require 'time'
|
|
14
15
|
|
|
15
16
|
module Shotstack
|
|
16
17
|
# A clip is a container for a specific type of asset, i.e. a title, image, video, audio or html. You use a Clip to define when an asset will display on the timeline, how long it will play for and transitions, filters and effects to apply to it.
|
|
@@ -30,17 +31,17 @@ module Shotstack
|
|
|
30
31
|
# Scale the asset to a fraction of the viewport size - i.e. setting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks.
|
|
31
32
|
attr_accessor :scale
|
|
32
33
|
|
|
33
|
-
# Place the asset in one of nine predefined positions of the viewport. This is most effective for when the asset is scaled and you want to position the element to a specific position.
|
|
34
|
+
# Place the asset in one of nine predefined positions of the viewport. This is most effective for when the asset is scaled and you want to position the element to a specific position. <ul> <li>`top` - top (center)</li> <li>`topRight` - top right</li> <li>`right` - right (center)</li> <li>`bottomRight` - bottom right</li> <li>`bottom` - bottom (center)</li> <li>`bottomLeft` - bottom left</li> <li>`left` - left (center)</li> <li>`topLeft` - top left</li> <li>`center` - center</li> </ul>
|
|
34
35
|
attr_accessor :position
|
|
35
36
|
|
|
36
37
|
attr_accessor :offset
|
|
37
38
|
|
|
38
39
|
attr_accessor :transition
|
|
39
40
|
|
|
40
|
-
# A motion effect to apply to the Clip.
|
|
41
|
+
# A motion effect to apply to the Clip. <ul> <li>`zoomIn` - slow zoom in</li> <li>`zoomOut` - slow zoom out</li> <li>`slideLeft` - slow slide (pan) left</li> <li>`slideRight` - slow slide (pan) right</li> <li>`slideUp` - slow slide (pan) up</li> <li>`slideDown` - slow slide (pan) down</li> </ul>
|
|
41
42
|
attr_accessor :effect
|
|
42
43
|
|
|
43
|
-
# A filter effect to apply to the Clip.
|
|
44
|
+
# A filter effect to apply to the Clip. <ul> <li>`boost` - boost contrast and saturation</li> <li>`contrast` - increase contrast</li> <li>`darken` - darken the scene</li> <li>`greyscale` - remove colour</li> <li>`lighten` - lighten the scene</li> <li>`muted` - reduce saturation and contrast</li> <li>`invert` - invert colors</li> </ul>
|
|
44
45
|
attr_accessor :filter
|
|
45
46
|
|
|
46
47
|
# Sets the opacity of the Clip where 1 is opaque and 0 is transparent.
|
|
@@ -85,10 +86,15 @@ module Shotstack
|
|
|
85
86
|
}
|
|
86
87
|
end
|
|
87
88
|
|
|
89
|
+
# Returns all the JSON keys this model knows about
|
|
90
|
+
def self.acceptable_attributes
|
|
91
|
+
attribute_map.values
|
|
92
|
+
end
|
|
93
|
+
|
|
88
94
|
# Attribute type mapping.
|
|
89
95
|
def self.openapi_types
|
|
90
96
|
{
|
|
91
|
-
:'asset' => :'
|
|
97
|
+
:'asset' => :'Asset',
|
|
92
98
|
:'start' => :'Float',
|
|
93
99
|
:'length' => :'Float',
|
|
94
100
|
:'fit' => :'String',
|
|
@@ -169,6 +175,8 @@ module Shotstack
|
|
|
169
175
|
|
|
170
176
|
if attributes.key?(:'opacity')
|
|
171
177
|
self.opacity = attributes[:'opacity']
|
|
178
|
+
else
|
|
179
|
+
self.opacity = 1
|
|
172
180
|
end
|
|
173
181
|
end
|
|
174
182
|
|
|
@@ -203,7 +211,7 @@ module Shotstack
|
|
|
203
211
|
return false unless position_validator.valid?(@position)
|
|
204
212
|
effect_validator = EnumAttributeValidator.new('String', ["zoomIn", "zoomOut", "slideLeft", "slideRight", "slideUp", "slideDown"])
|
|
205
213
|
return false unless effect_validator.valid?(@effect)
|
|
206
|
-
filter_validator = EnumAttributeValidator.new('String', ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
|
|
214
|
+
filter_validator = EnumAttributeValidator.new('String', ["blur", "boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
|
|
207
215
|
return false unless filter_validator.valid?(@filter)
|
|
208
216
|
true
|
|
209
217
|
end
|
|
@@ -241,7 +249,7 @@ module Shotstack
|
|
|
241
249
|
# Custom attribute writer method checking allowed values (enum).
|
|
242
250
|
# @param [Object] filter Object to be assigned
|
|
243
251
|
def filter=(filter)
|
|
244
|
-
validator = EnumAttributeValidator.new('String', ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
|
|
252
|
+
validator = EnumAttributeValidator.new('String', ["blur", "boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
|
|
245
253
|
unless validator.valid?(filter)
|
|
246
254
|
fail ArgumentError, "invalid value for \"filter\", must be one of #{validator.allowable_values}."
|
|
247
255
|
end
|
|
@@ -291,7 +299,9 @@ module Shotstack
|
|
|
291
299
|
def build_from_hash(attributes)
|
|
292
300
|
return nil unless attributes.is_a?(Hash)
|
|
293
301
|
self.class.openapi_types.each_pair do |key, type|
|
|
294
|
-
if
|
|
302
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
303
|
+
self.send("#{key}=", nil)
|
|
304
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
295
305
|
# check to ensure the input is an array given that the attribute
|
|
296
306
|
# is documented as an array but the input is not
|
|
297
307
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
@@ -299,7 +309,7 @@ module Shotstack
|
|
|
299
309
|
end
|
|
300
310
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
301
311
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
302
|
-
end
|
|
312
|
+
end
|
|
303
313
|
end
|
|
304
314
|
|
|
305
315
|
self
|
|
@@ -311,8 +321,8 @@ module Shotstack
|
|
|
311
321
|
# @return [Object] Deserialized data
|
|
312
322
|
def _deserialize(type, value)
|
|
313
323
|
case type.to_sym
|
|
314
|
-
when :
|
|
315
|
-
|
|
324
|
+
when :Time
|
|
325
|
+
Time.parse(value)
|
|
316
326
|
when :Date
|
|
317
327
|
Date.parse(value)
|
|
318
328
|
when :String
|
|
@@ -342,7 +352,9 @@ module Shotstack
|
|
|
342
352
|
end
|
|
343
353
|
end
|
|
344
354
|
else # model
|
|
345
|
-
|
|
355
|
+
# models (e.g. Pet) or oneOf
|
|
356
|
+
klass = Shotstack.const_get(type)
|
|
357
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
346
358
|
end
|
|
347
359
|
end
|
|
348
360
|
|
|
@@ -368,7 +380,7 @@ module Shotstack
|
|
|
368
380
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
369
381
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
370
382
|
end
|
|
371
|
-
|
|
383
|
+
|
|
372
384
|
hash[param] = _to_hash(value)
|
|
373
385
|
end
|
|
374
386
|
hash
|
|
@@ -391,5 +403,7 @@ module Shotstack
|
|
|
391
403
|
value
|
|
392
404
|
end
|
|
393
405
|
end
|
|
406
|
+
|
|
394
407
|
end
|
|
408
|
+
|
|
395
409
|
end
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Shotstack
|
|
3
|
+
|
|
4
|
+
#The Shotstack API is a video editing service that allows for the automated creation of videos using JSON. You can configure an edit and POST it to the Shotstack API which will render your video and provide a file location when complete. For more details check https://shotstack.io
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: v1
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
OpenAPI Generator version: 5.0.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Shotstack
|
|
17
|
+
# Crop the sides of an asset by a relative amount. The size of the crop is specified using a scale between 0 and 1, relative to the screen width - i.e a left crop of 0.5 will crop half of the asset from the left, a top crop of 0.25 will crop the top by quarter of the asset.
|
|
18
|
+
class Crop
|
|
19
|
+
# Crop from the top of the asset
|
|
20
|
+
attr_accessor :top
|
|
21
|
+
|
|
22
|
+
# Crop from the bottom of the asset
|
|
23
|
+
attr_accessor :bottom
|
|
24
|
+
|
|
25
|
+
# Crop from the left of the asset
|
|
26
|
+
attr_accessor :left
|
|
27
|
+
|
|
28
|
+
# Crop from the left of the asset
|
|
29
|
+
attr_accessor :right
|
|
30
|
+
|
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
32
|
+
def self.attribute_map
|
|
33
|
+
{
|
|
34
|
+
:'top' => :'top',
|
|
35
|
+
:'bottom' => :'bottom',
|
|
36
|
+
:'left' => :'left',
|
|
37
|
+
:'right' => :'right'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns all the JSON keys this model knows about
|
|
42
|
+
def self.acceptable_attributes
|
|
43
|
+
attribute_map.values
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Attribute type mapping.
|
|
47
|
+
def self.openapi_types
|
|
48
|
+
{
|
|
49
|
+
:'top' => :'Float',
|
|
50
|
+
:'bottom' => :'Float',
|
|
51
|
+
:'left' => :'Float',
|
|
52
|
+
:'right' => :'Float'
|
|
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 `Shotstack::Crop` 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 `Shotstack::Crop`. 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?(:'top')
|
|
78
|
+
self.top = attributes[:'top']
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if attributes.key?(:'bottom')
|
|
82
|
+
self.bottom = attributes[:'bottom']
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if attributes.key?(:'left')
|
|
86
|
+
self.left = attributes[:'left']
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
if attributes.key?(:'right')
|
|
90
|
+
self.right = attributes[:'right']
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
95
|
+
# @return Array for valid properties with the reasons
|
|
96
|
+
def list_invalid_properties
|
|
97
|
+
invalid_properties = Array.new
|
|
98
|
+
if !@top.nil? && @top > 1
|
|
99
|
+
invalid_properties.push('invalid value for "top", must be smaller than or equal to 1.')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
if !@top.nil? && @top < 0
|
|
103
|
+
invalid_properties.push('invalid value for "top", must be greater than or equal to 0.')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if !@bottom.nil? && @bottom > 1
|
|
107
|
+
invalid_properties.push('invalid value for "bottom", must be smaller than or equal to 1.')
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
if !@bottom.nil? && @bottom < 0
|
|
111
|
+
invalid_properties.push('invalid value for "bottom", must be greater than or equal to 0.')
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
if !@left.nil? && @left > 1
|
|
115
|
+
invalid_properties.push('invalid value for "left", must be smaller than or equal to 1.')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if !@left.nil? && @left < 0
|
|
119
|
+
invalid_properties.push('invalid value for "left", must be greater than or equal to 0.')
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if !@right.nil? && @right > 1
|
|
123
|
+
invalid_properties.push('invalid value for "right", must be smaller than or equal to 1.')
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
if !@right.nil? && @right < 0
|
|
127
|
+
invalid_properties.push('invalid value for "right", must be greater than or equal to 0.')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
invalid_properties
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Check to see if the all the properties in the model are valid
|
|
134
|
+
# @return true if the model is valid
|
|
135
|
+
def valid?
|
|
136
|
+
return false if !@top.nil? && @top > 1
|
|
137
|
+
return false if !@top.nil? && @top < 0
|
|
138
|
+
return false if !@bottom.nil? && @bottom > 1
|
|
139
|
+
return false if !@bottom.nil? && @bottom < 0
|
|
140
|
+
return false if !@left.nil? && @left > 1
|
|
141
|
+
return false if !@left.nil? && @left < 0
|
|
142
|
+
return false if !@right.nil? && @right > 1
|
|
143
|
+
return false if !@right.nil? && @right < 0
|
|
144
|
+
true
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Custom attribute writer method with validation
|
|
148
|
+
# @param [Object] top Value to be assigned
|
|
149
|
+
def top=(top)
|
|
150
|
+
if !top.nil? && top > 1
|
|
151
|
+
fail ArgumentError, 'invalid value for "top", must be smaller than or equal to 1.'
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if !top.nil? && top < 0
|
|
155
|
+
fail ArgumentError, 'invalid value for "top", must be greater than or equal to 0.'
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
@top = top
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Custom attribute writer method with validation
|
|
162
|
+
# @param [Object] bottom Value to be assigned
|
|
163
|
+
def bottom=(bottom)
|
|
164
|
+
if !bottom.nil? && bottom > 1
|
|
165
|
+
fail ArgumentError, 'invalid value for "bottom", must be smaller than or equal to 1.'
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
if !bottom.nil? && bottom < 0
|
|
169
|
+
fail ArgumentError, 'invalid value for "bottom", must be greater than or equal to 0.'
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
@bottom = bottom
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Custom attribute writer method with validation
|
|
176
|
+
# @param [Object] left Value to be assigned
|
|
177
|
+
def left=(left)
|
|
178
|
+
if !left.nil? && left > 1
|
|
179
|
+
fail ArgumentError, 'invalid value for "left", must be smaller than or equal to 1.'
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
if !left.nil? && left < 0
|
|
183
|
+
fail ArgumentError, 'invalid value for "left", must be greater than or equal to 0.'
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
@left = left
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Custom attribute writer method with validation
|
|
190
|
+
# @param [Object] right Value to be assigned
|
|
191
|
+
def right=(right)
|
|
192
|
+
if !right.nil? && right > 1
|
|
193
|
+
fail ArgumentError, 'invalid value for "right", must be smaller than or equal to 1.'
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
if !right.nil? && right < 0
|
|
197
|
+
fail ArgumentError, 'invalid value for "right", must be greater than or equal to 0.'
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
@right = right
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Checks equality by comparing each attribute.
|
|
204
|
+
# @param [Object] Object to be compared
|
|
205
|
+
def ==(o)
|
|
206
|
+
return true if self.equal?(o)
|
|
207
|
+
self.class == o.class &&
|
|
208
|
+
top == o.top &&
|
|
209
|
+
bottom == o.bottom &&
|
|
210
|
+
left == o.left &&
|
|
211
|
+
right == o.right
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# @see the `==` method
|
|
215
|
+
# @param [Object] Object to be compared
|
|
216
|
+
def eql?(o)
|
|
217
|
+
self == o
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Calculates hash code according to all attributes.
|
|
221
|
+
# @return [Integer] Hash code
|
|
222
|
+
def hash
|
|
223
|
+
[top, bottom, left, right].hash
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Builds the object from hash
|
|
227
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
228
|
+
# @return [Object] Returns the model itself
|
|
229
|
+
def self.build_from_hash(attributes)
|
|
230
|
+
new.build_from_hash(attributes)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Builds the object from hash
|
|
234
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
235
|
+
# @return [Object] Returns the model itself
|
|
236
|
+
def build_from_hash(attributes)
|
|
237
|
+
return nil unless attributes.is_a?(Hash)
|
|
238
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
239
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
240
|
+
self.send("#{key}=", nil)
|
|
241
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
242
|
+
# check to ensure the input is an array given that the attribute
|
|
243
|
+
# is documented as an array but the input is not
|
|
244
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
245
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
246
|
+
end
|
|
247
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
248
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
self
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Deserializes the data based on type
|
|
256
|
+
# @param string type Data type
|
|
257
|
+
# @param string value Value to be deserialized
|
|
258
|
+
# @return [Object] Deserialized data
|
|
259
|
+
def _deserialize(type, value)
|
|
260
|
+
case type.to_sym
|
|
261
|
+
when :Time
|
|
262
|
+
Time.parse(value)
|
|
263
|
+
when :Date
|
|
264
|
+
Date.parse(value)
|
|
265
|
+
when :String
|
|
266
|
+
value.to_s
|
|
267
|
+
when :Integer
|
|
268
|
+
value.to_i
|
|
269
|
+
when :Float
|
|
270
|
+
value.to_f
|
|
271
|
+
when :Boolean
|
|
272
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
273
|
+
true
|
|
274
|
+
else
|
|
275
|
+
false
|
|
276
|
+
end
|
|
277
|
+
when :Object
|
|
278
|
+
# generic object (usually a Hash), return directly
|
|
279
|
+
value
|
|
280
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
281
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
282
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
283
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
284
|
+
k_type = Regexp.last_match[:k_type]
|
|
285
|
+
v_type = Regexp.last_match[:v_type]
|
|
286
|
+
{}.tap do |hash|
|
|
287
|
+
value.each do |k, v|
|
|
288
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
else # model
|
|
292
|
+
# models (e.g. Pet) or oneOf
|
|
293
|
+
klass = Shotstack.const_get(type)
|
|
294
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Returns the string representation of the object
|
|
299
|
+
# @return [String] String presentation of the object
|
|
300
|
+
def to_s
|
|
301
|
+
to_hash.to_s
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
305
|
+
# @return [Hash] Returns the object in the form of hash
|
|
306
|
+
def to_body
|
|
307
|
+
to_hash
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Returns the object in the form of hash
|
|
311
|
+
# @return [Hash] Returns the object in the form of hash
|
|
312
|
+
def to_hash
|
|
313
|
+
hash = {}
|
|
314
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
315
|
+
value = self.send(attr)
|
|
316
|
+
if value.nil?
|
|
317
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
318
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
hash[param] = _to_hash(value)
|
|
322
|
+
end
|
|
323
|
+
hash
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Outputs non-array value in the form of hash
|
|
327
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
328
|
+
# @param [Object] value Any valid value
|
|
329
|
+
# @return [Hash] Returns the value in the form of hash
|
|
330
|
+
def _to_hash(value)
|
|
331
|
+
if value.is_a?(Array)
|
|
332
|
+
value.compact.map { |v| _to_hash(v) }
|
|
333
|
+
elsif value.is_a?(Hash)
|
|
334
|
+
{}.tap do |hash|
|
|
335
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
336
|
+
end
|
|
337
|
+
elsif value.respond_to? :to_hash
|
|
338
|
+
value.to_hash
|
|
339
|
+
else
|
|
340
|
+
value
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
end
|