shotstack 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -12
- data/lib/shotstack.rb +3 -1
- data/lib/shotstack/api/endpoints_api.rb +20 -11
- data/lib/shotstack/api_client.rb +49 -45
- data/lib/shotstack/api_error.rb +1 -1
- data/lib/shotstack/configuration.rb +35 -8
- data/lib/shotstack/models/audio_asset.rb +70 -12
- data/lib/shotstack/models/clip.rb +27 -13
- data/lib/shotstack/models/crop.rb +346 -0
- data/lib/shotstack/models/edit.rb +19 -7
- data/lib/shotstack/models/font.rb +19 -7
- data/lib/shotstack/models/html_asset.rb +25 -13
- data/lib/shotstack/models/image_asset.rb +34 -13
- data/lib/shotstack/models/luma_asset.rb +20 -8
- data/lib/shotstack/models/offset.rb +23 -7
- data/lib/shotstack/models/output.rb +60 -15
- data/lib/shotstack/models/poster.rb +19 -7
- data/lib/shotstack/models/queued_response.rb +21 -7
- data/lib/shotstack/models/queued_response_data.rb +21 -9
- data/lib/shotstack/models/range.rb +260 -0
- data/lib/shotstack/models/render_response.rb +21 -7
- data/lib/shotstack/models/render_response_data.rb +100 -28
- data/lib/shotstack/models/soundtrack.rb +22 -8
- data/lib/shotstack/models/thumbnail.rb +19 -7
- data/lib/shotstack/models/timeline.rb +19 -7
- data/lib/shotstack/models/title_asset.rb +24 -12
- data/lib/shotstack/models/track.rb +19 -7
- data/lib/shotstack/models/transition.rb +25 -13
- data/lib/shotstack/models/video_asset.rb +33 -12
- data/lib/shotstack/version.rb +2 -2
- data/shotstack.gemspec +6 -7
- metadata +9 -28
- data/shotstack-0.0.11.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe23e5f4a04895111959fadb1ae057a20d64b47b3015f4ac8cad2481b83f077
|
4
|
+
data.tar.gz: da6e99e80bea597ef2e65a5bf09bafcecd4923015fcc3ba1dbffda46306006c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69581b3a2c839530874857f0964f62cb01adb0a28c8dd04bfd65f142d172eb6465ddddf43d1fc80d55108301c7ab60a7b3939ee9903868842c5241e6314bf904
|
7
|
+
data.tar.gz: 1106311ee9c828f029679471cc02899342c3054927176e0c6e9b2b2cb7b433afa21f1dd997ef787df1cfbd9e9dddf3868f1497fcae89313bb6a25120c4829e00
|
data/README.md
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
# Shotstack Ruby SDK
|
2
2
|
|
3
|
-
Ruby SDK for Shotstack, the cloud video editing API.
|
3
|
+
Ruby SDK for [Shotstack](http://shotstack.io), the cloud video editing API.
|
4
4
|
|
5
|
-
|
5
|
+
Shotstack is a cloud based video editing platform that enables the editing of videos using code.
|
6
6
|
|
7
|
-
|
7
|
+
The platform uses an API and a JSON format for specifying how videos should be edited and what assets and titles should be used.
|
8
8
|
|
9
|
-
|
9
|
+
A server based render farm takes care of rendering the videos allowing multiple videos to be created simultaneously.
|
10
10
|
|
11
|
-
|
12
|
-
rm shotstack-*.gem
|
13
|
-
gem build shotstack
|
14
|
-
gem push shotstack-*.*.*.gem # use the correct version number
|
15
|
-
```
|
11
|
+
For examples of how to use the SDK to create videos using code checkout the Ruby demo repo: https://github.com/shotstack/ruby-demos
|
16
12
|
|
17
|
-
|
13
|
+
## Installation
|
18
14
|
|
19
|
-
```bash
|
20
|
-
sudo gem install shotstack
|
21
15
|
```
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## Documentation
|
20
|
+
|
21
|
+
- [Getting Started Guide](https://shotstack.gitbook.io/docs/guides/getting-started)
|
22
|
+
- [API Reference](https://shotstack.restlet.io/)
|
23
|
+
- [Examples](https://github.com/shotstack/ruby-demos)
|
24
|
+
- [Shotstack Website](http://shotstack.io)
|
25
|
+
|
26
|
+
###
|
data/lib/shotstack.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.0.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -19,6 +19,7 @@ require 'shotstack/configuration'
|
|
19
19
|
# Models
|
20
20
|
require 'shotstack/models/audio_asset'
|
21
21
|
require 'shotstack/models/clip'
|
22
|
+
require 'shotstack/models/crop'
|
22
23
|
require 'shotstack/models/edit'
|
23
24
|
require 'shotstack/models/font'
|
24
25
|
require 'shotstack/models/html_asset'
|
@@ -29,6 +30,7 @@ require 'shotstack/models/output'
|
|
29
30
|
require 'shotstack/models/poster'
|
30
31
|
require 'shotstack/models/queued_response'
|
31
32
|
require 'shotstack/models/queued_response_data'
|
33
|
+
require 'shotstack/models/range'
|
32
34
|
require 'shotstack/models/render_response'
|
33
35
|
require 'shotstack/models/render_response_data'
|
34
36
|
require 'shotstack/models/soundtrack'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.0.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -19,6 +19,7 @@ module Shotstack
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
20
20
|
@api_client = api_client
|
21
21
|
end
|
22
|
+
# Get Render Status
|
22
23
|
# Get the rendering status, video url and details of a timeline by ID.
|
23
24
|
# @param id [String] The id of the timeline render task in UUID format
|
24
25
|
# @param [Hash] opts the optional parameters
|
@@ -28,6 +29,7 @@ module Shotstack
|
|
28
29
|
data
|
29
30
|
end
|
30
31
|
|
32
|
+
# Get Render Status
|
31
33
|
# Get the rendering status, video url and details of a timeline by ID.
|
32
34
|
# @param id [String] The id of the timeline render task in UUID format
|
33
35
|
# @param [Hash] opts the optional parameters
|
@@ -60,15 +62,16 @@ module Shotstack
|
|
60
62
|
form_params = opts[:form_params] || {}
|
61
63
|
|
62
64
|
# http body (model)
|
63
|
-
post_body = opts[:
|
65
|
+
post_body = opts[:debug_body]
|
64
66
|
|
65
67
|
# return_type
|
66
|
-
return_type = opts[:
|
68
|
+
return_type = opts[:debug_return_type] || 'RenderResponse'
|
67
69
|
|
68
70
|
# auth_names
|
69
|
-
auth_names = opts[:
|
71
|
+
auth_names = opts[:debug_auth_names] || ['DeveloperKey']
|
70
72
|
|
71
73
|
new_options = opts.merge(
|
74
|
+
:operation => :"EndpointsApi.get_render",
|
72
75
|
:header_params => header_params,
|
73
76
|
:query_params => query_params,
|
74
77
|
:form_params => form_params,
|
@@ -84,18 +87,22 @@ module Shotstack
|
|
84
87
|
return data, status_code, headers
|
85
88
|
end
|
86
89
|
|
87
|
-
# Render
|
88
|
-
#
|
90
|
+
# Render Video
|
91
|
+
# Queue and render the contents of a timeline as a video file.
|
92
|
+
# @param edit [Edit] The video edit specified using JSON.
|
89
93
|
# @param [Hash] opts the optional parameters
|
94
|
+
# @option opts [String] :x_api_queue_id The id of a dedicated queue (enterprise customers only).
|
90
95
|
# @return [QueuedResponse]
|
91
96
|
def post_render(edit, opts = {})
|
92
97
|
data, _status_code, _headers = post_render_with_http_info(edit, opts)
|
93
98
|
data
|
94
99
|
end
|
95
100
|
|
96
|
-
# Render
|
97
|
-
#
|
101
|
+
# Render Video
|
102
|
+
# Queue and render the contents of a timeline as a video file.
|
103
|
+
# @param edit [Edit] The video edit specified using JSON.
|
98
104
|
# @param [Hash] opts the optional parameters
|
105
|
+
# @option opts [String] :x_api_queue_id The id of a dedicated queue (enterprise customers only).
|
99
106
|
# @return [Array<(QueuedResponse, Integer, Hash)>] QueuedResponse data, response status code and response headers
|
100
107
|
def post_render_with_http_info(edit, opts = {})
|
101
108
|
if @api_client.config.debugging
|
@@ -117,20 +124,22 @@ module Shotstack
|
|
117
124
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
118
125
|
# HTTP header 'Content-Type'
|
119
126
|
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
127
|
+
header_params[:'x-api-queue-id'] = opts[:'x_api_queue_id'] if !opts[:'x_api_queue_id'].nil?
|
120
128
|
|
121
129
|
# form parameters
|
122
130
|
form_params = opts[:form_params] || {}
|
123
131
|
|
124
132
|
# http body (model)
|
125
|
-
post_body = opts[:
|
133
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(edit)
|
126
134
|
|
127
135
|
# return_type
|
128
|
-
return_type = opts[:
|
136
|
+
return_type = opts[:debug_return_type] || 'QueuedResponse'
|
129
137
|
|
130
138
|
# auth_names
|
131
|
-
auth_names = opts[:
|
139
|
+
auth_names = opts[:debug_auth_names] || ['DeveloperKey']
|
132
140
|
|
133
141
|
new_options = opts.merge(
|
142
|
+
:operation => :"EndpointsApi.post_render",
|
134
143
|
:header_params => header_params,
|
135
144
|
:query_params => query_params,
|
136
145
|
:form_params => form_params,
|
data/lib/shotstack/api_client.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.0.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -14,6 +14,7 @@ require 'date'
|
|
14
14
|
require 'json'
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
|
+
require 'time'
|
17
18
|
require 'typhoeus'
|
18
19
|
|
19
20
|
module Shotstack
|
@@ -86,7 +87,7 @@ module Shotstack
|
|
86
87
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
87
88
|
# @return [Typhoeus::Request] A Typhoeus Request
|
88
89
|
def build_request(http_method, path, opts = {})
|
89
|
-
url = build_request_url(path)
|
90
|
+
url = build_request_url(path, opts)
|
90
91
|
http_method = http_method.to_sym.downcase
|
91
92
|
|
92
93
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
@@ -155,6 +156,44 @@ module Shotstack
|
|
155
156
|
data
|
156
157
|
end
|
157
158
|
|
159
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
160
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
161
|
+
# The response body is written to the file in chunks in order to handle files which
|
162
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
163
|
+
# process can use.
|
164
|
+
#
|
165
|
+
# @see Configuration#temp_folder_path
|
166
|
+
def download_file(request)
|
167
|
+
tempfile = nil
|
168
|
+
encoding = nil
|
169
|
+
request.on_headers do |response|
|
170
|
+
content_disposition = response.headers['Content-Disposition']
|
171
|
+
if content_disposition && content_disposition =~ /filename=/i
|
172
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
173
|
+
prefix = sanitize_filename(filename)
|
174
|
+
else
|
175
|
+
prefix = 'download-'
|
176
|
+
end
|
177
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
178
|
+
encoding = response.body.encoding
|
179
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
180
|
+
@tempfile = tempfile
|
181
|
+
end
|
182
|
+
request.on_body do |chunk|
|
183
|
+
chunk.force_encoding(encoding)
|
184
|
+
tempfile.write(chunk)
|
185
|
+
end
|
186
|
+
request.on_complete do |response|
|
187
|
+
if tempfile
|
188
|
+
tempfile.close
|
189
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
190
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
191
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
192
|
+
"explicitly with `tempfile.delete`"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
158
197
|
# Check if the given MIME is a JSON MIME.
|
159
198
|
# JSON MIME examples:
|
160
199
|
# application/json
|
@@ -191,7 +230,7 @@ module Shotstack
|
|
191
230
|
begin
|
192
231
|
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
193
232
|
rescue JSON::ParserError => e
|
194
|
-
if %w(String Date
|
233
|
+
if %w(String Date Time).include?(return_type)
|
195
234
|
data = body
|
196
235
|
else
|
197
236
|
raise e
|
@@ -216,9 +255,9 @@ module Shotstack
|
|
216
255
|
data.to_f
|
217
256
|
when 'Boolean'
|
218
257
|
data == true
|
219
|
-
when '
|
258
|
+
when 'Time'
|
220
259
|
# parse date time (expecting ISO 8601 format)
|
221
|
-
|
260
|
+
Time.parse data
|
222
261
|
when 'Date'
|
223
262
|
# parse date time (expecting ISO 8601 format)
|
224
263
|
Date.parse data
|
@@ -236,44 +275,9 @@ module Shotstack
|
|
236
275
|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
237
276
|
end
|
238
277
|
else
|
239
|
-
# models
|
240
|
-
Shotstack.const_get(return_type)
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
# Save response body into a file in (the defined) temporary folder, using the filename
|
245
|
-
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
246
|
-
# The response body is written to the file in chunks in order to handle files which
|
247
|
-
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
248
|
-
# process can use.
|
249
|
-
#
|
250
|
-
# @see Configuration#temp_folder_path
|
251
|
-
def download_file(request)
|
252
|
-
tempfile = nil
|
253
|
-
encoding = nil
|
254
|
-
request.on_headers do |response|
|
255
|
-
content_disposition = response.headers['Content-Disposition']
|
256
|
-
if content_disposition && content_disposition =~ /filename=/i
|
257
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
258
|
-
prefix = sanitize_filename(filename)
|
259
|
-
else
|
260
|
-
prefix = 'download-'
|
261
|
-
end
|
262
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
263
|
-
encoding = response.body.encoding
|
264
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
265
|
-
@tempfile = tempfile
|
266
|
-
end
|
267
|
-
request.on_body do |chunk|
|
268
|
-
chunk.force_encoding(encoding)
|
269
|
-
tempfile.write(chunk)
|
270
|
-
end
|
271
|
-
request.on_complete do |response|
|
272
|
-
tempfile.close if tempfile
|
273
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
274
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
275
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
276
|
-
"explicitly with `tempfile.delete`"
|
278
|
+
# models (e.g. Pet) or oneOf
|
279
|
+
klass = Shotstack.const_get(return_type)
|
280
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
277
281
|
end
|
278
282
|
end
|
279
283
|
|
@@ -286,10 +290,10 @@ module Shotstack
|
|
286
290
|
filename.gsub(/.*[\/\\]/, '')
|
287
291
|
end
|
288
292
|
|
289
|
-
def build_request_url(path)
|
293
|
+
def build_request_url(path, opts = {})
|
290
294
|
# Add leading and trailing slashes to path
|
291
295
|
path = "/#{path}".gsub(/\/+/, '/')
|
292
|
-
@config.base_url + path
|
296
|
+
@config.base_url(opts[:operation]) + path
|
293
297
|
end
|
294
298
|
|
295
299
|
# Update hearder and query params based on authentication settings.
|
data/lib/shotstack/api_error.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.0.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -21,6 +21,18 @@ module Shotstack
|
|
21
21
|
# Defines url base path
|
22
22
|
attr_accessor :base_path
|
23
23
|
|
24
|
+
# Define server configuration index
|
25
|
+
attr_accessor :server_index
|
26
|
+
|
27
|
+
# Define server operation configuration index
|
28
|
+
attr_accessor :server_operation_index
|
29
|
+
|
30
|
+
# Default server variables
|
31
|
+
attr_accessor :server_variables
|
32
|
+
|
33
|
+
# Default server operation variables
|
34
|
+
attr_accessor :server_operation_variables
|
35
|
+
|
24
36
|
# Defines API keys used with API Key authentications.
|
25
37
|
#
|
26
38
|
# @return [Hash] key: parameter name, value: parameter value (API key)
|
@@ -129,6 +141,10 @@ module Shotstack
|
|
129
141
|
@scheme = 'https'
|
130
142
|
@host = 'api.shotstack.io'
|
131
143
|
@base_path = '/v1'
|
144
|
+
@server_index = 0
|
145
|
+
@server_operation_index = {}
|
146
|
+
@server_variables = {}
|
147
|
+
@server_operation_variables = {}
|
132
148
|
@api_key = {}
|
133
149
|
@api_key_prefix = {}
|
134
150
|
@timeout = 0
|
@@ -171,8 +187,12 @@ module Shotstack
|
|
171
187
|
@base_path = '' if @base_path == '/'
|
172
188
|
end
|
173
189
|
|
174
|
-
|
175
|
-
|
190
|
+
# Returns base URL for specified operation based on server settings
|
191
|
+
def base_url(operation = nil)
|
192
|
+
index = server_operation_index.fetch(operation, server_index)
|
193
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') # if index == nil
|
194
|
+
|
195
|
+
#server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
176
196
|
end
|
177
197
|
|
178
198
|
# Gets API key (with prefix if set).
|
@@ -208,10 +228,10 @@ module Shotstack
|
|
208
228
|
[
|
209
229
|
{
|
210
230
|
url: "https://api.shotstack.io/{version}",
|
211
|
-
description: "No
|
231
|
+
description: "No description provided",
|
212
232
|
variables: {
|
213
233
|
version: {
|
214
|
-
description: "No
|
234
|
+
description: "No description provided",
|
215
235
|
default_value: "v1",
|
216
236
|
enum_values: [
|
217
237
|
"v1",
|
@@ -223,12 +243,17 @@ module Shotstack
|
|
223
243
|
]
|
224
244
|
end
|
225
245
|
|
246
|
+
def operation_server_settings
|
247
|
+
{
|
248
|
+
}
|
249
|
+
end
|
250
|
+
|
226
251
|
# Returns URL based on server settings
|
227
252
|
#
|
228
253
|
# @param index array index of the server settings
|
229
254
|
# @param variables hash of variable and the corresponding value
|
230
|
-
def server_url(index, variables = {})
|
231
|
-
servers = server_settings
|
255
|
+
def server_url(index, variables = {}, servers = nil)
|
256
|
+
servers = server_settings if servers == nil
|
232
257
|
|
233
258
|
# check array index out of bound
|
234
259
|
if (index < 0 || index >= servers.size)
|
@@ -238,10 +263,12 @@ module Shotstack
|
|
238
263
|
server = servers[index]
|
239
264
|
url = server[:url]
|
240
265
|
|
266
|
+
return url unless server.key? :variables
|
267
|
+
|
241
268
|
# go through variable and assign a value
|
242
269
|
server[:variables].each do |name, variable|
|
243
270
|
if variables.key?(name)
|
244
|
-
if (server[:variables][name][:enum_values].include?
|
271
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
245
272
|
url.gsub! "{" + name.to_s + "}", variables[name]
|
246
273
|
else
|
247
274
|
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
@@ -6,17 +6,18 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.0.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
require_relative 'asset'
|
15
16
|
|
16
17
|
module Shotstack
|
17
18
|
# 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
19
|
class AudioAsset < Asset
|
19
|
-
# The type of asset - set to
|
20
|
+
# The type of asset - set to `audio` for audio assets.
|
20
21
|
attr_accessor :type
|
21
22
|
|
22
23
|
# The audio source URL. The URL must be publicly accessible or include credentials.
|
@@ -28,23 +29,55 @@ module Shotstack
|
|
28
29
|
# Set the volume for the audio clip between 0 and 1 where 0 is muted and 1 is full volume (defaults to 1).
|
29
30
|
attr_accessor :volume
|
30
31
|
|
32
|
+
# The effect to apply to the audio asset <ul> <li>`fadeIn` - fade volume in only</li> <li>`fadeOut` - fade volume out only</li> <li>`fadeInFadeOut` - fade volume in and out</li> </ul>
|
33
|
+
attr_accessor :effect
|
34
|
+
|
35
|
+
class EnumAttributeValidator
|
36
|
+
attr_reader :datatype
|
37
|
+
attr_reader :allowable_values
|
38
|
+
|
39
|
+
def initialize(datatype, allowable_values)
|
40
|
+
@allowable_values = allowable_values.map do |value|
|
41
|
+
case datatype.to_s
|
42
|
+
when /Integer/i
|
43
|
+
value.to_i
|
44
|
+
when /Float/i
|
45
|
+
value.to_f
|
46
|
+
else
|
47
|
+
value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid?(value)
|
53
|
+
!value || allowable_values.include?(value)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
31
57
|
# Attribute mapping from ruby-style variable name to JSON key.
|
32
58
|
def self.attribute_map
|
33
59
|
{
|
34
60
|
:'type' => :'type',
|
35
61
|
:'src' => :'src',
|
36
62
|
:'trim' => :'trim',
|
37
|
-
:'volume' => :'volume'
|
63
|
+
:'volume' => :'volume',
|
64
|
+
:'effect' => :'effect'
|
38
65
|
}
|
39
66
|
end
|
40
67
|
|
68
|
+
# Returns all the JSON keys this model knows about
|
69
|
+
def self.acceptable_attributes
|
70
|
+
attribute_map.values
|
71
|
+
end
|
72
|
+
|
41
73
|
# Attribute type mapping.
|
42
74
|
def self.openapi_types
|
43
75
|
{
|
44
76
|
:'type' => :'String',
|
45
77
|
:'src' => :'String',
|
46
78
|
:'trim' => :'Float',
|
47
|
-
:'volume' => :'Float'
|
79
|
+
:'volume' => :'Float',
|
80
|
+
:'effect' => :'String'
|
48
81
|
}
|
49
82
|
end
|
50
83
|
|
@@ -85,6 +118,12 @@ module Shotstack
|
|
85
118
|
|
86
119
|
if attributes.key?(:'volume')
|
87
120
|
self.volume = attributes[:'volume']
|
121
|
+
else
|
122
|
+
self.volume = 1
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:'effect')
|
126
|
+
self.effect = attributes[:'effect']
|
88
127
|
end
|
89
128
|
end
|
90
129
|
|
@@ -108,9 +147,21 @@ module Shotstack
|
|
108
147
|
def valid?
|
109
148
|
return false if @type.nil?
|
110
149
|
return false if @src.nil?
|
150
|
+
effect_validator = EnumAttributeValidator.new('String', ["fadeIn", "fadeOut", "fadeInFadeOut"])
|
151
|
+
return false unless effect_validator.valid?(@effect)
|
111
152
|
true
|
112
153
|
end
|
113
154
|
|
155
|
+
# Custom attribute writer method checking allowed values (enum).
|
156
|
+
# @param [Object] effect Object to be assigned
|
157
|
+
def effect=(effect)
|
158
|
+
validator = EnumAttributeValidator.new('String', ["fadeIn", "fadeOut", "fadeInFadeOut"])
|
159
|
+
unless validator.valid?(effect)
|
160
|
+
fail ArgumentError, "invalid value for \"effect\", must be one of #{validator.allowable_values}."
|
161
|
+
end
|
162
|
+
@effect = effect
|
163
|
+
end
|
164
|
+
|
114
165
|
# Checks equality by comparing each attribute.
|
115
166
|
# @param [Object] Object to be compared
|
116
167
|
def ==(o)
|
@@ -119,7 +170,8 @@ module Shotstack
|
|
119
170
|
type == o.type &&
|
120
171
|
src == o.src &&
|
121
172
|
trim == o.trim &&
|
122
|
-
volume == o.volume
|
173
|
+
volume == o.volume &&
|
174
|
+
effect == o.effect
|
123
175
|
end
|
124
176
|
|
125
177
|
# @see the `==` method
|
@@ -131,7 +183,7 @@ module Shotstack
|
|
131
183
|
# Calculates hash code according to all attributes.
|
132
184
|
# @return [Integer] Hash code
|
133
185
|
def hash
|
134
|
-
[type, src, trim, volume].hash
|
186
|
+
[type, src, trim, volume, effect].hash
|
135
187
|
end
|
136
188
|
|
137
189
|
# Builds the object from hash
|
@@ -147,7 +199,9 @@ module Shotstack
|
|
147
199
|
def build_from_hash(attributes)
|
148
200
|
return nil unless attributes.is_a?(Hash)
|
149
201
|
self.class.openapi_types.each_pair do |key, type|
|
150
|
-
if
|
202
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
203
|
+
self.send("#{key}=", nil)
|
204
|
+
elsif type =~ /\AArray<(.*)>/i
|
151
205
|
# check to ensure the input is an array given that the attribute
|
152
206
|
# is documented as an array but the input is not
|
153
207
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -155,7 +209,7 @@ module Shotstack
|
|
155
209
|
end
|
156
210
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
157
211
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
158
|
-
end
|
212
|
+
end
|
159
213
|
end
|
160
214
|
|
161
215
|
self
|
@@ -167,8 +221,8 @@ module Shotstack
|
|
167
221
|
# @return [Object] Deserialized data
|
168
222
|
def _deserialize(type, value)
|
169
223
|
case type.to_sym
|
170
|
-
when :
|
171
|
-
|
224
|
+
when :Time
|
225
|
+
Time.parse(value)
|
172
226
|
when :Date
|
173
227
|
Date.parse(value)
|
174
228
|
when :String
|
@@ -198,7 +252,9 @@ module Shotstack
|
|
198
252
|
end
|
199
253
|
end
|
200
254
|
else # model
|
201
|
-
|
255
|
+
# models (e.g. Pet) or oneOf
|
256
|
+
klass = Shotstack.const_get(type)
|
257
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
202
258
|
end
|
203
259
|
end
|
204
260
|
|
@@ -224,7 +280,7 @@ module Shotstack
|
|
224
280
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
225
281
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
226
282
|
end
|
227
|
-
|
283
|
+
|
228
284
|
hash[param] = _to_hash(value)
|
229
285
|
end
|
230
286
|
hash
|
@@ -247,5 +303,7 @@ module Shotstack
|
|
247
303
|
value
|
248
304
|
end
|
249
305
|
end
|
306
|
+
|
250
307
|
end
|
308
|
+
|
251
309
|
end
|