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