shotstack 0.0.9 → 0.1.2

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 (41) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +17 -0
  3. data/lib/shotstack.rb +31 -15
  4. data/lib/shotstack/api/endpoints_api.rb +149 -0
  5. data/lib/shotstack/api_client.rb +142 -74
  6. data/lib/shotstack/api_error.rb +38 -5
  7. data/lib/shotstack/configuration.rb +93 -5
  8. data/lib/shotstack/models/asset.rb +17 -0
  9. data/lib/shotstack/models/audio_asset.rb +251 -0
  10. data/lib/shotstack/models/clip.rb +395 -0
  11. data/lib/shotstack/models/edit.rb +121 -42
  12. data/lib/shotstack/models/font.rb +213 -0
  13. data/lib/shotstack/models/html_asset.rb +319 -0
  14. data/lib/shotstack/models/image_asset.rb +231 -0
  15. data/lib/shotstack/models/luma_asset.rb +241 -0
  16. data/lib/shotstack/models/offset.rb +266 -0
  17. data/lib/shotstack/models/output.rb +207 -46
  18. data/lib/shotstack/models/poster.rb +213 -0
  19. data/lib/shotstack/models/queued_response.rb +121 -49
  20. data/lib/shotstack/models/queued_response_data.rb +116 -46
  21. data/lib/shotstack/models/render_response.rb +121 -49
  22. data/lib/shotstack/models/render_response_data.rb +193 -69
  23. data/lib/shotstack/models/soundtrack.rb +152 -42
  24. data/lib/shotstack/models/thumbnail.rb +228 -0
  25. data/lib/shotstack/models/timeline.rb +124 -45
  26. data/lib/shotstack/models/title_asset.rb +354 -0
  27. data/lib/shotstack/models/track.rb +100 -34
  28. data/lib/shotstack/models/transition.rb +132 -43
  29. data/lib/shotstack/models/video_asset.rb +251 -0
  30. data/lib/shotstack/version.rb +13 -1
  31. data/shotstack.gemspec +23 -16
  32. metadata +37 -150
  33. data/lib/shotstack/api/render_api.rb +0 -137
  34. data/lib/shotstack/models/clips.rb +0 -147
  35. data/lib/shotstack/models/image_clip.rb +0 -216
  36. data/lib/shotstack/models/image_clip_options.rb +0 -175
  37. data/lib/shotstack/models/title_clip.rb +0 -216
  38. data/lib/shotstack/models/title_clip_options.rb +0 -194
  39. data/lib/shotstack/models/video_clip.rb +0 -216
  40. data/lib/shotstack/models/video_clip_options.rb +0 -185
  41. 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 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
+
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,4 +1,14 @@
1
- require 'uri'
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
2
12
 
3
13
  module Shotstack
4
14
  class Configuration
@@ -64,7 +74,12 @@ module Shotstack
64
74
  # Default to 0 (never times out).
65
75
  attr_accessor :timeout
66
76
 
67
- ### TLS/SSL
77
+ # Set this to false to skip client side validation in the operation.
78
+ # Default to true.
79
+ # @return [true, false]
80
+ attr_accessor :client_side_validation
81
+
82
+ ### TLS/SSL setting
68
83
  # Set this to false to skip verifying SSL certificate when calling API from https server.
69
84
  # Default to true.
70
85
  #
@@ -73,6 +88,16 @@ module Shotstack
73
88
  # @return [true, false]
74
89
  attr_accessor :verify_ssl
75
90
 
91
+ ### TLS/SSL setting
92
+ # Set this to false to skip verifying SSL host name
93
+ # Default to true.
94
+ #
95
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
96
+ #
97
+ # @return [true, false]
98
+ attr_accessor :verify_ssl_host
99
+
100
+ ### TLS/SSL setting
76
101
  # Set this to customize the certificate file to verify the peer.
77
102
  #
78
103
  # @return [String] the path to the certificate file
@@ -81,12 +106,21 @@ module Shotstack
81
106
  # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
82
107
  attr_accessor :ssl_ca_cert
83
108
 
109
+ ### TLS/SSL setting
84
110
  # Client certificate file (for client certificate)
85
111
  attr_accessor :cert_file
86
112
 
113
+ ### TLS/SSL setting
87
114
  # Client private key file (for client certificate)
88
115
  attr_accessor :key_file
89
116
 
117
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
118
+ # Default to nil.
119
+ #
120
+ # @see The params_encoding option of Ethon. Related source code:
121
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
122
+ attr_accessor :params_encoding
123
+
90
124
  attr_accessor :inject_format
91
125
 
92
126
  attr_accessor :force_ending_format
@@ -98,7 +132,10 @@ module Shotstack
98
132
  @api_key = {}
99
133
  @api_key_prefix = {}
100
134
  @timeout = 0
135
+ @client_side_validation = true
101
136
  @verify_ssl = true
137
+ @verify_ssl_host = true
138
+ @params_encoding = nil
102
139
  @cert_file = nil
103
140
  @key_file = nil
104
141
  @debugging = false
@@ -131,12 +168,11 @@ module Shotstack
131
168
  def base_path=(base_path)
132
169
  # Add leading and trailing slashes to base_path
133
170
  @base_path = "/#{base_path}".gsub(/\/+/, '/')
134
- @base_path = "" if @base_path == "/"
171
+ @base_path = '' if @base_path == '/'
135
172
  end
136
173
 
137
174
  def base_url
138
- url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
139
- URI.encode(url)
175
+ "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
140
176
  end
141
177
 
142
178
  # Gets API key (with prefix if set).
@@ -166,5 +202,57 @@ module Shotstack
166
202
  },
167
203
  }
168
204
  end
205
+
206
+ # Returns an array of Server setting
207
+ def server_settings
208
+ [
209
+ {
210
+ url: "https://api.shotstack.io/{version}",
211
+ description: "No descriptoin provided",
212
+ variables: {
213
+ version: {
214
+ description: "No descriptoin provided",
215
+ default_value: "v1",
216
+ enum_values: [
217
+ "v1",
218
+ "stage"
219
+ ]
220
+ }
221
+ }
222
+ }
223
+ ]
224
+ end
225
+
226
+ # Returns URL based on server settings
227
+ #
228
+ # @param index array index of the server settings
229
+ # @param variables hash of variable and the corresponding value
230
+ def server_url(index, variables = {})
231
+ servers = server_settings
232
+
233
+ # check array index out of bound
234
+ if (index < 0 || index >= servers.size)
235
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
236
+ end
237
+
238
+ server = servers[index]
239
+ url = server[:url]
240
+
241
+ # go through variable and assign a value
242
+ server[:variables].each do |name, variable|
243
+ if variables.key?(name)
244
+ if (server[:variables][name][:enum_values].include? variables[name])
245
+ url.gsub! "{" + name.to_s + "}", variables[name]
246
+ else
247
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
248
+ end
249
+ else
250
+ # use default value
251
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
252
+ end
253
+ end
254
+
255
+ url
256
+ end
169
257
  end
170
258
  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,251 @@
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 <b>audio</b> 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
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ invalid_properties = Array.new
95
+ if @type.nil?
96
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
97
+ end
98
+
99
+ if @src.nil?
100
+ invalid_properties.push('invalid value for "src", src cannot be nil.')
101
+ end
102
+
103
+ invalid_properties
104
+ end
105
+
106
+ # Check to see if the all the properties in the model are valid
107
+ # @return true if the model is valid
108
+ def valid?
109
+ return false if @type.nil?
110
+ return false if @src.nil?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ type == o.type &&
120
+ src == o.src &&
121
+ trim == o.trim &&
122
+ volume == o.volume
123
+ end
124
+
125
+ # @see the `==` method
126
+ # @param [Object] Object to be compared
127
+ def eql?(o)
128
+ self == o
129
+ end
130
+
131
+ # Calculates hash code according to all attributes.
132
+ # @return [Integer] Hash code
133
+ def hash
134
+ [type, src, trim, volume].hash
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def self.build_from_hash(attributes)
141
+ new.build_from_hash(attributes)
142
+ end
143
+
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 build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ self.class.openapi_types.each_pair do |key, type|
150
+ if type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :DateTime
171
+ DateTime.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ Shotstack.const_get(type).build_from_hash(value)
202
+ end
203
+ end
204
+
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
207
+ def to_s
208
+ to_hash.to_s
209
+ end
210
+
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_body
214
+ to_hash
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = self.send(attr)
223
+ if value.nil?
224
+ is_nullable = self.class.openapi_nullable.include?(attr)
225
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
226
+ end
227
+
228
+ hash[param] = _to_hash(value)
229
+ end
230
+ hash
231
+ end
232
+
233
+ # Outputs non-array value in the form of hash
234
+ # For object, use to_hash. Otherwise, just return the value
235
+ # @param [Object] value Any valid value
236
+ # @return [Hash] Returns the value in the form of hash
237
+ def _to_hash(value)
238
+ if value.is_a?(Array)
239
+ value.compact.map { |v| _to_hash(v) }
240
+ elsif value.is_a?(Hash)
241
+ {}.tap do |hash|
242
+ value.each { |k, v| hash[k] = _to_hash(v) }
243
+ end
244
+ elsif value.respond_to? :to_hash
245
+ value.to_hash
246
+ else
247
+ value
248
+ end
249
+ end
250
+ end
251
+ end