shotstack 0.0.9 → 0.0.10

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.
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,3 +1,15 @@
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
  module Shotstack
2
14
  class ApiError < StandardError
3
15
  attr_reader :code, :response_headers, :response_body
@@ -9,16 +21,37 @@ module Shotstack
9
21
  # ApiError.new(:code => 404, :message => "Not Found")
10
22
  def initialize(arg = nil)
11
23
  if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
12
30
  arg.each do |k, v|
13
- if k.to_s == 'message'
14
- super v
15
- else
16
- instance_variable_set "@#{k}", v
17
- end
31
+ instance_variable_set "@#{k}", v
18
32
  end
19
33
  else
20
34
  super arg
21
35
  end
22
36
  end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
23
56
  end
24
57
  end
@@ -1,3 +1,15 @@
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 'uri'
2
14
 
3
15
  module Shotstack
@@ -64,7 +76,12 @@ module Shotstack
64
76
  # Default to 0 (never times out).
65
77
  attr_accessor :timeout
66
78
 
67
- ### TLS/SSL
79
+ # Set this to false to skip client side validation in the operation.
80
+ # Default to true.
81
+ # @return [true, false]
82
+ attr_accessor :client_side_validation
83
+
84
+ ### TLS/SSL setting
68
85
  # Set this to false to skip verifying SSL certificate when calling API from https server.
69
86
  # Default to true.
70
87
  #
@@ -73,6 +90,16 @@ module Shotstack
73
90
  # @return [true, false]
74
91
  attr_accessor :verify_ssl
75
92
 
93
+ ### TLS/SSL setting
94
+ # Set this to false to skip verifying SSL host name
95
+ # Default to true.
96
+ #
97
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
98
+ #
99
+ # @return [true, false]
100
+ attr_accessor :verify_ssl_host
101
+
102
+ ### TLS/SSL setting
76
103
  # Set this to customize the certificate file to verify the peer.
77
104
  #
78
105
  # @return [String] the path to the certificate file
@@ -81,12 +108,21 @@ module Shotstack
81
108
  # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
82
109
  attr_accessor :ssl_ca_cert
83
110
 
111
+ ### TLS/SSL setting
84
112
  # Client certificate file (for client certificate)
85
113
  attr_accessor :cert_file
86
114
 
115
+ ### TLS/SSL setting
87
116
  # Client private key file (for client certificate)
88
117
  attr_accessor :key_file
89
118
 
119
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
120
+ # Default to nil.
121
+ #
122
+ # @see The params_encoding option of Ethon. Related source code:
123
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
124
+ attr_accessor :params_encoding
125
+
90
126
  attr_accessor :inject_format
91
127
 
92
128
  attr_accessor :force_ending_format
@@ -94,11 +130,14 @@ module Shotstack
94
130
  def initialize
95
131
  @scheme = 'https'
96
132
  @host = 'api.shotstack.io'
97
- @base_path = '/v1'
133
+ @base_path = '/version'
98
134
  @api_key = {}
99
135
  @api_key_prefix = {}
100
136
  @timeout = 0
137
+ @client_side_validation = true
101
138
  @verify_ssl = true
139
+ @verify_ssl_host = true
140
+ @params_encoding = nil
102
141
  @cert_file = nil
103
142
  @key_file = nil
104
143
  @debugging = false
@@ -131,7 +170,7 @@ module Shotstack
131
170
  def base_path=(base_path)
132
171
  # Add leading and trailing slashes to base_path
133
172
  @base_path = "/#{base_path}".gsub(/\/+/, '/')
134
- @base_path = "" if @base_path == "/"
173
+ @base_path = '' if @base_path == '/'
135
174
  end
136
175
 
137
176
  def base_url
@@ -166,5 +205,53 @@ module Shotstack
166
205
  },
167
206
  }
168
207
  end
208
+
209
+ # Returns an array of Server setting
210
+ def server_settings
211
+ [
212
+ {
213
+ url: "https://api.shotstack.io/{version}",
214
+ description: "No descriptoin provided",
215
+ variables: {
216
+ version: {
217
+ description: "No descriptoin provided",
218
+ default_value: "version",
219
+ }
220
+ }
221
+ }
222
+ ]
223
+ end
224
+
225
+ # Returns URL based on server settings
226
+ #
227
+ # @param index array index of the server settings
228
+ # @param variables hash of variable and the corresponding value
229
+ def server_url(index, variables = {})
230
+ servers = server_settings
231
+
232
+ # check array index out of bound
233
+ if (index < 0 || index >= servers.size)
234
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
235
+ end
236
+
237
+ server = servers[index]
238
+ url = server[:url]
239
+
240
+ # go through variable and assign a value
241
+ server[:variables].each do |name, variable|
242
+ if variables.key?(name)
243
+ if (server[:variables][name][:enum_values].include? variables[name])
244
+ url.gsub! "{" + name.to_s + "}", variables[name]
245
+ else
246
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
247
+ end
248
+ else
249
+ # use default value
250
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
251
+ end
252
+ end
253
+
254
+ url
255
+ end
169
256
  end
170
257
  end
@@ -0,0 +1,17 @@
1
+ module Shotstack
2
+ class Asset
3
+ # Builds the object from hash
4
+ # @param [Hash] attributes Model attributes in the form of hash
5
+ # @return [Object] Returns the model itself
6
+ def self.build_from_hash(attributes)
7
+ new.build_from_hash(attributes)
8
+ end
9
+
10
+ # Builds the object from hash
11
+ # @param [Hash] attributes Model attributes in the form of hash
12
+ # @return [Object] Returns the model itself
13
+ def build_from_hash(attributes)
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,308 @@
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
+
13
+ require 'date'
14
+
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.
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>.
19
+ attr_accessor :asset
20
+
21
+ # The start position of the Clip on the timeline, in seconds.
22
+ attr_accessor :start
23
+
24
+ # The length, in seconds, the Clip should play for.
25
+ attr_accessor :length
26
+
27
+ attr_accessor :transition
28
+
29
+ # A motion effect to apply to the Clip.
30
+ attr_accessor :effect
31
+
32
+ # A filter effect to apply to the Clip.
33
+ attr_accessor :filter
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
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'asset' => :'asset',
61
+ :'start' => :'start',
62
+ :'length' => :'length',
63
+ :'transition' => :'transition',
64
+ :'effect' => :'effect',
65
+ :'filter' => :'filter'
66
+ }
67
+ end
68
+
69
+ # Attribute type mapping.
70
+ def self.openapi_types
71
+ {
72
+ :'asset' => :'Asset',
73
+ :'start' => :'Float',
74
+ :'length' => :'Float',
75
+ :'transition' => :'Transition',
76
+ :'effect' => :'String',
77
+ :'filter' => :'String'
78
+ }
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Shotstack::Clip` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Shotstack::Clip`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'asset')
97
+ self.asset = attributes[:'asset']
98
+ end
99
+
100
+ if attributes.key?(:'start')
101
+ self.start = attributes[:'start']
102
+ end
103
+
104
+ if attributes.key?(:'length')
105
+ self.length = attributes[:'length']
106
+ end
107
+
108
+ if attributes.key?(:'transition')
109
+ self.transition = attributes[:'transition']
110
+ end
111
+
112
+ if attributes.key?(:'effect')
113
+ self.effect = attributes[:'effect']
114
+ end
115
+
116
+ if attributes.key?(:'filter')
117
+ self.filter = attributes[:'filter']
118
+ end
119
+ end
120
+
121
+ # Show invalid properties with the reasons. Usually used together with valid?
122
+ # @return Array for valid properties with the reasons
123
+ def list_invalid_properties
124
+ invalid_properties = Array.new
125
+ if @asset.nil?
126
+ invalid_properties.push('invalid value for "asset", asset cannot be nil.')
127
+ end
128
+
129
+ if @start.nil?
130
+ invalid_properties.push('invalid value for "start", start cannot be nil.')
131
+ end
132
+
133
+ if @length.nil?
134
+ invalid_properties.push('invalid value for "length", length cannot be nil.')
135
+ end
136
+
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ return false if @asset.nil?
144
+ return false if @start.nil?
145
+ return false if @length.nil?
146
+ effect_validator = EnumAttributeValidator.new('String', ["zoomIn", "zoomOut", "slideLeft", "slideRight", "slideUp", "slideDown"])
147
+ return false unless effect_validator.valid?(@effect)
148
+ filter_validator = EnumAttributeValidator.new('String', ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
149
+ return false unless filter_validator.valid?(@filter)
150
+ true
151
+ end
152
+
153
+ # Custom attribute writer method checking allowed values (enum).
154
+ # @param [Object] effect Object to be assigned
155
+ def effect=(effect)
156
+ validator = EnumAttributeValidator.new('String', ["zoomIn", "zoomOut", "slideLeft", "slideRight", "slideUp", "slideDown"])
157
+ unless validator.valid?(effect)
158
+ fail ArgumentError, "invalid value for \"effect\", must be one of #{validator.allowable_values}."
159
+ end
160
+ @effect = effect
161
+ end
162
+
163
+ # Custom attribute writer method checking allowed values (enum).
164
+ # @param [Object] filter Object to be assigned
165
+ def filter=(filter)
166
+ validator = EnumAttributeValidator.new('String', ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"])
167
+ unless validator.valid?(filter)
168
+ fail ArgumentError, "invalid value for \"filter\", must be one of #{validator.allowable_values}."
169
+ end
170
+ @filter = filter
171
+ end
172
+
173
+ # Checks equality by comparing each attribute.
174
+ # @param [Object] Object to be compared
175
+ def ==(o)
176
+ return true if self.equal?(o)
177
+ self.class == o.class &&
178
+ asset == o.asset &&
179
+ start == o.start &&
180
+ length == o.length &&
181
+ transition == o.transition &&
182
+ effect == o.effect &&
183
+ filter == o.filter
184
+ end
185
+
186
+ # @see the `==` method
187
+ # @param [Object] Object to be compared
188
+ def eql?(o)
189
+ self == o
190
+ end
191
+
192
+ # Calculates hash code according to all attributes.
193
+ # @return [Integer] Hash code
194
+ def hash
195
+ [asset, start, length, transition, effect, filter].hash
196
+ end
197
+
198
+ # Builds the object from hash
199
+ # @param [Hash] attributes Model attributes in the form of hash
200
+ # @return [Object] Returns the model itself
201
+ def self.build_from_hash(attributes)
202
+ new.build_from_hash(attributes)
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ self.class.openapi_types.each_pair do |key, type|
211
+ if type =~ /\AArray<(.*)>/i
212
+ # check to ensure the input is an array given that the attribute
213
+ # is documented as an array but the input is not
214
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
215
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
216
+ end
217
+ elsif !attributes[self.class.attribute_map[key]].nil?
218
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
219
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
220
+ end
221
+
222
+ self
223
+ end
224
+
225
+ # Deserializes the data based on type
226
+ # @param string type Data type
227
+ # @param string value Value to be deserialized
228
+ # @return [Object] Deserialized data
229
+ def _deserialize(type, value)
230
+ case type.to_sym
231
+ when :DateTime
232
+ DateTime.parse(value)
233
+ when :Date
234
+ Date.parse(value)
235
+ when :String
236
+ value.to_s
237
+ when :Integer
238
+ value.to_i
239
+ when :Float
240
+ value.to_f
241
+ when :Boolean
242
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
243
+ true
244
+ else
245
+ false
246
+ end
247
+ when :Object
248
+ # generic object (usually a Hash), return directly
249
+ value
250
+ when /\AArray<(?<inner_type>.+)>\z/
251
+ inner_type = Regexp.last_match[:inner_type]
252
+ value.map { |v| _deserialize(inner_type, v) }
253
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
254
+ k_type = Regexp.last_match[:k_type]
255
+ v_type = Regexp.last_match[:v_type]
256
+ {}.tap do |hash|
257
+ value.each do |k, v|
258
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
259
+ end
260
+ end
261
+ else # model
262
+ Shotstack.const_get(type).build_from_hash(value)
263
+ end
264
+ end
265
+
266
+ # Returns the string representation of the object
267
+ # @return [String] String presentation of the object
268
+ def to_s
269
+ to_hash.to_s
270
+ end
271
+
272
+ # to_body is an alias to to_hash (backward compatibility)
273
+ # @return [Hash] Returns the object in the form of hash
274
+ def to_body
275
+ to_hash
276
+ end
277
+
278
+ # Returns the object in the form of hash
279
+ # @return [Hash] Returns the object in the form of hash
280
+ def to_hash
281
+ hash = {}
282
+ self.class.attribute_map.each_pair do |attr, param|
283
+ value = self.send(attr)
284
+ next if value.nil?
285
+ hash[param] = _to_hash(value)
286
+ end
287
+ hash
288
+ end
289
+
290
+ # Outputs non-array value in the form of hash
291
+ # For object, use to_hash. Otherwise, just return the value
292
+ # @param [Object] value Any valid value
293
+ # @return [Hash] Returns the value in the form of hash
294
+ def _to_hash(value)
295
+ if value.is_a?(Array)
296
+ value.compact.map { |v| _to_hash(v) }
297
+ elsif value.is_a?(Hash)
298
+ {}.tap do |hash|
299
+ value.each { |k, v| hash[k] = _to_hash(v) }
300
+ end
301
+ elsif value.respond_to? :to_hash
302
+ value.to_hash
303
+ else
304
+ value
305
+ end
306
+ end
307
+ end
308
+ end