shotstack 0.0.10 → 0.1.3

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.
@@ -0,0 +1,253 @@
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 `audio` 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
+ else
89
+ self.volume = 1
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ if @type.nil?
98
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
99
+ end
100
+
101
+ if @src.nil?
102
+ invalid_properties.push('invalid value for "src", src cannot be nil.')
103
+ end
104
+
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ return false if @type.nil?
112
+ return false if @src.nil?
113
+ true
114
+ end
115
+
116
+ # Checks equality by comparing each attribute.
117
+ # @param [Object] Object to be compared
118
+ def ==(o)
119
+ return true if self.equal?(o)
120
+ self.class == o.class &&
121
+ type == o.type &&
122
+ src == o.src &&
123
+ trim == o.trim &&
124
+ volume == o.volume
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [type, src, trim, volume].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :DateTime
173
+ DateTime.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ Shotstack.const_get(type).build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+ end
253
+ end
@@ -1,21 +1,21 @@
1
1
  =begin
2
- #shotstack
2
+ #Shotstack
3
3
 
4
- #The Shotstack API is a video editing service that allows for the programatic creation of videos using JSON.
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 spec version: v1
6
+ The version of the OpenAPI document: v1
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.0.0-beta3
9
+ OpenAPI Generator version: 4.2.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
14
 
15
15
  module Shotstack
16
- # A clip is a container for a specific type of asset, i.e. a title, photo or video. You use a Clip to define when an asset will display on the timeline, how long it will play for and transitions and effects to apply to it.
16
+ # A clip is a container for a specific type of asset, i.e. a title, image, video, audio or html. You use a Clip to define when an asset will display on the timeline, how long it will play for and transitions, filters and effects to apply to it.
17
17
  class Clip
18
- # The type of asset to display for the duration of this Clip. Value must be one of <b>TitleAsset</b>, <b>ImageAsset</b> or <b>VideoAsset</b>.
18
+ # The type of asset to display for the duration of this Clip. Value must be one of <b>TitleAsset</b>, <b>ImageAsset</b>, <b>VideoAsset</b>, <b>HtmlAsset</b>, <b>AudioAsset</b> or <b>LumaAsset</b>
19
19
  attr_accessor :asset
20
20
 
21
21
  # The start position of the Clip on the timeline, in seconds.
@@ -24,14 +24,28 @@ module Shotstack
24
24
  # The length, in seconds, the Clip should play for.
25
25
  attr_accessor :length
26
26
 
27
+ # Set how the asset should be scaled to fit the viewport using one of the following options: <ul> <li>`cover` - stretch the asset to fill the viewport without maintaining the aspect ratio.</li> <li>`contain` - fit the entire asset within the viewport while maintaining the original aspect ratio.</li> <li>`crop` - scale the asset to fill the viewport while maintaining the aspect ratio. The asset will be cropped if it exceeds the bounds of the viewport.</li> <li>`none` - preserves the original asset dimensions and does not apply any scaling.</li> </ul>
28
+ attr_accessor :fit
29
+
30
+ # Scale the asset to a fraction of the viewport size - i.e. setting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks.
31
+ attr_accessor :scale
32
+
33
+ # Place the asset in one of nine predefined positions of the viewport. This is most effective for when the asset is scaled and you want to position the element to a specific position. <ul> <li>`top` - top (center)</li> <li>`topRight` - top right</li> <li>`right` - right (center)</li> <li>`bottomRight` - bottom right</li> <li>`bottom` - bottom (center)</li> <li>`bottomLeft` - bottom left</li> <li>`left` - left (center)</li> <li>`topLeft` - top left</li> <li>`center` - center</li> </ul>
34
+ attr_accessor :position
35
+
36
+ attr_accessor :offset
37
+
27
38
  attr_accessor :transition
28
39
 
29
- # A motion effect to apply to the Clip.
40
+ # A motion effect to apply to the Clip. <ul> <li>`zoomIn` - slow zoom in</li> <li>`zoomOut` - slow zoom out</li> <li>`slideLeft` - slow slide (pan) left</li> <li>`slideRight` - slow slide (pan) right</li> <li>`slideUp` - slow slide (pan) up</li> <li>`slideDown` - slow slide (pan) down</li> </ul>
30
41
  attr_accessor :effect
31
42
 
32
- # A filter effect to apply to the Clip.
43
+ # A filter effect to apply to the Clip. <ul> <li>`blur` - blurs the image or video</li> <li>`boost` - boost contrast and saturation</li> <li>`contrast` - increase contrast</li> <li>`darken` - darken the scene</li> <li>`greyscale` - remove colour</li> <li>`lighten` - lighten the scene</li> <li>`muted` - reduce saturation and contrast</li> <li>`invert` - invert colors</li> </ul>
33
44
  attr_accessor :filter
34
45
 
46
+ # Sets the opacity of the Clip where 1 is opaque and 0 is transparent.
47
+ attr_accessor :opacity
48
+
35
49
  class EnumAttributeValidator
36
50
  attr_reader :datatype
37
51
  attr_reader :allowable_values
@@ -60,9 +74,14 @@ module Shotstack
60
74
  :'asset' => :'asset',
61
75
  :'start' => :'start',
62
76
  :'length' => :'length',
77
+ :'fit' => :'fit',
78
+ :'scale' => :'scale',
79
+ :'position' => :'position',
80
+ :'offset' => :'offset',
63
81
  :'transition' => :'transition',
64
82
  :'effect' => :'effect',
65
- :'filter' => :'filter'
83
+ :'filter' => :'filter',
84
+ :'opacity' => :'opacity'
66
85
  }
67
86
  end
68
87
 
@@ -72,12 +91,23 @@ module Shotstack
72
91
  :'asset' => :'Asset',
73
92
  :'start' => :'Float',
74
93
  :'length' => :'Float',
94
+ :'fit' => :'String',
95
+ :'scale' => :'Float',
96
+ :'position' => :'String',
97
+ :'offset' => :'Offset',
75
98
  :'transition' => :'Transition',
76
99
  :'effect' => :'String',
77
- :'filter' => :'String'
100
+ :'filter' => :'String',
101
+ :'opacity' => :'Float'
78
102
  }
79
103
  end
80
104
 
105
+ # List of attributes with nullable: true
106
+ def self.openapi_nullable
107
+ Set.new([
108
+ ])
109
+ end
110
+
81
111
  # Initializes the object
82
112
  # @param [Hash] attributes Model attributes in the form of hash
83
113
  def initialize(attributes = {})
@@ -105,6 +135,26 @@ module Shotstack
105
135
  self.length = attributes[:'length']
106
136
  end
107
137
 
138
+ if attributes.key?(:'fit')
139
+ self.fit = attributes[:'fit']
140
+ else
141
+ self.fit = 'crop'
142
+ end
143
+
144
+ if attributes.key?(:'scale')
145
+ self.scale = attributes[:'scale']
146
+ end
147
+
148
+ if attributes.key?(:'position')
149
+ self.position = attributes[:'position']
150
+ else
151
+ self.position = 'center'
152
+ end
153
+
154
+ if attributes.key?(:'offset')
155
+ self.offset = attributes[:'offset']
156
+ end
157
+
108
158
  if attributes.key?(:'transition')
109
159
  self.transition = attributes[:'transition']
110
160
  end
@@ -116,6 +166,12 @@ module Shotstack
116
166
  if attributes.key?(:'filter')
117
167
  self.filter = attributes[:'filter']
118
168
  end
169
+
170
+ if attributes.key?(:'opacity')
171
+ self.opacity = attributes[:'opacity']
172
+ else
173
+ self.opacity = 1
174
+ end
119
175
  end
120
176
 
121
177
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -143,13 +199,37 @@ module Shotstack
143
199
  return false if @asset.nil?
144
200
  return false if @start.nil?
145
201
  return false if @length.nil?
202
+ fit_validator = EnumAttributeValidator.new('String', ["cover", "contain", "crop", "none"])
203
+ return false unless fit_validator.valid?(@fit)
204
+ position_validator = EnumAttributeValidator.new('String', ["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"])
205
+ return false unless position_validator.valid?(@position)
146
206
  effect_validator = EnumAttributeValidator.new('String', ["zoomIn", "zoomOut", "slideLeft", "slideRight", "slideUp", "slideDown"])
147
207
  return false unless effect_validator.valid?(@effect)
148
- filter_validator = EnumAttributeValidator.new('String', ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
208
+ filter_validator = EnumAttributeValidator.new('String', ["blur", "boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
149
209
  return false unless filter_validator.valid?(@filter)
150
210
  true
151
211
  end
152
212
 
213
+ # Custom attribute writer method checking allowed values (enum).
214
+ # @param [Object] fit Object to be assigned
215
+ def fit=(fit)
216
+ validator = EnumAttributeValidator.new('String', ["cover", "contain", "crop", "none"])
217
+ unless validator.valid?(fit)
218
+ fail ArgumentError, "invalid value for \"fit\", must be one of #{validator.allowable_values}."
219
+ end
220
+ @fit = fit
221
+ end
222
+
223
+ # Custom attribute writer method checking allowed values (enum).
224
+ # @param [Object] position Object to be assigned
225
+ def position=(position)
226
+ validator = EnumAttributeValidator.new('String', ["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"])
227
+ unless validator.valid?(position)
228
+ fail ArgumentError, "invalid value for \"position\", must be one of #{validator.allowable_values}."
229
+ end
230
+ @position = position
231
+ end
232
+
153
233
  # Custom attribute writer method checking allowed values (enum).
154
234
  # @param [Object] effect Object to be assigned
155
235
  def effect=(effect)
@@ -163,7 +243,7 @@ module Shotstack
163
243
  # Custom attribute writer method checking allowed values (enum).
164
244
  # @param [Object] filter Object to be assigned
165
245
  def filter=(filter)
166
- validator = EnumAttributeValidator.new('String', ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
246
+ validator = EnumAttributeValidator.new('String', ["blur", "boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
167
247
  unless validator.valid?(filter)
168
248
  fail ArgumentError, "invalid value for \"filter\", must be one of #{validator.allowable_values}."
169
249
  end
@@ -178,9 +258,14 @@ module Shotstack
178
258
  asset == o.asset &&
179
259
  start == o.start &&
180
260
  length == o.length &&
261
+ fit == o.fit &&
262
+ scale == o.scale &&
263
+ position == o.position &&
264
+ offset == o.offset &&
181
265
  transition == o.transition &&
182
266
  effect == o.effect &&
183
- filter == o.filter
267
+ filter == o.filter &&
268
+ opacity == o.opacity
184
269
  end
185
270
 
186
271
  # @see the `==` method
@@ -192,7 +277,7 @@ module Shotstack
192
277
  # Calculates hash code according to all attributes.
193
278
  # @return [Integer] Hash code
194
279
  def hash
195
- [asset, start, length, transition, effect, filter].hash
280
+ [asset, start, length, fit, scale, position, offset, transition, effect, filter, opacity].hash
196
281
  end
197
282
 
198
283
  # Builds the object from hash
@@ -281,7 +366,11 @@ module Shotstack
281
366
  hash = {}
282
367
  self.class.attribute_map.each_pair do |attr, param|
283
368
  value = self.send(attr)
284
- next if value.nil?
369
+ if value.nil?
370
+ is_nullable = self.class.openapi_nullable.include?(attr)
371
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
372
+ end
373
+
285
374
  hash[param] = _to_hash(value)
286
375
  end
287
376
  hash