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,175 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for Output
|
5
|
+
class Output
|
6
|
+
attr_accessor :format
|
7
|
+
|
8
|
+
attr_accessor :resolution
|
9
|
+
|
10
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
11
|
+
def self.attribute_map
|
12
|
+
{
|
13
|
+
|
14
|
+
:'format' => :'format',
|
15
|
+
|
16
|
+
:'resolution' => :'resolution'
|
17
|
+
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Attribute type mapping.
|
22
|
+
def self.swagger_types
|
23
|
+
{
|
24
|
+
:'format' => :'String',
|
25
|
+
:'resolution' => :'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[:'format']
|
38
|
+
self.format = attributes[:'format']
|
39
|
+
end
|
40
|
+
|
41
|
+
if attributes[:'resolution']
|
42
|
+
self.resolution = attributes[:'resolution']
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# Custom attribute writer method checking allowed values (enum).
|
48
|
+
def format=(format)
|
49
|
+
allowed_values = ["mp4", "gif"]
|
50
|
+
if format && !allowed_values.include?(format)
|
51
|
+
fail "invalid value for 'format', must be one of #{allowed_values}"
|
52
|
+
end
|
53
|
+
@format = format
|
54
|
+
end
|
55
|
+
|
56
|
+
# Custom attribute writer method checking allowed values (enum).
|
57
|
+
def resolution=(resolution)
|
58
|
+
allowed_values = ["preview", "mobile", "sd", "hd", "1080"]
|
59
|
+
if resolution && !allowed_values.include?(resolution)
|
60
|
+
fail "invalid value for 'resolution', must be one of #{allowed_values}"
|
61
|
+
end
|
62
|
+
@resolution = resolution
|
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
|
+
format == o.format &&
|
70
|
+
resolution == o.resolution
|
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
|
+
[format, resolution].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
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for QueuedResponse
|
5
|
+
class QueuedResponse
|
6
|
+
attr_accessor :message
|
7
|
+
|
8
|
+
attr_accessor :response
|
9
|
+
|
10
|
+
attr_accessor :success
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
|
16
|
+
:'message' => :'message',
|
17
|
+
|
18
|
+
:'response' => :'response',
|
19
|
+
|
20
|
+
:'success' => :'success'
|
21
|
+
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attribute type mapping.
|
26
|
+
def self.swagger_types
|
27
|
+
{
|
28
|
+
:'message' => :'String',
|
29
|
+
:'response' => :'QueuedResponseData',
|
30
|
+
:'success' => :'BOOLEAN'
|
31
|
+
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(attributes = {})
|
36
|
+
return unless attributes.is_a?(Hash)
|
37
|
+
|
38
|
+
# convert string to symbol for hash key
|
39
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
40
|
+
|
41
|
+
|
42
|
+
if attributes[:'message']
|
43
|
+
self.message = attributes[:'message']
|
44
|
+
end
|
45
|
+
|
46
|
+
if attributes[:'response']
|
47
|
+
self.response = attributes[:'response']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes[:'success']
|
51
|
+
self.success = attributes[:'success']
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Check equality by comparing each attribute.
|
57
|
+
def ==(o)
|
58
|
+
return true if self.equal?(o)
|
59
|
+
self.class == o.class &&
|
60
|
+
message == o.message &&
|
61
|
+
response == o.response &&
|
62
|
+
success == o.success
|
63
|
+
end
|
64
|
+
|
65
|
+
# @see the `==` method
|
66
|
+
def eql?(o)
|
67
|
+
self == o
|
68
|
+
end
|
69
|
+
|
70
|
+
# Calculate hash code according to all attributes.
|
71
|
+
def hash
|
72
|
+
[message, response, success].hash
|
73
|
+
end
|
74
|
+
|
75
|
+
# build the object from hash
|
76
|
+
def build_from_hash(attributes)
|
77
|
+
return nil unless attributes.is_a?(Hash)
|
78
|
+
self.class.swagger_types.each_pair do |key, type|
|
79
|
+
if type =~ /^Array<(.*)>/i
|
80
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
81
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
82
|
+
else
|
83
|
+
#TODO show warning in debug mode
|
84
|
+
end
|
85
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
86
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
87
|
+
else
|
88
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def _deserialize(type, value)
|
96
|
+
case type.to_sym
|
97
|
+
when :DateTime
|
98
|
+
DateTime.parse(value)
|
99
|
+
when :Date
|
100
|
+
Date.parse(value)
|
101
|
+
when :String
|
102
|
+
value.to_s
|
103
|
+
when :Integer
|
104
|
+
value.to_i
|
105
|
+
when :Float
|
106
|
+
value.to_f
|
107
|
+
when :BOOLEAN
|
108
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
109
|
+
true
|
110
|
+
else
|
111
|
+
false
|
112
|
+
end
|
113
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
114
|
+
inner_type = Regexp.last_match[:inner_type]
|
115
|
+
value.map { |v| _deserialize(inner_type, v) }
|
116
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
117
|
+
k_type = Regexp.last_match[:k_type]
|
118
|
+
v_type = Regexp.last_match[:v_type]
|
119
|
+
{}.tap do |hash|
|
120
|
+
value.each do |k, v|
|
121
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
else # model
|
125
|
+
_model = Shotstack.const_get(type).new
|
126
|
+
_model.build_from_hash(value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_s
|
131
|
+
to_hash.to_s
|
132
|
+
end
|
133
|
+
|
134
|
+
# to_body is an alias to to_body (backward compatibility))
|
135
|
+
def to_body
|
136
|
+
to_hash
|
137
|
+
end
|
138
|
+
|
139
|
+
# return the object in the form of hash
|
140
|
+
def to_hash
|
141
|
+
hash = {}
|
142
|
+
self.class.attribute_map.each_pair do |attr, param|
|
143
|
+
value = self.send(attr)
|
144
|
+
next if value.nil?
|
145
|
+
hash[param] = _to_hash(value)
|
146
|
+
end
|
147
|
+
hash
|
148
|
+
end
|
149
|
+
|
150
|
+
# Method to output non-array value in the form of hash
|
151
|
+
# For object, use to_hash. Otherwise, just return the value
|
152
|
+
def _to_hash(value)
|
153
|
+
if value.is_a?(Array)
|
154
|
+
value.compact.map{ |v| _to_hash(v) }
|
155
|
+
elsif value.is_a?(Hash)
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
158
|
+
end
|
159
|
+
elsif value.respond_to? :to_hash
|
160
|
+
value.to_hash
|
161
|
+
else
|
162
|
+
value
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for QueuedResponseData
|
5
|
+
class QueuedResponseData
|
6
|
+
attr_accessor :id
|
7
|
+
|
8
|
+
attr_accessor :message
|
9
|
+
|
10
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
11
|
+
def self.attribute_map
|
12
|
+
{
|
13
|
+
|
14
|
+
:'id' => :'id',
|
15
|
+
|
16
|
+
:'message' => :'message'
|
17
|
+
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Attribute type mapping.
|
22
|
+
def self.swagger_types
|
23
|
+
{
|
24
|
+
:'id' => :'String',
|
25
|
+
:'message' => :'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[:'id']
|
38
|
+
self.id = attributes[:'id']
|
39
|
+
end
|
40
|
+
|
41
|
+
if attributes[:'message']
|
42
|
+
self.message = attributes[:'message']
|
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
|
+
id == o.id &&
|
52
|
+
message == o.message
|
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
|
+
[id, message].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,167 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Shotstack
|
4
|
+
# Model for RenderResponse
|
5
|
+
class RenderResponse
|
6
|
+
attr_accessor :message
|
7
|
+
|
8
|
+
attr_accessor :response
|
9
|
+
|
10
|
+
attr_accessor :success
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
|
16
|
+
:'message' => :'message',
|
17
|
+
|
18
|
+
:'response' => :'response',
|
19
|
+
|
20
|
+
:'success' => :'success'
|
21
|
+
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attribute type mapping.
|
26
|
+
def self.swagger_types
|
27
|
+
{
|
28
|
+
:'message' => :'String',
|
29
|
+
:'response' => :'RenderResponseData',
|
30
|
+
:'success' => :'BOOLEAN'
|
31
|
+
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(attributes = {})
|
36
|
+
return unless attributes.is_a?(Hash)
|
37
|
+
|
38
|
+
# convert string to symbol for hash key
|
39
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
40
|
+
|
41
|
+
|
42
|
+
if attributes[:'message']
|
43
|
+
self.message = attributes[:'message']
|
44
|
+
end
|
45
|
+
|
46
|
+
if attributes[:'response']
|
47
|
+
self.response = attributes[:'response']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes[:'success']
|
51
|
+
self.success = attributes[:'success']
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Check equality by comparing each attribute.
|
57
|
+
def ==(o)
|
58
|
+
return true if self.equal?(o)
|
59
|
+
self.class == o.class &&
|
60
|
+
message == o.message &&
|
61
|
+
response == o.response &&
|
62
|
+
success == o.success
|
63
|
+
end
|
64
|
+
|
65
|
+
# @see the `==` method
|
66
|
+
def eql?(o)
|
67
|
+
self == o
|
68
|
+
end
|
69
|
+
|
70
|
+
# Calculate hash code according to all attributes.
|
71
|
+
def hash
|
72
|
+
[message, response, success].hash
|
73
|
+
end
|
74
|
+
|
75
|
+
# build the object from hash
|
76
|
+
def build_from_hash(attributes)
|
77
|
+
return nil unless attributes.is_a?(Hash)
|
78
|
+
self.class.swagger_types.each_pair do |key, type|
|
79
|
+
if type =~ /^Array<(.*)>/i
|
80
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
81
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
82
|
+
else
|
83
|
+
#TODO show warning in debug mode
|
84
|
+
end
|
85
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
86
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
87
|
+
else
|
88
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def _deserialize(type, value)
|
96
|
+
case type.to_sym
|
97
|
+
when :DateTime
|
98
|
+
DateTime.parse(value)
|
99
|
+
when :Date
|
100
|
+
Date.parse(value)
|
101
|
+
when :String
|
102
|
+
value.to_s
|
103
|
+
when :Integer
|
104
|
+
value.to_i
|
105
|
+
when :Float
|
106
|
+
value.to_f
|
107
|
+
when :BOOLEAN
|
108
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
109
|
+
true
|
110
|
+
else
|
111
|
+
false
|
112
|
+
end
|
113
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
114
|
+
inner_type = Regexp.last_match[:inner_type]
|
115
|
+
value.map { |v| _deserialize(inner_type, v) }
|
116
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
117
|
+
k_type = Regexp.last_match[:k_type]
|
118
|
+
v_type = Regexp.last_match[:v_type]
|
119
|
+
{}.tap do |hash|
|
120
|
+
value.each do |k, v|
|
121
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
else # model
|
125
|
+
_model = Shotstack.const_get(type).new
|
126
|
+
_model.build_from_hash(value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_s
|
131
|
+
to_hash.to_s
|
132
|
+
end
|
133
|
+
|
134
|
+
# to_body is an alias to to_body (backward compatibility))
|
135
|
+
def to_body
|
136
|
+
to_hash
|
137
|
+
end
|
138
|
+
|
139
|
+
# return the object in the form of hash
|
140
|
+
def to_hash
|
141
|
+
hash = {}
|
142
|
+
self.class.attribute_map.each_pair do |attr, param|
|
143
|
+
value = self.send(attr)
|
144
|
+
next if value.nil?
|
145
|
+
hash[param] = _to_hash(value)
|
146
|
+
end
|
147
|
+
hash
|
148
|
+
end
|
149
|
+
|
150
|
+
# Method to output non-array value in the form of hash
|
151
|
+
# For object, use to_hash. Otherwise, just return the value
|
152
|
+
def _to_hash(value)
|
153
|
+
if value.is_a?(Array)
|
154
|
+
value.compact.map{ |v| _to_hash(v) }
|
155
|
+
elsif value.is_a?(Hash)
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
158
|
+
end
|
159
|
+
elsif value.respond_to? :to_hash
|
160
|
+
value.to_hash
|
161
|
+
else
|
162
|
+
value
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|