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
|
@@ -0,0 +1,213 @@
|
|
|
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
|
+
|
|
15
|
+
module Shotstack
|
|
16
|
+
# Download a custom font to use with the HTML asset type, using the font name in the CSS or font tag.
|
|
17
|
+
class Font
|
|
18
|
+
# The URL of the font file. The URL must be publicly accessible or include credentials.
|
|
19
|
+
attr_accessor :src
|
|
20
|
+
|
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
22
|
+
def self.attribute_map
|
|
23
|
+
{
|
|
24
|
+
:'src' => :'src'
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Attribute type mapping.
|
|
29
|
+
def self.openapi_types
|
|
30
|
+
{
|
|
31
|
+
:'src' => :'String'
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# List of attributes with nullable: true
|
|
36
|
+
def self.openapi_nullable
|
|
37
|
+
Set.new([
|
|
38
|
+
])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Initializes the object
|
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
43
|
+
def initialize(attributes = {})
|
|
44
|
+
if (!attributes.is_a?(Hash))
|
|
45
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Font` initialize method"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
51
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Font`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
52
|
+
end
|
|
53
|
+
h[k.to_sym] = v
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if attributes.key?(:'src')
|
|
57
|
+
self.src = attributes[:'src']
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
62
|
+
# @return Array for valid properties with the reasons
|
|
63
|
+
def list_invalid_properties
|
|
64
|
+
invalid_properties = Array.new
|
|
65
|
+
if @src.nil?
|
|
66
|
+
invalid_properties.push('invalid value for "src", src cannot be nil.')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
invalid_properties
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Check to see if the all the properties in the model are valid
|
|
73
|
+
# @return true if the model is valid
|
|
74
|
+
def valid?
|
|
75
|
+
return false if @src.nil?
|
|
76
|
+
true
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Checks equality by comparing each attribute.
|
|
80
|
+
# @param [Object] Object to be compared
|
|
81
|
+
def ==(o)
|
|
82
|
+
return true if self.equal?(o)
|
|
83
|
+
self.class == o.class &&
|
|
84
|
+
src == o.src
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @see the `==` method
|
|
88
|
+
# @param [Object] Object to be compared
|
|
89
|
+
def eql?(o)
|
|
90
|
+
self == o
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Calculates hash code according to all attributes.
|
|
94
|
+
# @return [Integer] Hash code
|
|
95
|
+
def hash
|
|
96
|
+
[src].hash
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Builds the object from hash
|
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
101
|
+
# @return [Object] Returns the model itself
|
|
102
|
+
def self.build_from_hash(attributes)
|
|
103
|
+
new.build_from_hash(attributes)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Builds the object from hash
|
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
108
|
+
# @return [Object] Returns the model itself
|
|
109
|
+
def build_from_hash(attributes)
|
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
|
111
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
112
|
+
if type =~ /\AArray<(.*)>/i
|
|
113
|
+
# check to ensure the input is an array given that the attribute
|
|
114
|
+
# is documented as an array but the input is not
|
|
115
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
116
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
117
|
+
end
|
|
118
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
119
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
120
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
self
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Deserializes the data based on type
|
|
127
|
+
# @param string type Data type
|
|
128
|
+
# @param string value Value to be deserialized
|
|
129
|
+
# @return [Object] Deserialized data
|
|
130
|
+
def _deserialize(type, value)
|
|
131
|
+
case type.to_sym
|
|
132
|
+
when :DateTime
|
|
133
|
+
DateTime.parse(value)
|
|
134
|
+
when :Date
|
|
135
|
+
Date.parse(value)
|
|
136
|
+
when :String
|
|
137
|
+
value.to_s
|
|
138
|
+
when :Integer
|
|
139
|
+
value.to_i
|
|
140
|
+
when :Float
|
|
141
|
+
value.to_f
|
|
142
|
+
when :Boolean
|
|
143
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
144
|
+
true
|
|
145
|
+
else
|
|
146
|
+
false
|
|
147
|
+
end
|
|
148
|
+
when :Object
|
|
149
|
+
# generic object (usually a Hash), return directly
|
|
150
|
+
value
|
|
151
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
152
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
153
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
154
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
155
|
+
k_type = Regexp.last_match[:k_type]
|
|
156
|
+
v_type = Regexp.last_match[:v_type]
|
|
157
|
+
{}.tap do |hash|
|
|
158
|
+
value.each do |k, v|
|
|
159
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
else # model
|
|
163
|
+
Shotstack.const_get(type).build_from_hash(value)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Returns the string representation of the object
|
|
168
|
+
# @return [String] String presentation of the object
|
|
169
|
+
def to_s
|
|
170
|
+
to_hash.to_s
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
|
175
|
+
def to_body
|
|
176
|
+
to_hash
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Returns the object in the form of hash
|
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
|
181
|
+
def to_hash
|
|
182
|
+
hash = {}
|
|
183
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
184
|
+
value = self.send(attr)
|
|
185
|
+
if value.nil?
|
|
186
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
187
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
hash[param] = _to_hash(value)
|
|
191
|
+
end
|
|
192
|
+
hash
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Outputs non-array value in the form of hash
|
|
196
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
197
|
+
# @param [Object] value Any valid value
|
|
198
|
+
# @return [Hash] Returns the value in the form of hash
|
|
199
|
+
def _to_hash(value)
|
|
200
|
+
if value.is_a?(Array)
|
|
201
|
+
value.compact.map { |v| _to_hash(v) }
|
|
202
|
+
elsif value.is_a?(Hash)
|
|
203
|
+
{}.tap do |hash|
|
|
204
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
205
|
+
end
|
|
206
|
+
elsif value.respond_to? :to_hash
|
|
207
|
+
value.to_hash
|
|
208
|
+
else
|
|
209
|
+
value
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
@@ -0,0 +1,319 @@
|
|
|
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 HtmlAsset clip type lets you create text based layout and formatting using HTML and CSS. You can also set the height and width of a bounding box for the HTML content to sit within. Text and elements will wrap within the bounding box.
|
|
18
|
+
class HtmlAsset < Asset
|
|
19
|
+
# The type of asset - set to <b>html</b> for HTML.
|
|
20
|
+
attr_accessor :type
|
|
21
|
+
|
|
22
|
+
# The HTML text string.
|
|
23
|
+
attr_accessor :html
|
|
24
|
+
|
|
25
|
+
# The CSS text string to apply styling to the HTML.
|
|
26
|
+
attr_accessor :css
|
|
27
|
+
|
|
28
|
+
# Set the width of the HTML asset bounding box. Text will wrap to fill the bounding box.
|
|
29
|
+
attr_accessor :width
|
|
30
|
+
|
|
31
|
+
# Set the width of the HTML asset bounding box. Text and elements will be masked if they exceed the height of the bounding box.
|
|
32
|
+
attr_accessor :height
|
|
33
|
+
|
|
34
|
+
# Apply a background color behind the HTML bounding box using. Set the text color using hexadecimal color notation. Transparency is supported by setting the first two characters of the hex string (opposite to HTML), i.e. #80ffffff will be white with 50% transparency.
|
|
35
|
+
attr_accessor :background
|
|
36
|
+
|
|
37
|
+
# Place the HTML in one of nine predefined positions within the HTML area.
|
|
38
|
+
attr_accessor :position
|
|
39
|
+
|
|
40
|
+
class EnumAttributeValidator
|
|
41
|
+
attr_reader :datatype
|
|
42
|
+
attr_reader :allowable_values
|
|
43
|
+
|
|
44
|
+
def initialize(datatype, allowable_values)
|
|
45
|
+
@allowable_values = allowable_values.map do |value|
|
|
46
|
+
case datatype.to_s
|
|
47
|
+
when /Integer/i
|
|
48
|
+
value.to_i
|
|
49
|
+
when /Float/i
|
|
50
|
+
value.to_f
|
|
51
|
+
else
|
|
52
|
+
value
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def valid?(value)
|
|
58
|
+
!value || allowable_values.include?(value)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
63
|
+
def self.attribute_map
|
|
64
|
+
{
|
|
65
|
+
:'type' => :'type',
|
|
66
|
+
:'html' => :'html',
|
|
67
|
+
:'css' => :'css',
|
|
68
|
+
:'width' => :'width',
|
|
69
|
+
:'height' => :'height',
|
|
70
|
+
:'background' => :'background',
|
|
71
|
+
:'position' => :'position'
|
|
72
|
+
}
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Attribute type mapping.
|
|
76
|
+
def self.openapi_types
|
|
77
|
+
{
|
|
78
|
+
:'type' => :'String',
|
|
79
|
+
:'html' => :'String',
|
|
80
|
+
:'css' => :'String',
|
|
81
|
+
:'width' => :'Float',
|
|
82
|
+
:'height' => :'Float',
|
|
83
|
+
:'background' => :'String',
|
|
84
|
+
:'position' => :'String'
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# List of attributes with nullable: true
|
|
89
|
+
def self.openapi_nullable
|
|
90
|
+
Set.new([
|
|
91
|
+
])
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Initializes the object
|
|
95
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
96
|
+
def initialize(attributes = {})
|
|
97
|
+
if (!attributes.is_a?(Hash))
|
|
98
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::HtmlAsset` initialize method"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
102
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
103
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
104
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::HtmlAsset`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
105
|
+
end
|
|
106
|
+
h[k.to_sym] = v
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'type')
|
|
110
|
+
self.type = attributes[:'type']
|
|
111
|
+
else
|
|
112
|
+
self.type = 'html'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if attributes.key?(:'html')
|
|
116
|
+
self.html = attributes[:'html']
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if attributes.key?(:'css')
|
|
120
|
+
self.css = attributes[:'css']
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if attributes.key?(:'width')
|
|
124
|
+
self.width = attributes[:'width']
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if attributes.key?(:'height')
|
|
128
|
+
self.height = attributes[:'height']
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
if attributes.key?(:'background')
|
|
132
|
+
self.background = attributes[:'background']
|
|
133
|
+
else
|
|
134
|
+
self.background = 'transparent'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if attributes.key?(:'position')
|
|
138
|
+
self.position = attributes[:'position']
|
|
139
|
+
else
|
|
140
|
+
self.position = 'center'
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
145
|
+
# @return Array for valid properties with the reasons
|
|
146
|
+
def list_invalid_properties
|
|
147
|
+
invalid_properties = Array.new
|
|
148
|
+
if @type.nil?
|
|
149
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
if @html.nil?
|
|
153
|
+
invalid_properties.push('invalid value for "html", html cannot be nil.')
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
invalid_properties
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Check to see if the all the properties in the model are valid
|
|
160
|
+
# @return true if the model is valid
|
|
161
|
+
def valid?
|
|
162
|
+
return false if @type.nil?
|
|
163
|
+
return false if @html.nil?
|
|
164
|
+
position_validator = EnumAttributeValidator.new('String', ["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"])
|
|
165
|
+
return false unless position_validator.valid?(@position)
|
|
166
|
+
true
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
170
|
+
# @param [Object] position Object to be assigned
|
|
171
|
+
def position=(position)
|
|
172
|
+
validator = EnumAttributeValidator.new('String', ["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"])
|
|
173
|
+
unless validator.valid?(position)
|
|
174
|
+
fail ArgumentError, "invalid value for \"position\", must be one of #{validator.allowable_values}."
|
|
175
|
+
end
|
|
176
|
+
@position = position
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Checks equality by comparing each attribute.
|
|
180
|
+
# @param [Object] Object to be compared
|
|
181
|
+
def ==(o)
|
|
182
|
+
return true if self.equal?(o)
|
|
183
|
+
self.class == o.class &&
|
|
184
|
+
type == o.type &&
|
|
185
|
+
html == o.html &&
|
|
186
|
+
css == o.css &&
|
|
187
|
+
width == o.width &&
|
|
188
|
+
height == o.height &&
|
|
189
|
+
background == o.background &&
|
|
190
|
+
position == o.position
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# @see the `==` method
|
|
194
|
+
# @param [Object] Object to be compared
|
|
195
|
+
def eql?(o)
|
|
196
|
+
self == o
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Calculates hash code according to all attributes.
|
|
200
|
+
# @return [Integer] Hash code
|
|
201
|
+
def hash
|
|
202
|
+
[type, html, css, width, height, background, position].hash
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Builds the object from hash
|
|
206
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
207
|
+
# @return [Object] Returns the model itself
|
|
208
|
+
def self.build_from_hash(attributes)
|
|
209
|
+
new.build_from_hash(attributes)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Builds the object from hash
|
|
213
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
214
|
+
# @return [Object] Returns the model itself
|
|
215
|
+
def build_from_hash(attributes)
|
|
216
|
+
return nil unless attributes.is_a?(Hash)
|
|
217
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
218
|
+
if type =~ /\AArray<(.*)>/i
|
|
219
|
+
# check to ensure the input is an array given that the attribute
|
|
220
|
+
# is documented as an array but the input is not
|
|
221
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
222
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
223
|
+
end
|
|
224
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
225
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
226
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
self
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Deserializes the data based on type
|
|
233
|
+
# @param string type Data type
|
|
234
|
+
# @param string value Value to be deserialized
|
|
235
|
+
# @return [Object] Deserialized data
|
|
236
|
+
def _deserialize(type, value)
|
|
237
|
+
case type.to_sym
|
|
238
|
+
when :DateTime
|
|
239
|
+
DateTime.parse(value)
|
|
240
|
+
when :Date
|
|
241
|
+
Date.parse(value)
|
|
242
|
+
when :String
|
|
243
|
+
value.to_s
|
|
244
|
+
when :Integer
|
|
245
|
+
value.to_i
|
|
246
|
+
when :Float
|
|
247
|
+
value.to_f
|
|
248
|
+
when :Boolean
|
|
249
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
250
|
+
true
|
|
251
|
+
else
|
|
252
|
+
false
|
|
253
|
+
end
|
|
254
|
+
when :Object
|
|
255
|
+
# generic object (usually a Hash), return directly
|
|
256
|
+
value
|
|
257
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
258
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
259
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
260
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
261
|
+
k_type = Regexp.last_match[:k_type]
|
|
262
|
+
v_type = Regexp.last_match[:v_type]
|
|
263
|
+
{}.tap do |hash|
|
|
264
|
+
value.each do |k, v|
|
|
265
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
else # model
|
|
269
|
+
Shotstack.const_get(type).build_from_hash(value)
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Returns the string representation of the object
|
|
274
|
+
# @return [String] String presentation of the object
|
|
275
|
+
def to_s
|
|
276
|
+
to_hash.to_s
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
280
|
+
# @return [Hash] Returns the object in the form of hash
|
|
281
|
+
def to_body
|
|
282
|
+
to_hash
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Returns the object in the form of hash
|
|
286
|
+
# @return [Hash] Returns the object in the form of hash
|
|
287
|
+
def to_hash
|
|
288
|
+
hash = {}
|
|
289
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
290
|
+
value = self.send(attr)
|
|
291
|
+
if value.nil?
|
|
292
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
293
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
hash[param] = _to_hash(value)
|
|
297
|
+
end
|
|
298
|
+
hash
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# Outputs non-array value in the form of hash
|
|
302
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
303
|
+
# @param [Object] value Any valid value
|
|
304
|
+
# @return [Hash] Returns the value in the form of hash
|
|
305
|
+
def _to_hash(value)
|
|
306
|
+
if value.is_a?(Array)
|
|
307
|
+
value.compact.map { |v| _to_hash(v) }
|
|
308
|
+
elsif value.is_a?(Hash)
|
|
309
|
+
{}.tap do |hash|
|
|
310
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
311
|
+
end
|
|
312
|
+
elsif value.respond_to? :to_hash
|
|
313
|
+
value.to_hash
|
|
314
|
+
else
|
|
315
|
+
value
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|