shotstack 0.0.11 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shotstack.rb +12 -5
- data/lib/shotstack/api/{default_api.rb → endpoints_api.rb} +17 -17
- data/lib/shotstack/api_client.rb +33 -34
- data/lib/shotstack/api_error.rb +4 -4
- data/lib/shotstack/configuration.rb +11 -10
- data/lib/shotstack/models/audio_asset.rb +251 -0
- data/lib/shotstack/models/clip.rb +98 -11
- data/lib/shotstack/models/edit.rb +29 -9
- data/lib/shotstack/models/font.rb +213 -0
- data/lib/shotstack/models/html_asset.rb +319 -0
- data/lib/shotstack/models/image_asset.rb +15 -5
- data/lib/shotstack/models/luma_asset.rb +241 -0
- data/lib/shotstack/models/offset.rb +266 -0
- data/lib/shotstack/models/output.rb +85 -11
- data/lib/shotstack/models/poster.rb +213 -0
- data/lib/shotstack/models/queued_response.rb +14 -4
- data/lib/shotstack/models/queued_response_data.rb +14 -4
- data/lib/shotstack/models/render_response.rb +14 -4
- data/lib/shotstack/models/render_response_data.rb +14 -4
- data/lib/shotstack/models/soundtrack.rb +30 -10
- data/lib/shotstack/models/thumbnail.rb +228 -0
- data/lib/shotstack/models/timeline.rb +32 -8
- data/lib/shotstack/models/title_asset.rb +78 -13
- data/lib/shotstack/models/track.rb +15 -5
- data/lib/shotstack/models/transition.rb +18 -8
- data/lib/shotstack/models/video_asset.rb +18 -8
- data/lib/shotstack/version.rb +4 -4
- data/shotstack-0.0.11.gem +0 -0
- data/shotstack.gemspec +6 -12
- metadata +16 -126
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5d727eb8d81617086f6b4506df8f738a8ecb07d818a375ab8822159904a4845
|
4
|
+
data.tar.gz: d25bdff650bb7dd955978ff1b63d2edcf4bb895ed84e4c40a3217a57afdbb1e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2411953a0b793ecfb4e8a9d651e5a9f918168b508c63bb143ab47b44b971465b17e87fe879477ca75e3fb4d3e68499cce9c968f9db0b26ad9511c950f65f726
|
7
|
+
data.tar.gz: 06ec520d33f69604f7ecf2b11937c353f8d67af0a463563fcbb957c25682f62a8e523e6ee11664b3a88cf2cb5e8f3fc2763909e6c69483ab46c8b2bdb6f7713c
|
data/lib/shotstack.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
|
-
#
|
2
|
+
#Shotstack
|
3
3
|
|
4
|
-
#The Shotstack API is a video editing service that allows for the
|
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
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -17,15 +17,22 @@ require 'shotstack/version'
|
|
17
17
|
require 'shotstack/configuration'
|
18
18
|
|
19
19
|
# Models
|
20
|
+
require 'shotstack/models/audio_asset'
|
20
21
|
require 'shotstack/models/clip'
|
21
22
|
require 'shotstack/models/edit'
|
23
|
+
require 'shotstack/models/font'
|
24
|
+
require 'shotstack/models/html_asset'
|
22
25
|
require 'shotstack/models/image_asset'
|
26
|
+
require 'shotstack/models/luma_asset'
|
27
|
+
require 'shotstack/models/offset'
|
23
28
|
require 'shotstack/models/output'
|
29
|
+
require 'shotstack/models/poster'
|
24
30
|
require 'shotstack/models/queued_response'
|
25
31
|
require 'shotstack/models/queued_response_data'
|
26
32
|
require 'shotstack/models/render_response'
|
27
33
|
require 'shotstack/models/render_response_data'
|
28
34
|
require 'shotstack/models/soundtrack'
|
35
|
+
require 'shotstack/models/thumbnail'
|
29
36
|
require 'shotstack/models/timeline'
|
30
37
|
require 'shotstack/models/title_asset'
|
31
38
|
require 'shotstack/models/track'
|
@@ -33,7 +40,7 @@ require 'shotstack/models/transition'
|
|
33
40
|
require 'shotstack/models/video_asset'
|
34
41
|
|
35
42
|
# APIs
|
36
|
-
require 'shotstack/api/
|
43
|
+
require 'shotstack/api/endpoints_api'
|
37
44
|
|
38
45
|
module Shotstack
|
39
46
|
class << self
|
@@ -1,19 +1,19 @@
|
|
1
1
|
=begin
|
2
|
-
#
|
2
|
+
#Shotstack
|
3
3
|
|
4
|
-
#The Shotstack API is a video editing service that allows for the
|
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
5
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'cgi'
|
14
14
|
|
15
15
|
module Shotstack
|
16
|
-
class
|
16
|
+
class EndpointsApi
|
17
17
|
attr_accessor :api_client
|
18
18
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
@@ -24,7 +24,7 @@ module Shotstack
|
|
24
24
|
# @param [Hash] opts the optional parameters
|
25
25
|
# @return [RenderResponse]
|
26
26
|
def get_render(id, opts = {})
|
27
|
-
data, _status_code, _headers =
|
27
|
+
data, _status_code, _headers = get_render_with_http_info(id, opts)
|
28
28
|
data
|
29
29
|
end
|
30
30
|
|
@@ -32,21 +32,21 @@ module Shotstack
|
|
32
32
|
# @param id [String] The id of the timeline render task in UUID format
|
33
33
|
# @param [Hash] opts the optional parameters
|
34
34
|
# @return [Array<(RenderResponse, Integer, Hash)>] RenderResponse data, response status code and response headers
|
35
|
-
def
|
35
|
+
def get_render_with_http_info(id, opts = {})
|
36
36
|
if @api_client.config.debugging
|
37
|
-
@api_client.config.logger.debug 'Calling API:
|
37
|
+
@api_client.config.logger.debug 'Calling API: EndpointsApi.get_render ...'
|
38
38
|
end
|
39
39
|
# verify the required parameter 'id' is set
|
40
40
|
if @api_client.config.client_side_validation && id.nil?
|
41
|
-
fail ArgumentError, "Missing the required parameter 'id' when calling
|
41
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling EndpointsApi.get_render"
|
42
42
|
end
|
43
43
|
pattern = Regexp.new(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
|
44
44
|
if @api_client.config.client_side_validation && id !~ pattern
|
45
|
-
fail ArgumentError, "invalid value for 'id' when calling
|
45
|
+
fail ArgumentError, "invalid value for 'id' when calling EndpointsApi.get_render, must conform to the pattern #{pattern}."
|
46
46
|
end
|
47
47
|
|
48
48
|
# resource path
|
49
|
-
local_var_path = '/render/{id}'.sub('{' + 'id' + '}', id.to_s)
|
49
|
+
local_var_path = '/render/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
|
50
50
|
|
51
51
|
# query parameters
|
52
52
|
query_params = opts[:query_params] || {}
|
@@ -79,7 +79,7 @@ module Shotstack
|
|
79
79
|
|
80
80
|
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
81
81
|
if @api_client.config.debugging
|
82
|
-
@api_client.config.logger.debug "API called:
|
82
|
+
@api_client.config.logger.debug "API called: EndpointsApi#get_render\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
83
83
|
end
|
84
84
|
return data, status_code, headers
|
85
85
|
end
|
@@ -89,7 +89,7 @@ module Shotstack
|
|
89
89
|
# @param [Hash] opts the optional parameters
|
90
90
|
# @return [QueuedResponse]
|
91
91
|
def post_render(edit, opts = {})
|
92
|
-
data, _status_code, _headers =
|
92
|
+
data, _status_code, _headers = post_render_with_http_info(edit, opts)
|
93
93
|
data
|
94
94
|
end
|
95
95
|
|
@@ -97,13 +97,13 @@ module Shotstack
|
|
97
97
|
# @param edit [Edit]
|
98
98
|
# @param [Hash] opts the optional parameters
|
99
99
|
# @return [Array<(QueuedResponse, Integer, Hash)>] QueuedResponse data, response status code and response headers
|
100
|
-
def
|
100
|
+
def post_render_with_http_info(edit, opts = {})
|
101
101
|
if @api_client.config.debugging
|
102
|
-
@api_client.config.logger.debug 'Calling API:
|
102
|
+
@api_client.config.logger.debug 'Calling API: EndpointsApi.post_render ...'
|
103
103
|
end
|
104
104
|
# verify the required parameter 'edit' is set
|
105
105
|
if @api_client.config.client_side_validation && edit.nil?
|
106
|
-
fail ArgumentError, "Missing the required parameter 'edit' when calling
|
106
|
+
fail ArgumentError, "Missing the required parameter 'edit' when calling EndpointsApi.post_render"
|
107
107
|
end
|
108
108
|
# resource path
|
109
109
|
local_var_path = '/render'
|
@@ -141,7 +141,7 @@ module Shotstack
|
|
141
141
|
|
142
142
|
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
143
143
|
if @api_client.config.debugging
|
144
|
-
@api_client.config.logger.debug "API called:
|
144
|
+
@api_client.config.logger.debug "API called: EndpointsApi#post_render\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
145
145
|
end
|
146
146
|
return data, status_code, headers
|
147
147
|
end
|
data/lib/shotstack/api_client.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
|
-
#
|
2
|
+
#Shotstack
|
3
3
|
|
4
|
-
#The Shotstack API is a video editing service that allows for the
|
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
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -15,7 +15,6 @@ require 'json'
|
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
17
|
require 'typhoeus'
|
18
|
-
require 'uri'
|
19
18
|
|
20
19
|
module Shotstack
|
21
20
|
class ApiClient
|
@@ -128,6 +127,34 @@ module Shotstack
|
|
128
127
|
request
|
129
128
|
end
|
130
129
|
|
130
|
+
# Builds the HTTP request body
|
131
|
+
#
|
132
|
+
# @param [Hash] header_params Header parameters
|
133
|
+
# @param [Hash] form_params Query parameters
|
134
|
+
# @param [Object] body HTTP body (JSON/XML)
|
135
|
+
# @return [String] HTTP body data in the form of string
|
136
|
+
def build_request_body(header_params, form_params, body)
|
137
|
+
# http form
|
138
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
139
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
140
|
+
data = {}
|
141
|
+
form_params.each do |key, value|
|
142
|
+
case value
|
143
|
+
when ::File, ::Array, nil
|
144
|
+
# let typhoeus handle File, Array and nil parameters
|
145
|
+
data[key] = value
|
146
|
+
else
|
147
|
+
data[key] = value.to_s
|
148
|
+
end
|
149
|
+
end
|
150
|
+
elsif body
|
151
|
+
data = body.is_a?(String) ? body : body.to_json
|
152
|
+
else
|
153
|
+
data = nil
|
154
|
+
end
|
155
|
+
data
|
156
|
+
end
|
157
|
+
|
131
158
|
# Check if the given MIME is a JSON MIME.
|
132
159
|
# JSON MIME examples:
|
133
160
|
# application/json
|
@@ -262,35 +289,7 @@ module Shotstack
|
|
262
289
|
def build_request_url(path)
|
263
290
|
# Add leading and trailing slashes to path
|
264
291
|
path = "/#{path}".gsub(/\/+/, '/')
|
265
|
-
|
266
|
-
end
|
267
|
-
|
268
|
-
# Builds the HTTP request body
|
269
|
-
#
|
270
|
-
# @param [Hash] header_params Header parameters
|
271
|
-
# @param [Hash] form_params Query parameters
|
272
|
-
# @param [Object] body HTTP body (JSON/XML)
|
273
|
-
# @return [String] HTTP body data in the form of string
|
274
|
-
def build_request_body(header_params, form_params, body)
|
275
|
-
# http form
|
276
|
-
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
277
|
-
header_params['Content-Type'] == 'multipart/form-data'
|
278
|
-
data = {}
|
279
|
-
form_params.each do |key, value|
|
280
|
-
case value
|
281
|
-
when ::File, ::Array, nil
|
282
|
-
# let typhoeus handle File, Array and nil parameters
|
283
|
-
data[key] = value
|
284
|
-
else
|
285
|
-
data[key] = value.to_s
|
286
|
-
end
|
287
|
-
end
|
288
|
-
elsif body
|
289
|
-
data = body.is_a?(String) ? body : body.to_json
|
290
|
-
else
|
291
|
-
data = nil
|
292
|
-
end
|
293
|
-
data
|
292
|
+
@config.base_url + path
|
294
293
|
end
|
295
294
|
|
296
295
|
# Update hearder and query params based on authentication settings.
|
data/lib/shotstack/api_error.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
|
-
#
|
2
|
+
#Shotstack
|
3
3
|
|
4
|
-
#The Shotstack API is a video editing service that allows for the
|
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
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -1,17 +1,15 @@
|
|
1
1
|
=begin
|
2
|
-
#
|
2
|
+
#Shotstack
|
3
3
|
|
4
|
-
#The Shotstack API is a video editing service that allows for the
|
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
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require 'uri'
|
14
|
-
|
15
13
|
module Shotstack
|
16
14
|
class Configuration
|
17
15
|
# Defines url scheme
|
@@ -130,7 +128,7 @@ module Shotstack
|
|
130
128
|
def initialize
|
131
129
|
@scheme = 'https'
|
132
130
|
@host = 'api.shotstack.io'
|
133
|
-
@base_path = '/
|
131
|
+
@base_path = '/v1'
|
134
132
|
@api_key = {}
|
135
133
|
@api_key_prefix = {}
|
136
134
|
@timeout = 0
|
@@ -174,8 +172,7 @@ module Shotstack
|
|
174
172
|
end
|
175
173
|
|
176
174
|
def base_url
|
177
|
-
|
178
|
-
URI.encode(url)
|
175
|
+
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
179
176
|
end
|
180
177
|
|
181
178
|
# Gets API key (with prefix if set).
|
@@ -215,7 +212,11 @@ module Shotstack
|
|
215
212
|
variables: {
|
216
213
|
version: {
|
217
214
|
description: "No descriptoin provided",
|
218
|
-
default_value: "
|
215
|
+
default_value: "v1",
|
216
|
+
enum_values: [
|
217
|
+
"v1",
|
218
|
+
"stage"
|
219
|
+
]
|
219
220
|
}
|
220
221
|
}
|
221
222
|
}
|
@@ -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 AudioAsset is used to add sound effects and audio at specific intervals on the timeline. The src must be a publicly accessible URL to an audio resource such as an mp3 file.
|
18
|
+
class AudioAsset < Asset
|
19
|
+
# The type of asset - set to <b>audio</b> for audio assets.
|
20
|
+
attr_accessor :type
|
21
|
+
|
22
|
+
# The audio source URL. The URL must be publicly accessible or include credentials.
|
23
|
+
attr_accessor :src
|
24
|
+
|
25
|
+
# The start trim point of the audio clip, in seconds (defaults to 0). Audio will start from the in trim point. The audio will play until the file ends or the Clip length is reached.
|
26
|
+
attr_accessor :trim
|
27
|
+
|
28
|
+
# Set the volume for the audio clip between 0 and 1 where 0 is muted and 1 is full volume (defaults to 1).
|
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::AudioAsset` 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::AudioAsset`. 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 = 'audio'
|
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
|