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,43 +1,79 @@
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 Track
16
+ # A track contains an array of clips. Tracks are layered on top of each other in the order in the array. The top most track will render on top of those below it.
5
17
  class Track
18
+ # An array of Clips comprising of TitleClip, ImageClip or VideoClip.
6
19
  attr_accessor :clips
7
20
 
8
21
  # Attribute mapping from ruby-style variable name to JSON key.
9
22
  def self.attribute_map
10
23
  {
11
-
12
24
  :'clips' => :'clips'
13
-
14
25
  }
15
26
  end
16
27
 
17
28
  # Attribute type mapping.
18
- def self.swagger_types
29
+ def self.openapi_types
19
30
  {
20
- :'clips' => :'Array<Clips>'
21
-
31
+ :'clips' => :'Array<Clip>'
22
32
  }
23
33
  end
24
34
 
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
25
37
  def initialize(attributes = {})
26
- return unless attributes.is_a?(Hash)
38
+ if (!attributes.is_a?(Hash))
39
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Track` initialize method"
40
+ end
27
41
 
28
- # convert string to symbol for hash key
29
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
42
+ # check to see if the attribute exists and convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h|
44
+ if (!self.class.attribute_map.key?(k.to_sym))
45
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Track`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46
+ end
47
+ h[k.to_sym] = v
48
+ }
30
49
 
31
-
32
- if attributes[:'clips']
50
+ if attributes.key?(:'clips')
33
51
  if (value = attributes[:'clips']).is_a?(Array)
34
52
  self.clips = value
35
53
  end
36
54
  end
37
-
38
55
  end
39
56
 
40
- # Check equality by comparing each attribute.
57
+ # Show invalid properties with the reasons. Usually used together with valid?
58
+ # @return Array for valid properties with the reasons
59
+ def list_invalid_properties
60
+ invalid_properties = Array.new
61
+ if @clips.nil?
62
+ invalid_properties.push('invalid value for "clips", clips cannot be nil.')
63
+ end
64
+
65
+ invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return false if @clips.nil?
72
+ true
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
41
77
  def ==(o)
42
78
  return true if self.equal?(o)
43
79
  self.class == o.class &&
@@ -45,35 +81,48 @@ module Shotstack
45
81
  end
46
82
 
47
83
  # @see the `==` method
84
+ # @param [Object] Object to be compared
48
85
  def eql?(o)
49
86
  self == o
50
87
  end
51
88
 
52
- # Calculate hash code according to all attributes.
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Integer] Hash code
53
91
  def hash
54
92
  [clips].hash
55
93
  end
56
94
 
57
- # build the object from hash
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def self.build_from_hash(attributes)
99
+ new.build_from_hash(attributes)
100
+ end
101
+
102
+ # Builds the object from hash
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ # @return [Object] Returns the model itself
58
105
  def build_from_hash(attributes)
59
106
  return nil unless attributes.is_a?(Hash)
60
- self.class.swagger_types.each_pair do |key, type|
61
- if type =~ /^Array<(.*)>/i
107
+ self.class.openapi_types.each_pair do |key, type|
108
+ if type =~ /\AArray<(.*)>/i
109
+ # check to ensure the input is an array given that the attribute
110
+ # is documented as an array but the input is not
62
111
  if attributes[self.class.attribute_map[key]].is_a?(Array)
63
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
64
- else
65
- #TODO show warning in debug mode
112
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
66
113
  end
67
114
  elsif !attributes[self.class.attribute_map[key]].nil?
68
115
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
69
- else
70
- # data not found in attributes(hash), not an issue as the data can be optional
71
- end
116
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
72
117
  end
73
118
 
74
119
  self
75
120
  end
76
121
 
122
+ # Deserializes the data based on type
123
+ # @param string type Data type
124
+ # @param string value Value to be deserialized
125
+ # @return [Object] Deserialized data
77
126
  def _deserialize(type, value)
78
127
  case type.to_sym
79
128
  when :DateTime
@@ -86,16 +135,19 @@ module Shotstack
86
135
  value.to_i
87
136
  when :Float
88
137
  value.to_f
89
- when :BOOLEAN
90
- if value =~ /^(true|t|yes|y|1)$/i
138
+ when :Boolean
139
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
91
140
  true
92
141
  else
93
142
  false
94
143
  end
144
+ when :Object
145
+ # generic object (usually a Hash), return directly
146
+ value
95
147
  when /\AArray<(?<inner_type>.+)>\z/
96
148
  inner_type = Regexp.last_match[:inner_type]
97
149
  value.map { |v| _deserialize(inner_type, v) }
98
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
150
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
99
151
  k_type = Regexp.last_match[:k_type]
100
152
  v_type = Regexp.last_match[:v_type]
101
153
  {}.tap do |hash|
@@ -104,21 +156,24 @@ module Shotstack
104
156
  end
105
157
  end
106
158
  else # model
107
- _model = Shotstack.const_get(type).new
108
- _model.build_from_hash(value)
159
+ Shotstack.const_get(type).build_from_hash(value)
109
160
  end
110
161
  end
111
162
 
163
+ # Returns the string representation of the object
164
+ # @return [String] String presentation of the object
112
165
  def to_s
113
166
  to_hash.to_s
114
167
  end
115
168
 
116
- # to_body is an alias to to_body (backward compatibility))
169
+ # to_body is an alias to to_hash (backward compatibility)
170
+ # @return [Hash] Returns the object in the form of hash
117
171
  def to_body
118
172
  to_hash
119
173
  end
120
174
 
121
- # return the object in the form of hash
175
+ # Returns the object in the form of hash
176
+ # @return [Hash] Returns the object in the form of hash
122
177
  def to_hash
123
178
  hash = {}
124
179
  self.class.attribute_map.each_pair do |attr, param|
@@ -129,11 +184,13 @@ module Shotstack
129
184
  hash
130
185
  end
131
186
 
132
- # Method to output non-array value in the form of hash
187
+ # Outputs non-array value in the form of hash
133
188
  # For object, use to_hash. Otherwise, just return the value
189
+ # @param [Object] value Any valid value
190
+ # @return [Hash] Returns the value in the form of hash
134
191
  def _to_hash(value)
135
192
  if value.is_a?(Array)
136
- value.compact.map{ |v| _to_hash(v) }
193
+ value.compact.map { |v| _to_hash(v) }
137
194
  elsif value.is_a?(Hash)
138
195
  {}.tap do |hash|
139
196
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -144,6 +201,5 @@ module Shotstack
144
201
  value
145
202
  end
146
203
  end
147
-
148
204
  end
149
205
  end
@@ -1,68 +1,127 @@
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 Transition
16
+ # In and out transitions for a clip - i.e. fade in and fade out
5
17
  class Transition
18
+ # The transition in
6
19
  attr_accessor :_in
7
20
 
21
+ # The transition out
8
22
  attr_accessor :out
9
23
 
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
10
46
  # Attribute mapping from ruby-style variable name to JSON key.
11
47
  def self.attribute_map
12
48
  {
13
-
14
49
  :'_in' => :'in',
15
-
16
50
  :'out' => :'out'
17
-
18
51
  }
19
52
  end
20
53
 
21
54
  # Attribute type mapping.
22
- def self.swagger_types
55
+ def self.openapi_types
23
56
  {
24
57
  :'_in' => :'String',
25
58
  :'out' => :'String'
26
-
27
59
  }
28
60
  end
29
61
 
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
30
64
  def initialize(attributes = {})
31
- return unless attributes.is_a?(Hash)
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Transition` initialize method"
67
+ end
32
68
 
33
- # convert string to symbol for hash key
34
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Transition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
35
76
 
36
-
37
- if attributes[:'in']
38
- self._in = attributes[:'in']
77
+ if attributes.key?(:'_in')
78
+ self._in = attributes[:'_in']
39
79
  end
40
-
41
- if attributes[:'out']
80
+
81
+ if attributes.key?(:'out')
42
82
  self.out = attributes[:'out']
43
83
  end
44
-
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ _in_validator = EnumAttributeValidator.new('String', ["fade", "wipeLeft", "wipeRight"])
97
+ return false unless _in_validator.valid?(@_in)
98
+ out_validator = EnumAttributeValidator.new('String', ["fade", "wipeLeft", "wipeRight"])
99
+ return false unless out_validator.valid?(@out)
100
+ true
45
101
  end
46
102
 
47
103
  # Custom attribute writer method checking allowed values (enum).
104
+ # @param [Object] _in Object to be assigned
48
105
  def _in=(_in)
49
- allowed_values = ["fade", "wipeLeft", "wipeRight"]
50
- if _in && !allowed_values.include?(_in)
51
- fail "invalid value for '_in', must be one of #{allowed_values}"
106
+ validator = EnumAttributeValidator.new('String', ["fade", "wipeLeft", "wipeRight"])
107
+ unless validator.valid?(_in)
108
+ fail ArgumentError, "invalid value for \"_in\", must be one of #{validator.allowable_values}."
52
109
  end
53
110
  @_in = _in
54
111
  end
55
112
 
56
113
  # Custom attribute writer method checking allowed values (enum).
114
+ # @param [Object] out Object to be assigned
57
115
  def out=(out)
58
- allowed_values = ["fade", "wipeLeft", "wipeRight"]
59
- if out && !allowed_values.include?(out)
60
- fail "invalid value for 'out', must be one of #{allowed_values}"
116
+ validator = EnumAttributeValidator.new('String', ["fade", "wipeLeft", "wipeRight"])
117
+ unless validator.valid?(out)
118
+ fail ArgumentError, "invalid value for \"out\", must be one of #{validator.allowable_values}."
61
119
  end
62
120
  @out = out
63
121
  end
64
122
 
65
- # Check equality by comparing each attribute.
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
66
125
  def ==(o)
67
126
  return true if self.equal?(o)
68
127
  self.class == o.class &&
@@ -71,35 +130,48 @@ module Shotstack
71
130
  end
72
131
 
73
132
  # @see the `==` method
133
+ # @param [Object] Object to be compared
74
134
  def eql?(o)
75
135
  self == o
76
136
  end
77
137
 
78
- # Calculate hash code according to all attributes.
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
79
140
  def hash
80
141
  [_in, out].hash
81
142
  end
82
143
 
83
- # build the object from hash
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 self.build_from_hash(attributes)
148
+ new.build_from_hash(attributes)
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
84
154
  def build_from_hash(attributes)
85
155
  return nil unless attributes.is_a?(Hash)
86
- self.class.swagger_types.each_pair do |key, type|
87
- if type =~ /^Array<(.*)>/i
156
+ self.class.openapi_types.each_pair do |key, type|
157
+ if type =~ /\AArray<(.*)>/i
158
+ # check to ensure the input is an array given that the attribute
159
+ # is documented as an array but the input is not
88
160
  if attributes[self.class.attribute_map[key]].is_a?(Array)
89
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
90
- else
91
- #TODO show warning in debug mode
161
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
92
162
  end
93
163
  elsif !attributes[self.class.attribute_map[key]].nil?
94
164
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
95
- else
96
- # data not found in attributes(hash), not an issue as the data can be optional
97
- end
165
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
98
166
  end
99
167
 
100
168
  self
101
169
  end
102
170
 
171
+ # Deserializes the data based on type
172
+ # @param string type Data type
173
+ # @param string value Value to be deserialized
174
+ # @return [Object] Deserialized data
103
175
  def _deserialize(type, value)
104
176
  case type.to_sym
105
177
  when :DateTime
@@ -112,16 +184,19 @@ module Shotstack
112
184
  value.to_i
113
185
  when :Float
114
186
  value.to_f
115
- when :BOOLEAN
116
- if value =~ /^(true|t|yes|y|1)$/i
187
+ when :Boolean
188
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
117
189
  true
118
190
  else
119
191
  false
120
192
  end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
121
196
  when /\AArray<(?<inner_type>.+)>\z/
122
197
  inner_type = Regexp.last_match[:inner_type]
123
198
  value.map { |v| _deserialize(inner_type, v) }
124
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
199
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
125
200
  k_type = Regexp.last_match[:k_type]
126
201
  v_type = Regexp.last_match[:v_type]
127
202
  {}.tap do |hash|
@@ -130,21 +205,24 @@ module Shotstack
130
205
  end
131
206
  end
132
207
  else # model
133
- _model = Shotstack.const_get(type).new
134
- _model.build_from_hash(value)
208
+ Shotstack.const_get(type).build_from_hash(value)
135
209
  end
136
210
  end
137
211
 
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
138
214
  def to_s
139
215
  to_hash.to_s
140
216
  end
141
217
 
142
- # to_body is an alias to to_body (backward compatibility))
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
143
220
  def to_body
144
221
  to_hash
145
222
  end
146
223
 
147
- # return the object in the form of hash
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
148
226
  def to_hash
149
227
  hash = {}
150
228
  self.class.attribute_map.each_pair do |attr, param|
@@ -155,11 +233,13 @@ module Shotstack
155
233
  hash
156
234
  end
157
235
 
158
- # Method to output non-array value in the form of hash
236
+ # Outputs non-array value in the form of hash
159
237
  # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
160
240
  def _to_hash(value)
161
241
  if value.is_a?(Array)
162
- value.compact.map{ |v| _to_hash(v) }
242
+ value.compact.map { |v| _to_hash(v) }
163
243
  elsif value.is_a?(Hash)
164
244
  {}.tap do |hash|
165
245
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -170,6 +250,5 @@ module Shotstack
170
250
  value
171
251
  end
172
252
  end
173
-
174
253
  end
175
254
  end