shotstack 0.0.9 → 0.1.2
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 +5 -5
- data/README.md +17 -0
- data/lib/shotstack.rb +31 -15
- data/lib/shotstack/api/endpoints_api.rb +149 -0
- data/lib/shotstack/api_client.rb +142 -74
- data/lib/shotstack/api_error.rb +38 -5
- data/lib/shotstack/configuration.rb +93 -5
- data/lib/shotstack/models/asset.rb +17 -0
- data/lib/shotstack/models/audio_asset.rb +251 -0
- data/lib/shotstack/models/clip.rb +395 -0
- data/lib/shotstack/models/edit.rb +121 -42
- data/lib/shotstack/models/font.rb +213 -0
- data/lib/shotstack/models/html_asset.rb +319 -0
- data/lib/shotstack/models/image_asset.rb +231 -0
- data/lib/shotstack/models/luma_asset.rb +241 -0
- data/lib/shotstack/models/offset.rb +266 -0
- data/lib/shotstack/models/output.rb +207 -46
- data/lib/shotstack/models/poster.rb +213 -0
- data/lib/shotstack/models/queued_response.rb +121 -49
- data/lib/shotstack/models/queued_response_data.rb +116 -46
- data/lib/shotstack/models/render_response.rb +121 -49
- data/lib/shotstack/models/render_response_data.rb +193 -69
- data/lib/shotstack/models/soundtrack.rb +152 -42
- data/lib/shotstack/models/thumbnail.rb +228 -0
- data/lib/shotstack/models/timeline.rb +124 -45
- data/lib/shotstack/models/title_asset.rb +354 -0
- data/lib/shotstack/models/track.rb +100 -34
- data/lib/shotstack/models/transition.rb +132 -43
- data/lib/shotstack/models/video_asset.rb +251 -0
- data/lib/shotstack/version.rb +13 -1
- data/shotstack.gemspec +23 -16
- metadata +37 -150
- data/lib/shotstack/api/render_api.rb +0 -137
- data/lib/shotstack/models/clips.rb +0 -147
- data/lib/shotstack/models/image_clip.rb +0 -216
- data/lib/shotstack/models/image_clip_options.rb +0 -175
- data/lib/shotstack/models/title_clip.rb +0 -216
- data/lib/shotstack/models/title_clip_options.rb +0 -194
- data/lib/shotstack/models/video_clip.rb +0 -216
- data/lib/shotstack/models/video_clip_options.rb +0 -185
- data/tags +0 -306
|
@@ -1,68 +1,133 @@
|
|
|
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: 4.2.1
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
1
13
|
require 'date'
|
|
2
14
|
|
|
3
15
|
module Shotstack
|
|
4
|
-
#
|
|
16
|
+
# In and out transitions for a clip - i.e. fade in and fade out
|
|
5
17
|
class Transition
|
|
18
|
+
# The transition in
|
|
6
19
|
attr_accessor :_in
|
|
7
20
|
|
|
21
|
+
# The transition out
|
|
8
22
|
attr_accessor :out
|
|
9
23
|
|
|
24
|
+
class EnumAttributeValidator
|
|
25
|
+
attr_reader :datatype
|
|
26
|
+
attr_reader :allowable_values
|
|
27
|
+
|
|
28
|
+
def initialize(datatype, allowable_values)
|
|
29
|
+
@allowable_values = allowable_values.map do |value|
|
|
30
|
+
case datatype.to_s
|
|
31
|
+
when /Integer/i
|
|
32
|
+
value.to_i
|
|
33
|
+
when /Float/i
|
|
34
|
+
value.to_f
|
|
35
|
+
else
|
|
36
|
+
value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def valid?(value)
|
|
42
|
+
!value || allowable_values.include?(value)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
10
46
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
11
47
|
def self.attribute_map
|
|
12
48
|
{
|
|
13
|
-
|
|
14
49
|
:'_in' => :'in',
|
|
15
|
-
|
|
16
50
|
:'out' => :'out'
|
|
17
|
-
|
|
18
51
|
}
|
|
19
52
|
end
|
|
20
53
|
|
|
21
54
|
# Attribute type mapping.
|
|
22
|
-
def self.
|
|
55
|
+
def self.openapi_types
|
|
23
56
|
{
|
|
24
57
|
:'_in' => :'String',
|
|
25
58
|
:'out' => :'String'
|
|
26
|
-
|
|
27
59
|
}
|
|
28
60
|
end
|
|
29
61
|
|
|
62
|
+
# List of attributes with nullable: true
|
|
63
|
+
def self.openapi_nullable
|
|
64
|
+
Set.new([
|
|
65
|
+
])
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Initializes the object
|
|
69
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
30
70
|
def initialize(attributes = {})
|
|
31
|
-
|
|
71
|
+
if (!attributes.is_a?(Hash))
|
|
72
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Transition` initialize method"
|
|
73
|
+
end
|
|
32
74
|
|
|
33
|
-
# convert string to symbol for hash key
|
|
34
|
-
attributes = attributes.
|
|
75
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
76
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
77
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
78
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Transition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
79
|
+
end
|
|
80
|
+
h[k.to_sym] = v
|
|
81
|
+
}
|
|
35
82
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
self._in = attributes[:'in']
|
|
83
|
+
if attributes.key?(:'_in')
|
|
84
|
+
self._in = attributes[:'_in']
|
|
39
85
|
end
|
|
40
|
-
|
|
41
|
-
if attributes
|
|
86
|
+
|
|
87
|
+
if attributes.key?(:'out')
|
|
42
88
|
self.out = attributes[:'out']
|
|
43
89
|
end
|
|
44
|
-
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
93
|
+
# @return Array for valid properties with the reasons
|
|
94
|
+
def list_invalid_properties
|
|
95
|
+
invalid_properties = Array.new
|
|
96
|
+
invalid_properties
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Check to see if the all the properties in the model are valid
|
|
100
|
+
# @return true if the model is valid
|
|
101
|
+
def valid?
|
|
102
|
+
_in_validator = EnumAttributeValidator.new('String', ["fade", "reveal", "wipeLeft", "wipeRight"])
|
|
103
|
+
return false unless _in_validator.valid?(@_in)
|
|
104
|
+
out_validator = EnumAttributeValidator.new('String', ["fade", "reveal", "wipeLeft", "wipeRight"])
|
|
105
|
+
return false unless out_validator.valid?(@out)
|
|
106
|
+
true
|
|
45
107
|
end
|
|
46
108
|
|
|
47
109
|
# Custom attribute writer method checking allowed values (enum).
|
|
110
|
+
# @param [Object] _in Object to be assigned
|
|
48
111
|
def _in=(_in)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
fail "invalid value for
|
|
112
|
+
validator = EnumAttributeValidator.new('String', ["fade", "reveal", "wipeLeft", "wipeRight"])
|
|
113
|
+
unless validator.valid?(_in)
|
|
114
|
+
fail ArgumentError, "invalid value for \"_in\", must be one of #{validator.allowable_values}."
|
|
52
115
|
end
|
|
53
116
|
@_in = _in
|
|
54
117
|
end
|
|
55
118
|
|
|
56
119
|
# Custom attribute writer method checking allowed values (enum).
|
|
120
|
+
# @param [Object] out Object to be assigned
|
|
57
121
|
def out=(out)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
fail "invalid value for
|
|
122
|
+
validator = EnumAttributeValidator.new('String', ["fade", "reveal", "wipeLeft", "wipeRight"])
|
|
123
|
+
unless validator.valid?(out)
|
|
124
|
+
fail ArgumentError, "invalid value for \"out\", must be one of #{validator.allowable_values}."
|
|
61
125
|
end
|
|
62
126
|
@out = out
|
|
63
127
|
end
|
|
64
128
|
|
|
65
|
-
#
|
|
129
|
+
# Checks equality by comparing each attribute.
|
|
130
|
+
# @param [Object] Object to be compared
|
|
66
131
|
def ==(o)
|
|
67
132
|
return true if self.equal?(o)
|
|
68
133
|
self.class == o.class &&
|
|
@@ -71,35 +136,48 @@ module Shotstack
|
|
|
71
136
|
end
|
|
72
137
|
|
|
73
138
|
# @see the `==` method
|
|
139
|
+
# @param [Object] Object to be compared
|
|
74
140
|
def eql?(o)
|
|
75
141
|
self == o
|
|
76
142
|
end
|
|
77
143
|
|
|
78
|
-
#
|
|
144
|
+
# Calculates hash code according to all attributes.
|
|
145
|
+
# @return [Integer] Hash code
|
|
79
146
|
def hash
|
|
80
147
|
[_in, out].hash
|
|
81
148
|
end
|
|
82
149
|
|
|
83
|
-
#
|
|
150
|
+
# Builds the object from hash
|
|
151
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
152
|
+
# @return [Object] Returns the model itself
|
|
153
|
+
def self.build_from_hash(attributes)
|
|
154
|
+
new.build_from_hash(attributes)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Builds the object from hash
|
|
158
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
159
|
+
# @return [Object] Returns the model itself
|
|
84
160
|
def build_from_hash(attributes)
|
|
85
161
|
return nil unless attributes.is_a?(Hash)
|
|
86
|
-
self.class.
|
|
87
|
-
if type =~
|
|
162
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
163
|
+
if type =~ /\AArray<(.*)>/i
|
|
164
|
+
# check to ensure the input is an array given that the attribute
|
|
165
|
+
# is documented as an array but the input is not
|
|
88
166
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
89
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
|
90
|
-
else
|
|
91
|
-
#TODO show warning in debug mode
|
|
167
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
92
168
|
end
|
|
93
169
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
94
170
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
95
|
-
else
|
|
96
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
|
97
|
-
end
|
|
171
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
98
172
|
end
|
|
99
173
|
|
|
100
174
|
self
|
|
101
175
|
end
|
|
102
176
|
|
|
177
|
+
# Deserializes the data based on type
|
|
178
|
+
# @param string type Data type
|
|
179
|
+
# @param string value Value to be deserialized
|
|
180
|
+
# @return [Object] Deserialized data
|
|
103
181
|
def _deserialize(type, value)
|
|
104
182
|
case type.to_sym
|
|
105
183
|
when :DateTime
|
|
@@ -112,16 +190,19 @@ module Shotstack
|
|
|
112
190
|
value.to_i
|
|
113
191
|
when :Float
|
|
114
192
|
value.to_f
|
|
115
|
-
when :
|
|
116
|
-
if value =~
|
|
193
|
+
when :Boolean
|
|
194
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
117
195
|
true
|
|
118
196
|
else
|
|
119
197
|
false
|
|
120
198
|
end
|
|
199
|
+
when :Object
|
|
200
|
+
# generic object (usually a Hash), return directly
|
|
201
|
+
value
|
|
121
202
|
when /\AArray<(?<inner_type>.+)>\z/
|
|
122
203
|
inner_type = Regexp.last_match[:inner_type]
|
|
123
204
|
value.map { |v| _deserialize(inner_type, v) }
|
|
124
|
-
when /\AHash<(?<k_type
|
|
205
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
125
206
|
k_type = Regexp.last_match[:k_type]
|
|
126
207
|
v_type = Regexp.last_match[:v_type]
|
|
127
208
|
{}.tap do |hash|
|
|
@@ -130,36 +211,45 @@ module Shotstack
|
|
|
130
211
|
end
|
|
131
212
|
end
|
|
132
213
|
else # model
|
|
133
|
-
|
|
134
|
-
_model.build_from_hash(value)
|
|
214
|
+
Shotstack.const_get(type).build_from_hash(value)
|
|
135
215
|
end
|
|
136
216
|
end
|
|
137
217
|
|
|
218
|
+
# Returns the string representation of the object
|
|
219
|
+
# @return [String] String presentation of the object
|
|
138
220
|
def to_s
|
|
139
221
|
to_hash.to_s
|
|
140
222
|
end
|
|
141
223
|
|
|
142
|
-
# to_body is an alias to
|
|
224
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
225
|
+
# @return [Hash] Returns the object in the form of hash
|
|
143
226
|
def to_body
|
|
144
227
|
to_hash
|
|
145
228
|
end
|
|
146
229
|
|
|
147
|
-
#
|
|
230
|
+
# Returns the object in the form of hash
|
|
231
|
+
# @return [Hash] Returns the object in the form of hash
|
|
148
232
|
def to_hash
|
|
149
233
|
hash = {}
|
|
150
234
|
self.class.attribute_map.each_pair do |attr, param|
|
|
151
235
|
value = self.send(attr)
|
|
152
|
-
|
|
236
|
+
if value.nil?
|
|
237
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
238
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
239
|
+
end
|
|
240
|
+
|
|
153
241
|
hash[param] = _to_hash(value)
|
|
154
242
|
end
|
|
155
243
|
hash
|
|
156
244
|
end
|
|
157
245
|
|
|
158
|
-
#
|
|
246
|
+
# Outputs non-array value in the form of hash
|
|
159
247
|
# For object, use to_hash. Otherwise, just return the value
|
|
248
|
+
# @param [Object] value Any valid value
|
|
249
|
+
# @return [Hash] Returns the value in the form of hash
|
|
160
250
|
def _to_hash(value)
|
|
161
251
|
if value.is_a?(Array)
|
|
162
|
-
value.compact.map{ |v| _to_hash(v) }
|
|
252
|
+
value.compact.map { |v| _to_hash(v) }
|
|
163
253
|
elsif value.is_a?(Hash)
|
|
164
254
|
{}.tap do |hash|
|
|
165
255
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
@@ -170,6 +260,5 @@ module Shotstack
|
|
|
170
260
|
value
|
|
171
261
|
end
|
|
172
262
|
end
|
|
173
|
-
|
|
174
263
|
end
|
|
175
264
|
end
|
|
@@ -0,0 +1,251 @@
|
|
|
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: 4.2.1
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require_relative 'asset'
|
|
15
|
+
|
|
16
|
+
module Shotstack
|
|
17
|
+
# The VideoAsset is used to create video sequences from video files. The src must be a publicly accessible URL to a video resource such as an mp4 file.
|
|
18
|
+
class VideoAsset < Asset
|
|
19
|
+
# The type of asset - set to <b>video</b> for videos.
|
|
20
|
+
attr_accessor :type
|
|
21
|
+
|
|
22
|
+
# The video source URL. The URL must be publicly accessible or include credentials.
|
|
23
|
+
attr_accessor :src
|
|
24
|
+
|
|
25
|
+
# The start trim point of the video clip, in seconds (defaults to 0). Videos will start from the in trim point. The video will play until the file ends or the Clip length is reached.
|
|
26
|
+
attr_accessor :trim
|
|
27
|
+
|
|
28
|
+
# Set the volume for the video clip between 0 and 1 where 0 is muted and 1 is full volume (defaults to 0).
|
|
29
|
+
attr_accessor :volume
|
|
30
|
+
|
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
32
|
+
def self.attribute_map
|
|
33
|
+
{
|
|
34
|
+
:'type' => :'type',
|
|
35
|
+
:'src' => :'src',
|
|
36
|
+
:'trim' => :'trim',
|
|
37
|
+
:'volume' => :'volume'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Attribute type mapping.
|
|
42
|
+
def self.openapi_types
|
|
43
|
+
{
|
|
44
|
+
:'type' => :'String',
|
|
45
|
+
:'src' => :'String',
|
|
46
|
+
:'trim' => :'Float',
|
|
47
|
+
:'volume' => :'Float'
|
|
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::VideoAsset` 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::VideoAsset`. 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?(:'type')
|
|
73
|
+
self.type = attributes[:'type']
|
|
74
|
+
else
|
|
75
|
+
self.type = 'video'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if attributes.key?(:'src')
|
|
79
|
+
self.src = attributes[:'src']
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if attributes.key?(:'trim')
|
|
83
|
+
self.trim = attributes[:'trim']
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if attributes.key?(:'volume')
|
|
87
|
+
self.volume = attributes[:'volume']
|
|
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
|
+
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 @src.nil?
|
|
100
|
+
invalid_properties.push('invalid value for "src", src cannot be nil.')
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
invalid_properties
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Check to see if the all the properties in the model are valid
|
|
107
|
+
# @return true if the model is valid
|
|
108
|
+
def valid?
|
|
109
|
+
return false if @type.nil?
|
|
110
|
+
return false if @src.nil?
|
|
111
|
+
true
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Checks equality by comparing each attribute.
|
|
115
|
+
# @param [Object] Object to be compared
|
|
116
|
+
def ==(o)
|
|
117
|
+
return true if self.equal?(o)
|
|
118
|
+
self.class == o.class &&
|
|
119
|
+
type == o.type &&
|
|
120
|
+
src == o.src &&
|
|
121
|
+
trim == o.trim &&
|
|
122
|
+
volume == o.volume
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# @see the `==` method
|
|
126
|
+
# @param [Object] Object to be compared
|
|
127
|
+
def eql?(o)
|
|
128
|
+
self == o
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Calculates hash code according to all attributes.
|
|
132
|
+
# @return [Integer] Hash code
|
|
133
|
+
def hash
|
|
134
|
+
[type, src, trim, volume].hash
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Builds the object from hash
|
|
138
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
139
|
+
# @return [Object] Returns the model itself
|
|
140
|
+
def self.build_from_hash(attributes)
|
|
141
|
+
new.build_from_hash(attributes)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Builds the object from hash
|
|
145
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
146
|
+
# @return [Object] Returns the model itself
|
|
147
|
+
def build_from_hash(attributes)
|
|
148
|
+
return nil unless attributes.is_a?(Hash)
|
|
149
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
150
|
+
if type =~ /\AArray<(.*)>/i
|
|
151
|
+
# check to ensure the input is an array given that the attribute
|
|
152
|
+
# is documented as an array but the input is not
|
|
153
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
154
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
155
|
+
end
|
|
156
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
157
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
158
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
self
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Deserializes the data based on type
|
|
165
|
+
# @param string type Data type
|
|
166
|
+
# @param string value Value to be deserialized
|
|
167
|
+
# @return [Object] Deserialized data
|
|
168
|
+
def _deserialize(type, value)
|
|
169
|
+
case type.to_sym
|
|
170
|
+
when :DateTime
|
|
171
|
+
DateTime.parse(value)
|
|
172
|
+
when :Date
|
|
173
|
+
Date.parse(value)
|
|
174
|
+
when :String
|
|
175
|
+
value.to_s
|
|
176
|
+
when :Integer
|
|
177
|
+
value.to_i
|
|
178
|
+
when :Float
|
|
179
|
+
value.to_f
|
|
180
|
+
when :Boolean
|
|
181
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
182
|
+
true
|
|
183
|
+
else
|
|
184
|
+
false
|
|
185
|
+
end
|
|
186
|
+
when :Object
|
|
187
|
+
# generic object (usually a Hash), return directly
|
|
188
|
+
value
|
|
189
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
190
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
191
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
192
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
193
|
+
k_type = Regexp.last_match[:k_type]
|
|
194
|
+
v_type = Regexp.last_match[:v_type]
|
|
195
|
+
{}.tap do |hash|
|
|
196
|
+
value.each do |k, v|
|
|
197
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
else # model
|
|
201
|
+
Shotstack.const_get(type).build_from_hash(value)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Returns the string representation of the object
|
|
206
|
+
# @return [String] String presentation of the object
|
|
207
|
+
def to_s
|
|
208
|
+
to_hash.to_s
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
|
213
|
+
def to_body
|
|
214
|
+
to_hash
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Returns the object in the form of hash
|
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
|
219
|
+
def to_hash
|
|
220
|
+
hash = {}
|
|
221
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
222
|
+
value = self.send(attr)
|
|
223
|
+
if value.nil?
|
|
224
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
225
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
hash[param] = _to_hash(value)
|
|
229
|
+
end
|
|
230
|
+
hash
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Outputs non-array value in the form of hash
|
|
234
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
235
|
+
# @param [Object] value Any valid value
|
|
236
|
+
# @return [Hash] Returns the value in the form of hash
|
|
237
|
+
def _to_hash(value)
|
|
238
|
+
if value.is_a?(Array)
|
|
239
|
+
value.compact.map { |v| _to_hash(v) }
|
|
240
|
+
elsif value.is_a?(Hash)
|
|
241
|
+
{}.tap do |hash|
|
|
242
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
243
|
+
end
|
|
244
|
+
elsif value.respond_to? :to_hash
|
|
245
|
+
value.to_hash
|
|
246
|
+
else
|
|
247
|
+
value
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|