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