shotstack 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +4 -0
- data/lib/shotstack/api/render_api.rb +137 -0
- data/lib/shotstack/api_client.rb +318 -0
- data/lib/shotstack/api_error.rb +24 -0
- data/lib/shotstack/configuration.rb +170 -0
- data/lib/shotstack/models/clips.rb +147 -0
- data/lib/shotstack/models/edit.rb +157 -0
- data/lib/shotstack/models/image_clip.rb +216 -0
- data/lib/shotstack/models/image_clip_options.rb +175 -0
- data/lib/shotstack/models/output.rb +175 -0
- data/lib/shotstack/models/queued_response.rb +167 -0
- data/lib/shotstack/models/queued_response_data.rb +157 -0
- data/lib/shotstack/models/render_response.rb +167 -0
- data/lib/shotstack/models/render_response_data.rb +206 -0
- data/lib/shotstack/models/soundtrack.rb +157 -0
- data/lib/shotstack/models/timeline.rb +169 -0
- data/lib/shotstack/models/title_clip.rb +216 -0
- data/lib/shotstack/models/title_clip_options.rb +194 -0
- data/lib/shotstack/models/track.rb +149 -0
- data/lib/shotstack/models/transition.rb +175 -0
- data/lib/shotstack/models/video_clip.rb +216 -0
- data/lib/shotstack/models/video_clip_options.rb +185 -0
- data/lib/shotstack/version.rb +3 -0
- data/lib/shotstack.rb +45 -0
- data/shotstack.gemspec +32 -0
- data/tags +306 -0
- metadata +250 -0
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for Clips
|
5
|
+
class Clips
|
6
|
+
attr_accessor :name
|
7
|
+
|
8
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
9
|
+
def self.attribute_map
|
10
|
+
{
|
11
|
+
|
12
|
+
:'name' => :'name'
|
13
|
+
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
# Attribute type mapping.
|
18
|
+
def self.swagger_types
|
19
|
+
{
|
20
|
+
:'name' => :'String'
|
21
|
+
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
return unless attributes.is_a?(Hash)
|
27
|
+
|
28
|
+
# convert string to symbol for hash key
|
29
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
30
|
+
|
31
|
+
|
32
|
+
if attributes[:'name']
|
33
|
+
self.name = attributes[:'name']
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# Check equality by comparing each attribute.
|
39
|
+
def ==(o)
|
40
|
+
return true if self.equal?(o)
|
41
|
+
self.class == o.class &&
|
42
|
+
name == o.name
|
43
|
+
end
|
44
|
+
|
45
|
+
# @see the `==` method
|
46
|
+
def eql?(o)
|
47
|
+
self == o
|
48
|
+
end
|
49
|
+
|
50
|
+
# Calculate hash code according to all attributes.
|
51
|
+
def hash
|
52
|
+
[name].hash
|
53
|
+
end
|
54
|
+
|
55
|
+
# build the object from hash
|
56
|
+
def build_from_hash(attributes)
|
57
|
+
return nil unless attributes.is_a?(Hash)
|
58
|
+
self.class.swagger_types.each_pair do |key, type|
|
59
|
+
if type =~ /^Array<(.*)>/i
|
60
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
61
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
62
|
+
else
|
63
|
+
#TODO show warning in debug mode
|
64
|
+
end
|
65
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
66
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
67
|
+
else
|
68
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def _deserialize(type, value)
|
76
|
+
case type.to_sym
|
77
|
+
when :DateTime
|
78
|
+
DateTime.parse(value)
|
79
|
+
when :Date
|
80
|
+
Date.parse(value)
|
81
|
+
when :String
|
82
|
+
value.to_s
|
83
|
+
when :Integer
|
84
|
+
value.to_i
|
85
|
+
when :Float
|
86
|
+
value.to_f
|
87
|
+
when :BOOLEAN
|
88
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
89
|
+
true
|
90
|
+
else
|
91
|
+
false
|
92
|
+
end
|
93
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
94
|
+
inner_type = Regexp.last_match[:inner_type]
|
95
|
+
value.map { |v| _deserialize(inner_type, v) }
|
96
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
97
|
+
k_type = Regexp.last_match[:k_type]
|
98
|
+
v_type = Regexp.last_match[:v_type]
|
99
|
+
{}.tap do |hash|
|
100
|
+
value.each do |k, v|
|
101
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
else # model
|
105
|
+
_model = Shotstack.const_get(type).new
|
106
|
+
_model.build_from_hash(value)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def to_s
|
111
|
+
to_hash.to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
# to_body is an alias to to_body (backward compatibility))
|
115
|
+
def to_body
|
116
|
+
to_hash
|
117
|
+
end
|
118
|
+
|
119
|
+
# return the object in the form of hash
|
120
|
+
def to_hash
|
121
|
+
hash = {}
|
122
|
+
self.class.attribute_map.each_pair do |attr, param|
|
123
|
+
value = self.send(attr)
|
124
|
+
next if value.nil?
|
125
|
+
hash[param] = _to_hash(value)
|
126
|
+
end
|
127
|
+
hash
|
128
|
+
end
|
129
|
+
|
130
|
+
# Method to output non-array value in the form of hash
|
131
|
+
# For object, use to_hash. Otherwise, just return the value
|
132
|
+
def _to_hash(value)
|
133
|
+
if value.is_a?(Array)
|
134
|
+
value.compact.map{ |v| _to_hash(v) }
|
135
|
+
elsif value.is_a?(Hash)
|
136
|
+
{}.tap do |hash|
|
137
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
138
|
+
end
|
139
|
+
elsif value.respond_to? :to_hash
|
140
|
+
value.to_hash
|
141
|
+
else
|
142
|
+
value
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for Edit
|
5
|
+
class Edit
|
6
|
+
attr_accessor :output
|
7
|
+
|
8
|
+
attr_accessor :timeline
|
9
|
+
|
10
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
11
|
+
def self.attribute_map
|
12
|
+
{
|
13
|
+
|
14
|
+
:'output' => :'output',
|
15
|
+
|
16
|
+
:'timeline' => :'timeline'
|
17
|
+
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Attribute type mapping.
|
22
|
+
def self.swagger_types
|
23
|
+
{
|
24
|
+
:'output' => :'Output',
|
25
|
+
:'timeline' => :'Timeline'
|
26
|
+
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(attributes = {})
|
31
|
+
return unless attributes.is_a?(Hash)
|
32
|
+
|
33
|
+
# convert string to symbol for hash key
|
34
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
35
|
+
|
36
|
+
|
37
|
+
if attributes[:'output']
|
38
|
+
self.output = attributes[:'output']
|
39
|
+
end
|
40
|
+
|
41
|
+
if attributes[:'timeline']
|
42
|
+
self.timeline = attributes[:'timeline']
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# Check equality by comparing each attribute.
|
48
|
+
def ==(o)
|
49
|
+
return true if self.equal?(o)
|
50
|
+
self.class == o.class &&
|
51
|
+
output == o.output &&
|
52
|
+
timeline == o.timeline
|
53
|
+
end
|
54
|
+
|
55
|
+
# @see the `==` method
|
56
|
+
def eql?(o)
|
57
|
+
self == o
|
58
|
+
end
|
59
|
+
|
60
|
+
# Calculate hash code according to all attributes.
|
61
|
+
def hash
|
62
|
+
[output, timeline].hash
|
63
|
+
end
|
64
|
+
|
65
|
+
# build the object from hash
|
66
|
+
def build_from_hash(attributes)
|
67
|
+
return nil unless attributes.is_a?(Hash)
|
68
|
+
self.class.swagger_types.each_pair do |key, type|
|
69
|
+
if type =~ /^Array<(.*)>/i
|
70
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
71
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
72
|
+
else
|
73
|
+
#TODO show warning in debug mode
|
74
|
+
end
|
75
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
76
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
77
|
+
else
|
78
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
self
|
83
|
+
end
|
84
|
+
|
85
|
+
def _deserialize(type, value)
|
86
|
+
case type.to_sym
|
87
|
+
when :DateTime
|
88
|
+
DateTime.parse(value)
|
89
|
+
when :Date
|
90
|
+
Date.parse(value)
|
91
|
+
when :String
|
92
|
+
value.to_s
|
93
|
+
when :Integer
|
94
|
+
value.to_i
|
95
|
+
when :Float
|
96
|
+
value.to_f
|
97
|
+
when :BOOLEAN
|
98
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
99
|
+
true
|
100
|
+
else
|
101
|
+
false
|
102
|
+
end
|
103
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
104
|
+
inner_type = Regexp.last_match[:inner_type]
|
105
|
+
value.map { |v| _deserialize(inner_type, v) }
|
106
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
107
|
+
k_type = Regexp.last_match[:k_type]
|
108
|
+
v_type = Regexp.last_match[:v_type]
|
109
|
+
{}.tap do |hash|
|
110
|
+
value.each do |k, v|
|
111
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
else # model
|
115
|
+
_model = Shotstack.const_get(type).new
|
116
|
+
_model.build_from_hash(value)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_s
|
121
|
+
to_hash.to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
# to_body is an alias to to_body (backward compatibility))
|
125
|
+
def to_body
|
126
|
+
to_hash
|
127
|
+
end
|
128
|
+
|
129
|
+
# return the object in the form of hash
|
130
|
+
def to_hash
|
131
|
+
hash = {}
|
132
|
+
self.class.attribute_map.each_pair do |attr, param|
|
133
|
+
value = self.send(attr)
|
134
|
+
next if value.nil?
|
135
|
+
hash[param] = _to_hash(value)
|
136
|
+
end
|
137
|
+
hash
|
138
|
+
end
|
139
|
+
|
140
|
+
# Method to output non-array value in the form of hash
|
141
|
+
# For object, use to_hash. Otherwise, just return the value
|
142
|
+
def _to_hash(value)
|
143
|
+
if value.is_a?(Array)
|
144
|
+
value.compact.map{ |v| _to_hash(v) }
|
145
|
+
elsif value.is_a?(Hash)
|
146
|
+
{}.tap do |hash|
|
147
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
148
|
+
end
|
149
|
+
elsif value.respond_to? :to_hash
|
150
|
+
value.to_hash
|
151
|
+
else
|
152
|
+
value
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for ImageClip
|
5
|
+
class ImageClip
|
6
|
+
attr_accessor :_in
|
7
|
+
|
8
|
+
attr_accessor :options
|
9
|
+
|
10
|
+
attr_accessor :out
|
11
|
+
|
12
|
+
attr_accessor :src
|
13
|
+
|
14
|
+
attr_accessor :start
|
15
|
+
|
16
|
+
attr_accessor :transition
|
17
|
+
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
|
24
|
+
:'_in' => :'in',
|
25
|
+
|
26
|
+
:'options' => :'options',
|
27
|
+
|
28
|
+
:'out' => :'out',
|
29
|
+
|
30
|
+
:'src' => :'src',
|
31
|
+
|
32
|
+
:'start' => :'start',
|
33
|
+
|
34
|
+
:'transition' => :'transition',
|
35
|
+
|
36
|
+
:'type' => :'type'
|
37
|
+
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Attribute type mapping.
|
42
|
+
def self.swagger_types
|
43
|
+
{
|
44
|
+
:'_in' => :'Float',
|
45
|
+
:'options' => :'ImageClipOptions',
|
46
|
+
:'out' => :'Float',
|
47
|
+
:'src' => :'String',
|
48
|
+
:'start' => :'Float',
|
49
|
+
:'transition' => :'Transition',
|
50
|
+
:'type' => :'String'
|
51
|
+
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(attributes = {})
|
56
|
+
return unless attributes.is_a?(Hash)
|
57
|
+
|
58
|
+
# convert string to symbol for hash key
|
59
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
60
|
+
|
61
|
+
|
62
|
+
if attributes[:'in']
|
63
|
+
self._in = attributes[:'in']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes[:'options']
|
67
|
+
self.options = attributes[:'options']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes[:'out']
|
71
|
+
self.out = attributes[:'out']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes[:'src']
|
75
|
+
self.src = attributes[:'src']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes[:'start']
|
79
|
+
self.start = attributes[:'start']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes[:'transition']
|
83
|
+
self.transition = attributes[:'transition']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes[:'type']
|
87
|
+
self.type = attributes[:'type']
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
# Custom attribute writer method checking allowed values (enum).
|
93
|
+
def type=(type)
|
94
|
+
allowed_values = ["image"]
|
95
|
+
if type && !allowed_values.include?(type)
|
96
|
+
fail "invalid value for 'type', must be one of #{allowed_values}"
|
97
|
+
end
|
98
|
+
@type = type
|
99
|
+
end
|
100
|
+
|
101
|
+
# Check equality by comparing each attribute.
|
102
|
+
def ==(o)
|
103
|
+
return true if self.equal?(o)
|
104
|
+
self.class == o.class &&
|
105
|
+
_in == o._in &&
|
106
|
+
options == o.options &&
|
107
|
+
out == o.out &&
|
108
|
+
src == o.src &&
|
109
|
+
start == o.start &&
|
110
|
+
transition == o.transition &&
|
111
|
+
type == o.type
|
112
|
+
end
|
113
|
+
|
114
|
+
# @see the `==` method
|
115
|
+
def eql?(o)
|
116
|
+
self == o
|
117
|
+
end
|
118
|
+
|
119
|
+
# Calculate hash code according to all attributes.
|
120
|
+
def hash
|
121
|
+
[_in, options, out, src, start, transition, type].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# build the object from hash
|
125
|
+
def build_from_hash(attributes)
|
126
|
+
return nil unless attributes.is_a?(Hash)
|
127
|
+
self.class.swagger_types.each_pair do |key, type|
|
128
|
+
if type =~ /^Array<(.*)>/i
|
129
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
130
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
131
|
+
else
|
132
|
+
#TODO show warning in debug mode
|
133
|
+
end
|
134
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
135
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
136
|
+
else
|
137
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
def _deserialize(type, value)
|
145
|
+
case type.to_sym
|
146
|
+
when :DateTime
|
147
|
+
DateTime.parse(value)
|
148
|
+
when :Date
|
149
|
+
Date.parse(value)
|
150
|
+
when :String
|
151
|
+
value.to_s
|
152
|
+
when :Integer
|
153
|
+
value.to_i
|
154
|
+
when :Float
|
155
|
+
value.to_f
|
156
|
+
when :BOOLEAN
|
157
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
158
|
+
true
|
159
|
+
else
|
160
|
+
false
|
161
|
+
end
|
162
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
163
|
+
inner_type = Regexp.last_match[:inner_type]
|
164
|
+
value.map { |v| _deserialize(inner_type, v) }
|
165
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
166
|
+
k_type = Regexp.last_match[:k_type]
|
167
|
+
v_type = Regexp.last_match[:v_type]
|
168
|
+
{}.tap do |hash|
|
169
|
+
value.each do |k, v|
|
170
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
else # model
|
174
|
+
_model = Shotstack.const_get(type).new
|
175
|
+
_model.build_from_hash(value)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def to_s
|
180
|
+
to_hash.to_s
|
181
|
+
end
|
182
|
+
|
183
|
+
# to_body is an alias to to_body (backward compatibility))
|
184
|
+
def to_body
|
185
|
+
to_hash
|
186
|
+
end
|
187
|
+
|
188
|
+
# return the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
next if value.nil?
|
194
|
+
hash[param] = _to_hash(value)
|
195
|
+
end
|
196
|
+
hash
|
197
|
+
end
|
198
|
+
|
199
|
+
# Method to output non-array value in the form of hash
|
200
|
+
# For object, use to_hash. Otherwise, just return the value
|
201
|
+
def _to_hash(value)
|
202
|
+
if value.is_a?(Array)
|
203
|
+
value.compact.map{ |v| _to_hash(v) }
|
204
|
+
elsif value.is_a?(Hash)
|
205
|
+
{}.tap do |hash|
|
206
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
207
|
+
end
|
208
|
+
elsif value.respond_to? :to_hash
|
209
|
+
value.to_hash
|
210
|
+
else
|
211
|
+
value
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for ImageClipOptions
|
5
|
+
class ImageClipOptions
|
6
|
+
attr_accessor :effect
|
7
|
+
|
8
|
+
attr_accessor :filter
|
9
|
+
|
10
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
11
|
+
def self.attribute_map
|
12
|
+
{
|
13
|
+
|
14
|
+
:'effect' => :'effect',
|
15
|
+
|
16
|
+
:'filter' => :'filter'
|
17
|
+
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Attribute type mapping.
|
22
|
+
def self.swagger_types
|
23
|
+
{
|
24
|
+
:'effect' => :'String',
|
25
|
+
:'filter' => :'String'
|
26
|
+
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(attributes = {})
|
31
|
+
return unless attributes.is_a?(Hash)
|
32
|
+
|
33
|
+
# convert string to symbol for hash key
|
34
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
35
|
+
|
36
|
+
|
37
|
+
if attributes[:'effect']
|
38
|
+
self.effect = attributes[:'effect']
|
39
|
+
end
|
40
|
+
|
41
|
+
if attributes[:'filter']
|
42
|
+
self.filter = attributes[:'filter']
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# Custom attribute writer method checking allowed values (enum).
|
48
|
+
def effect=(effect)
|
49
|
+
allowed_values = ["zoomIn", "zoomOut", "slideLeft", "slideRight", "slideUp", "slideDown"]
|
50
|
+
if effect && !allowed_values.include?(effect)
|
51
|
+
fail "invalid value for 'effect', must be one of #{allowed_values}"
|
52
|
+
end
|
53
|
+
@effect = effect
|
54
|
+
end
|
55
|
+
|
56
|
+
# Custom attribute writer method checking allowed values (enum).
|
57
|
+
def filter=(filter)
|
58
|
+
allowed_values = ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"]
|
59
|
+
if filter && !allowed_values.include?(filter)
|
60
|
+
fail "invalid value for 'filter', must be one of #{allowed_values}"
|
61
|
+
end
|
62
|
+
@filter = filter
|
63
|
+
end
|
64
|
+
|
65
|
+
# Check equality by comparing each attribute.
|
66
|
+
def ==(o)
|
67
|
+
return true if self.equal?(o)
|
68
|
+
self.class == o.class &&
|
69
|
+
effect == o.effect &&
|
70
|
+
filter == o.filter
|
71
|
+
end
|
72
|
+
|
73
|
+
# @see the `==` method
|
74
|
+
def eql?(o)
|
75
|
+
self == o
|
76
|
+
end
|
77
|
+
|
78
|
+
# Calculate hash code according to all attributes.
|
79
|
+
def hash
|
80
|
+
[effect, filter].hash
|
81
|
+
end
|
82
|
+
|
83
|
+
# build the object from hash
|
84
|
+
def build_from_hash(attributes)
|
85
|
+
return nil unless attributes.is_a?(Hash)
|
86
|
+
self.class.swagger_types.each_pair do |key, type|
|
87
|
+
if type =~ /^Array<(.*)>/i
|
88
|
+
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
|
92
|
+
end
|
93
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
94
|
+
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
|
98
|
+
end
|
99
|
+
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
def _deserialize(type, value)
|
104
|
+
case type.to_sym
|
105
|
+
when :DateTime
|
106
|
+
DateTime.parse(value)
|
107
|
+
when :Date
|
108
|
+
Date.parse(value)
|
109
|
+
when :String
|
110
|
+
value.to_s
|
111
|
+
when :Integer
|
112
|
+
value.to_i
|
113
|
+
when :Float
|
114
|
+
value.to_f
|
115
|
+
when :BOOLEAN
|
116
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
117
|
+
true
|
118
|
+
else
|
119
|
+
false
|
120
|
+
end
|
121
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
122
|
+
inner_type = Regexp.last_match[:inner_type]
|
123
|
+
value.map { |v| _deserialize(inner_type, v) }
|
124
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
125
|
+
k_type = Regexp.last_match[:k_type]
|
126
|
+
v_type = Regexp.last_match[:v_type]
|
127
|
+
{}.tap do |hash|
|
128
|
+
value.each do |k, v|
|
129
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
else # model
|
133
|
+
_model = Shotstack.const_get(type).new
|
134
|
+
_model.build_from_hash(value)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_s
|
139
|
+
to_hash.to_s
|
140
|
+
end
|
141
|
+
|
142
|
+
# to_body is an alias to to_body (backward compatibility))
|
143
|
+
def to_body
|
144
|
+
to_hash
|
145
|
+
end
|
146
|
+
|
147
|
+
# return the object in the form of hash
|
148
|
+
def to_hash
|
149
|
+
hash = {}
|
150
|
+
self.class.attribute_map.each_pair do |attr, param|
|
151
|
+
value = self.send(attr)
|
152
|
+
next if value.nil?
|
153
|
+
hash[param] = _to_hash(value)
|
154
|
+
end
|
155
|
+
hash
|
156
|
+
end
|
157
|
+
|
158
|
+
# Method to output non-array value in the form of hash
|
159
|
+
# For object, use to_hash. Otherwise, just return the value
|
160
|
+
def _to_hash(value)
|
161
|
+
if value.is_a?(Array)
|
162
|
+
value.compact.map{ |v| _to_hash(v) }
|
163
|
+
elsif value.is_a?(Hash)
|
164
|
+
{}.tap do |hash|
|
165
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
166
|
+
end
|
167
|
+
elsif value.respond_to? :to_hash
|
168
|
+
value.to_hash
|
169
|
+
else
|
170
|
+
value
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
end
|