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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 31d87d73c44a309627e675a50328dd0595745f55
4
- data.tar.gz: 43089c6e46758d056c8c7926f160a6b9437890ed
2
+ SHA256:
3
+ metadata.gz: c25bb8f71fb1b0d993a60aa4028546375451f0978461b1c91ac0caf9b651df55
4
+ data.tar.gz: cdeea3fed0658a006339aef975b40b94067d2e0d80c611cea9319fd304f5f1b8
5
5
  SHA512:
6
- metadata.gz: 734bb28a5608c27273234cae6e3cfcfcf7f95ad89fb04c7399adac6e3e2f54da3733da9785866211ebf5717a4ac49ef097a78a5b35f58a9e02759dd375784864
7
- data.tar.gz: c13acb5444f705bbdef61583edb555d0ab0a3809f9378e89604c592f302d645c8860207708ad9badccacad21fd9c2ffd25e7c00a8175ec7b0eccbea2ea0af54c
6
+ metadata.gz: 33c957198774b015ddcf9364efa98f1f104b883c02561f65acb946b790266943cac49f98178f5dbb774821c08f735c9be1f8918df30e9ff23f82f7a880ef3183
7
+ data.tar.gz: c7edb8be614276130289c71bf100892ef32d124b8cd480704b83f5dd26fb5bbe1c3302af6ca50a514aaac8075ab57894f390d133d96703aed7610186832f3099
data/README.md CHANGED
@@ -2,3 +2,20 @@
2
2
 
3
3
  Ruby SDK for Shotstack, the cloud video editing API.
4
4
 
5
+ ## Build Instructions
6
+
7
+ First make sure the version in `shotstack/version.rb` is correct.
8
+
9
+ Then, to build as a gem:
10
+
11
+ ```bash
12
+ rm shotstack-*.gem
13
+ gem build shotstack
14
+ gem push shotstack-*.*.*.gem # use the correct version number
15
+ ```
16
+
17
+ For local development install the gem:
18
+
19
+ ```bash
20
+ sudo gem install shotstack
21
+ ```
data/lib/shotstack.rb CHANGED
@@ -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
  # Common files
2
14
  require 'shotstack/api_client'
3
15
  require 'shotstack/api_error'
@@ -5,26 +17,23 @@ require 'shotstack/version'
5
17
  require 'shotstack/configuration'
6
18
 
7
19
  # Models
8
- require 'shotstack/models/render_response_data'
9
- require 'shotstack/models/render_response'
10
- require 'shotstack/models/queued_response_data'
11
- require 'shotstack/models/queued_response'
20
+ require 'shotstack/models/clip'
21
+ require 'shotstack/models/edit'
22
+ require 'shotstack/models/image_asset'
12
23
  require 'shotstack/models/output'
13
- require 'shotstack/models/transition'
14
- require 'shotstack/models/video_clip_options'
15
- require 'shotstack/models/video_clip'
16
- require 'shotstack/models/image_clip_options'
17
- require 'shotstack/models/image_clip'
18
- require 'shotstack/models/title_clip_options'
19
- require 'shotstack/models/title_clip'
20
- require 'shotstack/models/track'
21
- require 'shotstack/models/clips'
24
+ require 'shotstack/models/queued_response'
25
+ require 'shotstack/models/queued_response_data'
26
+ require 'shotstack/models/render_response'
27
+ require 'shotstack/models/render_response_data'
22
28
  require 'shotstack/models/soundtrack'
23
29
  require 'shotstack/models/timeline'
24
- require 'shotstack/models/edit'
30
+ require 'shotstack/models/title_asset'
31
+ require 'shotstack/models/track'
32
+ require 'shotstack/models/transition'
33
+ require 'shotstack/models/video_asset'
25
34
 
26
35
  # APIs
27
- require 'shotstack/api/render_api'
36
+ require 'shotstack/api/default_api'
28
37
 
29
38
  module Shotstack
30
39
  class << self
@@ -0,0 +1,131 @@
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 'uri'
14
+
15
+ module Shotstack
16
+ class DefaultApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get the rendering status and details of a timeline by ID.
23
+ # @param id [String] The id of the timeline render task in UUID format
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [RenderResponse]
26
+ def get_render(id, opts = {})
27
+ data, _status_code, _headers = g_et_render_id_with_http_info(id, opts)
28
+ data
29
+ end
30
+
31
+ # Get the rendering status and details of a timeline by ID.
32
+ # @param id [String] The id of the timeline render task in UUID format
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(RenderResponse, Integer, Hash)>] RenderResponse data, response status code and response headers
35
+ def g_et_render_id_with_http_info(id, opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: DefaultApi.g_et_render_id ...'
38
+ end
39
+ # verify the required parameter 'id' is set
40
+ if @api_client.config.client_side_validation && id.nil?
41
+ fail ArgumentError, "Missing the required parameter 'id' when calling DefaultApi.g_et_render_id"
42
+ end
43
+ pattern = Regexp.new(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
44
+ if @api_client.config.client_side_validation && id !~ pattern
45
+ fail ArgumentError, "invalid value for 'id' when calling DefaultApi.get_render, must conform to the pattern #{pattern}."
46
+ end
47
+
48
+ # resource path
49
+ local_var_path = '/render/{id}'.sub('{' + 'id' + '}', id.to_s)
50
+
51
+ # query parameters
52
+ query_params = {}
53
+
54
+ # header parameters
55
+ header_params = {}
56
+ # HTTP header 'Accept' (if needed)
57
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
58
+
59
+ # form parameters
60
+ form_params = {}
61
+
62
+ # http body (model)
63
+ post_body = nil
64
+ auth_names = ['DeveloperKey']
65
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
66
+ :header_params => header_params,
67
+ :query_params => query_params,
68
+ :form_params => form_params,
69
+ :body => post_body,
70
+ :auth_names => auth_names,
71
+ :return_type => 'RenderResponse')
72
+ if @api_client.config.debugging
73
+ @api_client.config.logger.debug "API called: DefaultApi#get_render\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
74
+ end
75
+ return data, status_code, headers
76
+ end
77
+
78
+ # Render the contents of a timeline as a video file.
79
+ # @param edit [Edit]
80
+ # @param [Hash] opts the optional parameters
81
+ # @return [QueuedResponse]
82
+ def post_render(edit, opts = {})
83
+ data, _status_code, _headers = p_ost_render_with_http_info(edit, opts)
84
+ data
85
+ end
86
+
87
+ # Render the contents of a timeline as a video file.
88
+ # @param edit [Edit]
89
+ # @param [Hash] opts the optional parameters
90
+ # @return [Array<(QueuedResponse, Integer, Hash)>] QueuedResponse data, response status code and response headers
91
+ def p_ost_render_with_http_info(edit, opts = {})
92
+ if @api_client.config.debugging
93
+ @api_client.config.logger.debug 'Calling API: DefaultApi.post_render ...'
94
+ end
95
+ # verify the required parameter 'edit' is set
96
+ if @api_client.config.client_side_validation && edit.nil?
97
+ fail ArgumentError, "Missing the required parameter 'edit' when calling DefaultApi.post_render"
98
+ end
99
+ # resource path
100
+ local_var_path = '/render'
101
+
102
+ # query parameters
103
+ query_params = {}
104
+
105
+ # header parameters
106
+ header_params = {}
107
+ # HTTP header 'Accept' (if needed)
108
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
109
+ # HTTP header 'Content-Type'
110
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
111
+
112
+ # form parameters
113
+ form_params = {}
114
+
115
+ # http body (model)
116
+ post_body = @api_client.object_to_http_body(edit)
117
+ auth_names = ['DeveloperKey']
118
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
119
+ :header_params => header_params,
120
+ :query_params => query_params,
121
+ :form_params => form_params,
122
+ :body => post_body,
123
+ :auth_names => auth_names,
124
+ :return_type => 'QueuedResponse')
125
+ if @api_client.config.debugging
126
+ @api_client.config.logger.debug "API called: DefaultApi#post_render\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
127
+ end
128
+ return data, status_code, headers
129
+ end
130
+ end
131
+ 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 'date'
2
14
  require 'json'
3
15
  require 'logger'
@@ -15,11 +27,13 @@ module Shotstack
15
27
  # @return [Hash]
16
28
  attr_accessor :default_headers
17
29
 
30
+ # Initializes the ApiClient
31
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
18
32
  def initialize(config = Configuration.default)
19
33
  @config = config
20
- @user_agent = "ruby-swagger-#{VERSION}"
34
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
21
35
  @default_headers = {
22
- 'Content-Type' => "application/json",
36
+ 'Content-Type' => 'application/json',
23
37
  'User-Agent' => @user_agent
24
38
  }
25
39
  end
@@ -30,7 +44,7 @@ module Shotstack
30
44
 
31
45
  # Call an API with given options.
32
46
  #
33
- # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
47
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
34
48
  # the data deserialized from response body (could be nil), response status code and response headers.
35
49
  def call_api(http_method, path, opts = {})
36
50
  request = build_request(http_method, path, opts)
@@ -41,10 +55,18 @@ module Shotstack
41
55
  end
42
56
 
43
57
  unless response.success?
44
- fail ApiError.new(:code => response.code,
45
- :response_headers => response.headers,
46
- :response_body => response.body),
47
- response.status_message
58
+ if response.timed_out?
59
+ fail ApiError.new('Connection timed out')
60
+ elsif response.code == 0
61
+ # Errors from libcurl will be made visible here
62
+ fail ApiError.new(:code => 0,
63
+ :message => response.return_message)
64
+ else
65
+ fail ApiError.new(:code => response.code,
66
+ :response_headers => response.headers,
67
+ :response_body => response.body),
68
+ response.status_message
69
+ end
48
70
  end
49
71
 
50
72
  if opts[:return_type]
@@ -55,6 +77,15 @@ module Shotstack
55
77
  return data, response.code, response.headers
56
78
  end
57
79
 
80
+ # Builds the HTTP request
81
+ #
82
+ # @param [String] http_method HTTP method/verb (e.g. POST)
83
+ # @param [String] path URL path (e.g. /account/new)
84
+ # @option opts [Hash] :header_params Header parameters
85
+ # @option opts [Hash] :query_params Query parameters
86
+ # @option opts [Hash] :form_params Query parameters
87
+ # @option opts [Object] :body HTTP body (JSON/XML)
88
+ # @return [Typhoeus::Request] A Typhoeus Request
58
89
  def build_request(http_method, path, opts = {})
59
90
  url = build_request_url(path)
60
91
  http_method = http_method.to_sym.downcase
@@ -63,22 +94,27 @@ module Shotstack
63
94
  query_params = opts[:query_params] || {}
64
95
  form_params = opts[:form_params] || {}
65
96
 
66
-
67
97
  update_params_for_auth! header_params, query_params, opts[:auth_names]
68
-
98
+
99
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
100
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
69
101
 
70
102
  req_opts = {
71
103
  :method => http_method,
72
104
  :headers => header_params,
73
105
  :params => query_params,
106
+ :params_encoding => @config.params_encoding,
74
107
  :timeout => @config.timeout,
75
108
  :ssl_verifypeer => @config.verify_ssl,
109
+ :ssl_verifyhost => _verify_ssl_host,
76
110
  :sslcert => @config.cert_file,
77
111
  :sslkey => @config.key_file,
78
- :cainfo => @config.ssl_ca_cert,
79
112
  :verbose => @config.debugging
80
113
  }
81
114
 
115
+ # set custom cert, if provided
116
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
117
+
82
118
  if [:post, :patch, :put, :delete].include?(http_method)
83
119
  req_body = build_request_body(header_params, form_params, opts[:body])
84
120
  req_opts.update :body => req_body
@@ -87,7 +123,9 @@ module Shotstack
87
123
  end
88
124
  end
89
125
 
90
- Typhoeus::Request.new(url, req_opts)
126
+ request = Typhoeus::Request.new(url, req_opts)
127
+ download_file(request) if opts[:return_type] == 'File'
128
+ request
91
129
  end
92
130
 
93
131
  # Check if the given MIME is a JSON MIME.
@@ -95,19 +133,28 @@ module Shotstack
95
133
  # application/json
96
134
  # application/json; charset=UTF8
97
135
  # APPLICATION/JSON
136
+ # */*
137
+ # @param [String] mime MIME
138
+ # @return [Boolean] True if the MIME is application/json
98
139
  def json_mime?(mime)
99
- !!(mime =~ /\Aapplication\/json(;.*)?\z/i)
140
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
100
141
  end
101
142
 
102
143
  # Deserialize the response to the given return type.
103
144
  #
104
- # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
145
+ # @param [Response] response HTTP response
146
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
105
147
  def deserialize(response, return_type)
106
148
  body = response.body
149
+
150
+ # handle file downloading - return the File instance processed in request callbacks
151
+ # note that response body is empty when the file is written in chunks in request on_body callback
152
+ return @tempfile if return_type == 'File'
153
+
107
154
  return nil if body.nil? || body.empty?
108
155
 
109
- # handle file downloading - save response body into a tmp file and return the File instance
110
- return download_file(response) if return_type == 'File'
156
+ # return response body directly for String return type
157
+ return body if return_type == 'String'
111
158
 
112
159
  # ensuring a default content type
113
160
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -128,6 +175,9 @@ module Shotstack
128
175
  end
129
176
 
130
177
  # Convert data to the given return type.
178
+ # @param [Object] data Data to be converted
179
+ # @param [String] return_type Return type
180
+ # @return [Mixed] Data in a particular type
131
181
  def convert_to_type(data, return_type)
132
182
  return nil if data.nil?
133
183
  case return_type
@@ -137,7 +187,7 @@ module Shotstack
137
187
  data.to_i
138
188
  when 'Float'
139
189
  data.to_f
140
- when 'BOOLEAN'
190
+ when 'Boolean'
141
191
  data == true
142
192
  when 'DateTime'
143
193
  # parse date time (expecting ISO 8601 format)
@@ -146,52 +196,58 @@ module Shotstack
146
196
  # parse date time (expecting ISO 8601 format)
147
197
  Date.parse data
148
198
  when 'Object'
149
- # generic object, return directly
199
+ # generic object (usually a Hash), return directly
150
200
  data
151
201
  when /\AArray<(.+)>\z/
152
202
  # e.g. Array<Pet>
153
203
  sub_type = $1
154
- data.map {|item| convert_to_type(item, sub_type) }
204
+ data.map { |item| convert_to_type(item, sub_type) }
155
205
  when /\AHash\<String, (.+)\>\z/
156
206
  # e.g. Hash<String, Integer>
157
207
  sub_type = $1
158
208
  {}.tap do |hash|
159
- data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
209
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
160
210
  end
161
211
  else
162
212
  # models, e.g. Pet
163
- Shotstack.const_get(return_type).new.tap do |model|
164
- model.build_from_hash data
165
- end
213
+ Shotstack.const_get(return_type).build_from_hash(data)
166
214
  end
167
215
  end
168
216
 
169
217
  # Save response body into a file in (the defined) temporary folder, using the filename
170
218
  # from the "Content-Disposition" header if provided, otherwise a random filename.
219
+ # The response body is written to the file in chunks in order to handle files which
220
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
221
+ # process can use.
171
222
  #
172
223
  # @see Configuration#temp_folder_path
173
- # @return [Tempfile] the file downloaded
174
- def download_file(response)
175
- content_disposition = response.headers['Content-Disposition']
176
- if content_disposition
177
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
178
- prefix = sanitize_filename(filename)
179
- else
180
- prefix = 'download-'
181
- end
182
- prefix = prefix + '-' unless prefix.end_with?('-')
183
-
224
+ def download_file(request)
184
225
  tempfile = nil
185
- encoding = response.body.encoding
186
- Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
187
- file.write(response.body)
188
- tempfile = file
226
+ encoding = nil
227
+ request.on_headers do |response|
228
+ content_disposition = response.headers['Content-Disposition']
229
+ if content_disposition && content_disposition =~ /filename=/i
230
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
231
+ prefix = sanitize_filename(filename)
232
+ else
233
+ prefix = 'download-'
234
+ end
235
+ prefix = prefix + '-' unless prefix.end_with?('-')
236
+ encoding = response.body.encoding
237
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
238
+ @tempfile = tempfile
239
+ end
240
+ request.on_body do |chunk|
241
+ chunk.force_encoding(encoding)
242
+ tempfile.write(chunk)
243
+ end
244
+ request.on_complete do |response|
245
+ tempfile.close if tempfile
246
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
247
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
248
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
249
+ "explicitly with `tempfile.delete`"
189
250
  end
190
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
191
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
192
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
193
- "explicitly with `tempfile.delete`"
194
- tempfile
195
251
  end
196
252
 
197
253
  # Sanitize filename by removing path.
@@ -200,7 +256,7 @@ module Shotstack
200
256
  # @param [String] filename the filename to be sanitized
201
257
  # @return [String] the sanitized filename
202
258
  def sanitize_filename(filename)
203
- filename.gsub /.*[\/\\]/, ''
259
+ filename.gsub(/.*[\/\\]/, '')
204
260
  end
205
261
 
206
262
  def build_request_url(path)
@@ -209,6 +265,12 @@ module Shotstack
209
265
  URI.encode(@config.base_url + path)
210
266
  end
211
267
 
268
+ # Builds the HTTP request body
269
+ #
270
+ # @param [Hash] header_params Header parameters
271
+ # @param [Hash] form_params Query parameters
272
+ # @param [Object] body HTTP body (JSON/XML)
273
+ # @return [String] HTTP body data in the form of string
212
274
  def build_request_body(header_params, form_params, body)
213
275
  # http form
214
276
  if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
@@ -216,7 +278,7 @@ module Shotstack
216
278
  data = {}
217
279
  form_params.each do |key, value|
218
280
  case value
219
- when File, Array, nil
281
+ when ::File, ::Array, nil
220
282
  # let typhoeus handle File, Array and nil parameters
221
283
  data[key] = value
222
284
  else
@@ -232,6 +294,10 @@ module Shotstack
232
294
  end
233
295
 
234
296
  # Update hearder and query params based on authentication settings.
297
+ #
298
+ # @param [Hash] header_params Header parameters
299
+ # @param [Hash] query_params Query parameters
300
+ # @param [String] auth_names Authentication scheme name
235
301
  def update_params_for_auth!(header_params, query_params, auth_names)
236
302
  Array(auth_names).each do |auth_name|
237
303
  auth_setting = @config.auth_settings[auth_name]
@@ -244,6 +310,9 @@ module Shotstack
244
310
  end
245
311
  end
246
312
 
313
+ # Sets user agent in HTTP header
314
+ #
315
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
247
316
  def user_agent=(user_agent)
248
317
  @user_agent = user_agent
249
318
  @default_headers['User-Agent'] = @user_agent
@@ -256,7 +325,7 @@ module Shotstack
256
325
  return nil if accepts.nil? || accepts.empty?
257
326
  # use JSON when present, otherwise use all of the provided
258
327
  json_accept = accepts.find { |s| json_mime?(s) }
259
- return json_accept || accepts.join(',')
328
+ json_accept || accepts.join(',')
260
329
  end
261
330
 
262
331
  # Return Content-Type header based on an array of content types provided.
@@ -267,21 +336,21 @@ module Shotstack
267
336
  return 'application/json' if content_types.nil? || content_types.empty?
268
337
  # use JSON when present, otherwise use the first one
269
338
  json_content_type = content_types.find { |s| json_mime?(s) }
270
- return json_content_type || content_types.first
339
+ json_content_type || content_types.first
271
340
  end
272
341
 
273
342
  # Convert object (array, hash, object, etc) to JSON string.
274
343
  # @param [Object] model object to be converted into JSON string
275
344
  # @return [String] JSON string representation of the object
276
345
  def object_to_http_body(model)
277
- return if model.nil?
278
- _body = nil
346
+ return model if model.nil? || model.is_a?(String)
347
+ local_body = nil
279
348
  if model.is_a?(Array)
280
- _body = model.map{|m| object_to_hash(m) }
349
+ local_body = model.map { |m| object_to_hash(m) }
281
350
  else
282
- _body = object_to_hash(model)
351
+ local_body = object_to_hash(model)
283
352
  end
284
- _body.to_json
353
+ local_body.to_json
285
354
  end
286
355
 
287
356
  # Convert object(non-array) to hash.