shotstack 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +17 -0
  3. data/lib/shotstack.rb +24 -15
  4. data/lib/shotstack/api/default_api.rb +131 -0
  5. data/lib/shotstack/api_client.rb +120 -51
  6. data/lib/shotstack/api_error.rb +38 -5
  7. data/lib/shotstack/configuration.rb +90 -3
  8. data/lib/shotstack/models/asset.rb +17 -0
  9. data/lib/shotstack/models/clip.rb +308 -0
  10. data/lib/shotstack/models/edit.rb +104 -45
  11. data/lib/shotstack/models/image_asset.rb +221 -0
  12. data/lib/shotstack/models/output.rb +128 -41
  13. data/lib/shotstack/models/queued_response.rb +110 -48
  14. data/lib/shotstack/models/queued_response_data.rb +105 -45
  15. data/lib/shotstack/models/render_response.rb +110 -48
  16. data/lib/shotstack/models/render_response_data.rb +172 -68
  17. data/lib/shotstack/models/soundtrack.rb +106 -45
  18. data/lib/shotstack/models/timeline.rb +101 -46
  19. data/lib/shotstack/models/title_asset.rb +265 -0
  20. data/lib/shotstack/models/track.rb +89 -33
  21. data/lib/shotstack/models/transition.rb +121 -42
  22. data/lib/shotstack/models/video_asset.rb +241 -0
  23. data/lib/shotstack/version.rb +13 -1
  24. data/shotstack.gemspec +26 -13
  25. metadata +38 -40
  26. data/lib/shotstack/api/render_api.rb +0 -137
  27. data/lib/shotstack/models/clips.rb +0 -147
  28. data/lib/shotstack/models/image_clip.rb +0 -216
  29. data/lib/shotstack/models/image_clip_options.rb +0 -175
  30. data/lib/shotstack/models/title_clip.rb +0 -216
  31. data/lib/shotstack/models/title_clip_options.rb +0 -194
  32. data/lib/shotstack/models/video_clip.rb +0 -216
  33. data/lib/shotstack/models/video_clip_options.rb +0 -185
  34. data/tags +0 -306
@@ -1,136 +1,233 @@
1
+ =begin
2
+ #shotstack
3
+
4
+ #The Shotstack API is a video editing service that allows for the programatic creation of videos using JSON.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0-beta3
10
+
11
+ =end
12
+
1
13
  require 'date'
2
14
 
3
15
  module Shotstack
4
- # Model for RenderResponseData
5
16
  class RenderResponseData
6
- attr_accessor :created
7
-
8
- attr_accessor :data
17
+ # The status of the render task
18
+ attr_accessor :status
9
19
 
20
+ # The id of the render task in UUID format
10
21
  attr_accessor :id
11
22
 
23
+ # The owner id of the render task
12
24
  attr_accessor :owner
13
25
 
14
- attr_accessor :status
26
+ attr_accessor :data
27
+
28
+ # The time the render task was initially queued
29
+ attr_accessor :created
15
30
 
31
+ # The time the render status was last updated
16
32
  attr_accessor :updated
17
33
 
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
18
56
  # Attribute mapping from ruby-style variable name to JSON key.
19
57
  def self.attribute_map
20
58
  {
21
-
22
- :'created' => :'created',
23
-
24
- :'data' => :'data',
25
-
59
+ :'status' => :'status',
26
60
  :'id' => :'id',
27
-
28
61
  :'owner' => :'owner',
29
-
30
- :'status' => :'status',
31
-
62
+ :'data' => :'data',
63
+ :'created' => :'created',
32
64
  :'updated' => :'updated'
33
-
34
65
  }
35
66
  end
36
67
 
37
68
  # Attribute type mapping.
38
- def self.swagger_types
69
+ def self.openapi_types
39
70
  {
40
- :'created' => :'String',
41
- :'data' => :'Edit',
71
+ :'status' => :'String',
42
72
  :'id' => :'String',
43
73
  :'owner' => :'String',
44
- :'status' => :'String',
74
+ :'data' => :'Edit',
75
+ :'created' => :'String',
45
76
  :'updated' => :'String'
46
-
47
77
  }
48
78
  end
49
79
 
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
50
82
  def initialize(attributes = {})
51
- return unless attributes.is_a?(Hash)
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::RenderResponseData` initialize method"
85
+ end
52
86
 
53
- # convert string to symbol for hash key
54
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::RenderResponseData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
55
94
 
56
-
57
- if attributes[:'created']
58
- self.created = attributes[:'created']
59
- end
60
-
61
- if attributes[:'data']
62
- self.data = attributes[:'data']
95
+ if attributes.key?(:'status')
96
+ self.status = attributes[:'status']
63
97
  end
64
-
65
- if attributes[:'id']
98
+
99
+ if attributes.key?(:'id')
66
100
  self.id = attributes[:'id']
67
101
  end
68
-
69
- if attributes[:'owner']
102
+
103
+ if attributes.key?(:'owner')
70
104
  self.owner = attributes[:'owner']
71
105
  end
72
-
73
- if attributes[:'status']
74
- self.status = attributes[:'status']
106
+
107
+ if attributes.key?(:'data')
108
+ self.data = attributes[:'data']
75
109
  end
76
-
77
- if attributes[:'updated']
110
+
111
+ if attributes.key?(:'created')
112
+ self.created = attributes[:'created']
113
+ end
114
+
115
+ if attributes.key?(:'updated')
78
116
  self.updated = attributes[:'updated']
79
117
  end
80
-
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ if @status.nil?
125
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
126
+ end
127
+
128
+ if @id.nil?
129
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
130
+ end
131
+
132
+ if @owner.nil?
133
+ invalid_properties.push('invalid value for "owner", owner cannot be nil.')
134
+ end
135
+
136
+ if @data.nil?
137
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
138
+ end
139
+
140
+ if @created.nil?
141
+ invalid_properties.push('invalid value for "created", created cannot be nil.')
142
+ end
143
+
144
+ if @updated.nil?
145
+ invalid_properties.push('invalid value for "updated", updated cannot be nil.')
146
+ end
147
+
148
+ invalid_properties
149
+ end
150
+
151
+ # Check to see if the all the properties in the model are valid
152
+ # @return true if the model is valid
153
+ def valid?
154
+ return false if @status.nil?
155
+ status_validator = EnumAttributeValidator.new('String', ["queued", "fetching", "rendering", "saving", "done", "failed"])
156
+ return false unless status_validator.valid?(@status)
157
+ return false if @id.nil?
158
+ return false if @owner.nil?
159
+ return false if @data.nil?
160
+ return false if @created.nil?
161
+ return false if @updated.nil?
162
+ true
81
163
  end
82
164
 
83
165
  # Custom attribute writer method checking allowed values (enum).
166
+ # @param [Object] status Object to be assigned
84
167
  def status=(status)
85
- allowed_values = ["queued", "fetching", "rendering", "saving", "done", "failed"]
86
- if status && !allowed_values.include?(status)
87
- fail "invalid value for 'status', must be one of #{allowed_values}"
168
+ validator = EnumAttributeValidator.new('String', ["queued", "fetching", "rendering", "saving", "done", "failed"])
169
+ unless validator.valid?(status)
170
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
88
171
  end
89
172
  @status = status
90
173
  end
91
174
 
92
- # Check equality by comparing each attribute.
175
+ # Checks equality by comparing each attribute.
176
+ # @param [Object] Object to be compared
93
177
  def ==(o)
94
178
  return true if self.equal?(o)
95
179
  self.class == o.class &&
96
- created == o.created &&
97
- data == o.data &&
180
+ status == o.status &&
98
181
  id == o.id &&
99
182
  owner == o.owner &&
100
- status == o.status &&
183
+ data == o.data &&
184
+ created == o.created &&
101
185
  updated == o.updated
102
186
  end
103
187
 
104
188
  # @see the `==` method
189
+ # @param [Object] Object to be compared
105
190
  def eql?(o)
106
191
  self == o
107
192
  end
108
193
 
109
- # Calculate hash code according to all attributes.
194
+ # Calculates hash code according to all attributes.
195
+ # @return [Integer] Hash code
110
196
  def hash
111
- [created, data, id, owner, status, updated].hash
197
+ [status, id, owner, data, created, updated].hash
112
198
  end
113
199
 
114
- # build the object from hash
200
+ # Builds the object from hash
201
+ # @param [Hash] attributes Model attributes in the form of hash
202
+ # @return [Object] Returns the model itself
203
+ def self.build_from_hash(attributes)
204
+ new.build_from_hash(attributes)
205
+ end
206
+
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
115
210
  def build_from_hash(attributes)
116
211
  return nil unless attributes.is_a?(Hash)
117
- self.class.swagger_types.each_pair do |key, type|
118
- if type =~ /^Array<(.*)>/i
212
+ self.class.openapi_types.each_pair do |key, type|
213
+ if type =~ /\AArray<(.*)>/i
214
+ # check to ensure the input is an array given that the attribute
215
+ # is documented as an array but the input is not
119
216
  if attributes[self.class.attribute_map[key]].is_a?(Array)
120
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
121
- else
122
- #TODO show warning in debug mode
217
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
123
218
  end
124
219
  elsif !attributes[self.class.attribute_map[key]].nil?
125
220
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
126
- else
127
- # data not found in attributes(hash), not an issue as the data can be optional
128
- end
221
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
129
222
  end
130
223
 
131
224
  self
132
225
  end
133
226
 
227
+ # Deserializes the data based on type
228
+ # @param string type Data type
229
+ # @param string value Value to be deserialized
230
+ # @return [Object] Deserialized data
134
231
  def _deserialize(type, value)
135
232
  case type.to_sym
136
233
  when :DateTime
@@ -143,16 +240,19 @@ module Shotstack
143
240
  value.to_i
144
241
  when :Float
145
242
  value.to_f
146
- when :BOOLEAN
147
- if value =~ /^(true|t|yes|y|1)$/i
243
+ when :Boolean
244
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
245
  true
149
246
  else
150
247
  false
151
248
  end
249
+ when :Object
250
+ # generic object (usually a Hash), return directly
251
+ value
152
252
  when /\AArray<(?<inner_type>.+)>\z/
153
253
  inner_type = Regexp.last_match[:inner_type]
154
254
  value.map { |v| _deserialize(inner_type, v) }
155
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
255
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
256
  k_type = Regexp.last_match[:k_type]
157
257
  v_type = Regexp.last_match[:v_type]
158
258
  {}.tap do |hash|
@@ -161,21 +261,24 @@ module Shotstack
161
261
  end
162
262
  end
163
263
  else # model
164
- _model = Shotstack.const_get(type).new
165
- _model.build_from_hash(value)
264
+ Shotstack.const_get(type).build_from_hash(value)
166
265
  end
167
266
  end
168
267
 
268
+ # Returns the string representation of the object
269
+ # @return [String] String presentation of the object
169
270
  def to_s
170
271
  to_hash.to_s
171
272
  end
172
273
 
173
- # to_body is an alias to to_body (backward compatibility))
274
+ # to_body is an alias to to_hash (backward compatibility)
275
+ # @return [Hash] Returns the object in the form of hash
174
276
  def to_body
175
277
  to_hash
176
278
  end
177
279
 
178
- # return the object in the form of hash
280
+ # Returns the object in the form of hash
281
+ # @return [Hash] Returns the object in the form of hash
179
282
  def to_hash
180
283
  hash = {}
181
284
  self.class.attribute_map.each_pair do |attr, param|
@@ -186,11 +289,13 @@ module Shotstack
186
289
  hash
187
290
  end
188
291
 
189
- # Method to output non-array value in the form of hash
292
+ # Outputs non-array value in the form of hash
190
293
  # For object, use to_hash. Otherwise, just return the value
294
+ # @param [Object] value Any valid value
295
+ # @return [Hash] Returns the value in the form of hash
191
296
  def _to_hash(value)
192
297
  if value.is_a?(Array)
193
- value.compact.map{ |v| _to_hash(v) }
298
+ value.compact.map { |v| _to_hash(v) }
194
299
  elsif value.is_a?(Hash)
195
300
  {}.tap do |hash|
196
301
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -201,6 +306,5 @@ module Shotstack
201
306
  value
202
307
  end
203
308
  end
204
-
205
309
  end
206
310
  end
@@ -1,87 +1,141 @@
1
+ =begin
2
+ #shotstack
3
+
4
+ #The Shotstack API is a video editing service that allows for the programatic creation of videos using JSON.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0-beta3
10
+
11
+ =end
12
+
1
13
  require 'date'
2
14
 
3
15
  module Shotstack
4
- # Model for Soundtrack
16
+ # A music or audio file in mp3 format that plays for the duration of the rendered video or the length of the audio file, which ever is shortest.
5
17
  class Soundtrack
6
- attr_accessor :effect
7
-
18
+ # The URL of the mp3 audio file. The URL must be publicly accessible or include credentials.
8
19
  attr_accessor :src
9
20
 
21
+ # The effect to apply to the audio file
22
+ attr_accessor :effect
23
+
10
24
  # Attribute mapping from ruby-style variable name to JSON key.
11
25
  def self.attribute_map
12
26
  {
13
-
14
- :'effect' => :'effect',
15
-
16
- :'src' => :'src'
17
-
27
+ :'src' => :'src',
28
+ :'effect' => :'effect'
18
29
  }
19
30
  end
20
31
 
21
32
  # Attribute type mapping.
22
- def self.swagger_types
33
+ def self.openapi_types
23
34
  {
24
- :'effect' => :'String',
25
- :'src' => :'String'
26
-
35
+ :'src' => :'String',
36
+ :'effect' => :'String'
27
37
  }
28
38
  end
29
39
 
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
30
42
  def initialize(attributes = {})
31
- return unless attributes.is_a?(Hash)
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Soundtrack` initialize method"
45
+ end
32
46
 
33
- # convert string to symbol for hash key
34
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h|
49
+ if (!self.class.attribute_map.key?(k.to_sym))
50
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Soundtrack`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'src')
56
+ self.src = attributes[:'src']
57
+ end
35
58
 
36
-
37
- if attributes[:'effect']
59
+ if attributes.key?(:'effect')
38
60
  self.effect = attributes[:'effect']
39
61
  end
40
-
41
- if attributes[:'src']
42
- self.src = attributes[:'src']
62
+ end
63
+
64
+ # Show invalid properties with the reasons. Usually used together with valid?
65
+ # @return Array for valid properties with the reasons
66
+ def list_invalid_properties
67
+ invalid_properties = Array.new
68
+ if @src.nil?
69
+ invalid_properties.push('invalid value for "src", src cannot be nil.')
43
70
  end
44
-
71
+
72
+ if @effect.nil?
73
+ invalid_properties.push('invalid value for "effect", effect cannot be nil.')
74
+ end
75
+
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ return false if @src.nil?
83
+ return false if @effect.nil?
84
+ true
45
85
  end
46
86
 
47
- # Check equality by comparing each attribute.
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
48
89
  def ==(o)
49
90
  return true if self.equal?(o)
50
91
  self.class == o.class &&
51
- effect == o.effect &&
52
- src == o.src
92
+ src == o.src &&
93
+ effect == o.effect
53
94
  end
54
95
 
55
96
  # @see the `==` method
97
+ # @param [Object] Object to be compared
56
98
  def eql?(o)
57
99
  self == o
58
100
  end
59
101
 
60
- # Calculate hash code according to all attributes.
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
61
104
  def hash
62
- [effect, src].hash
105
+ [src, effect].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ new.build_from_hash(attributes)
63
113
  end
64
114
 
65
- # build the object from hash
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
66
118
  def build_from_hash(attributes)
67
119
  return nil unless attributes.is_a?(Hash)
68
- self.class.swagger_types.each_pair do |key, type|
69
- if type =~ /^Array<(.*)>/i
120
+ self.class.openapi_types.each_pair do |key, type|
121
+ if type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
70
124
  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
125
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
74
126
  end
75
127
  elsif !attributes[self.class.attribute_map[key]].nil?
76
128
  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
129
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
80
130
  end
81
131
 
82
132
  self
83
133
  end
84
134
 
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
85
139
  def _deserialize(type, value)
86
140
  case type.to_sym
87
141
  when :DateTime
@@ -94,16 +148,19 @@ module Shotstack
94
148
  value.to_i
95
149
  when :Float
96
150
  value.to_f
97
- when :BOOLEAN
98
- if value =~ /^(true|t|yes|y|1)$/i
151
+ when :Boolean
152
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
99
153
  true
100
154
  else
101
155
  false
102
156
  end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
103
160
  when /\AArray<(?<inner_type>.+)>\z/
104
161
  inner_type = Regexp.last_match[:inner_type]
105
162
  value.map { |v| _deserialize(inner_type, v) }
106
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
163
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
107
164
  k_type = Regexp.last_match[:k_type]
108
165
  v_type = Regexp.last_match[:v_type]
109
166
  {}.tap do |hash|
@@ -112,21 +169,24 @@ module Shotstack
112
169
  end
113
170
  end
114
171
  else # model
115
- _model = Shotstack.const_get(type).new
116
- _model.build_from_hash(value)
172
+ Shotstack.const_get(type).build_from_hash(value)
117
173
  end
118
174
  end
119
175
 
176
+ # Returns the string representation of the object
177
+ # @return [String] String presentation of the object
120
178
  def to_s
121
179
  to_hash.to_s
122
180
  end
123
181
 
124
- # to_body is an alias to to_body (backward compatibility))
182
+ # to_body is an alias to to_hash (backward compatibility)
183
+ # @return [Hash] Returns the object in the form of hash
125
184
  def to_body
126
185
  to_hash
127
186
  end
128
187
 
129
- # return the object in the form of hash
188
+ # Returns the object in the form of hash
189
+ # @return [Hash] Returns the object in the form of hash
130
190
  def to_hash
131
191
  hash = {}
132
192
  self.class.attribute_map.each_pair do |attr, param|
@@ -137,11 +197,13 @@ module Shotstack
137
197
  hash
138
198
  end
139
199
 
140
- # Method to output non-array value in the form of hash
200
+ # Outputs non-array value in the form of hash
141
201
  # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
142
204
  def _to_hash(value)
143
205
  if value.is_a?(Array)
144
- value.compact.map{ |v| _to_hash(v) }
206
+ value.compact.map { |v| _to_hash(v) }
145
207
  elsif value.is_a?(Hash)
146
208
  {}.tap do |hash|
147
209
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -152,6 +214,5 @@ module Shotstack
152
214
  value
153
215
  end
154
216
  end
155
-
156
217
  end
157
218
  end