fastpixapi 1.1.2 → 1.1.3
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.
- checksums.yaml +4 -4
- data/lib/crystalline/metadata_fields.rb +56 -48
- data/lib/crystalline/types.rb +3 -3
- data/lib/crystalline.rb +4 -5
- data/lib/fastpix_client/dimensions.rb +51 -58
- data/lib/fastpix_client/drm_configurations.rb +49 -56
- data/lib/fastpix_client/errors.rb +35 -24
- data/lib/fastpix_client/fastpixapi.rb +2 -4
- data/lib/fastpix_client/in_video_ai_features.rb +100 -160
- data/lib/fastpix_client/input_video.rb +66 -74
- data/lib/fastpix_client/live_playback.rb +82 -99
- data/lib/fastpix_client/manage_live_stream.rb +136 -252
- data/lib/fastpix_client/manage_videos.rb +228 -543
- data/lib/fastpix_client/metrics.rb +76 -120
- data/lib/fastpix_client/models/components/createlivestreamresponsedto.rb +10 -18
- data/lib/fastpix_client/models/components/createmediarequest.rb +9 -18
- data/lib/fastpix_client/models/components/getallmediaresponse.rb +13 -29
- data/lib/fastpix_client/models/components/getcreatelivestreamresponsedto.rb +9 -20
- data/lib/fastpix_client/models/components/getmediaresponse.rb +13 -29
- data/lib/fastpix_client/models/components/live_media_clips.rb +9 -21
- data/lib/fastpix_client/models/components/media.rb +11 -26
- data/lib/fastpix_client/models/components/patchresponsedata.rb +9 -18
- data/lib/fastpix_client/models/components/sourceaccessmedia.rb +11 -26
- data/lib/fastpix_client/models/components/update_media.rb +11 -26
- data/lib/fastpix_client/models/components/views.rb +51 -124
- data/lib/fastpix_client/models/errors/empty_response_error.rb +15 -0
- data/lib/fastpix_client/models/errors.rb +1 -0
- data/lib/fastpix_client/models/operations/push_media_settings.rb +9 -20
- data/lib/fastpix_client/playback.rb +122 -213
- data/lib/fastpix_client/playlist.rb +150 -296
- data/lib/fastpix_client/sdk_hooks/registration.rb +2 -2
- data/lib/fastpix_client/sdk_hooks/types.rb +4 -0
- data/lib/fastpix_client/sdkconfiguration.rb +3 -3
- data/lib/fastpix_client/signing_keys.rb +76 -120
- data/lib/fastpix_client/simulcast_stream.rb +97 -141
- data/lib/fastpix_client/start_live_stream.rb +51 -33
- data/lib/fastpix_client/utils/forms.rb +97 -101
- data/lib/fastpix_client/utils/headers.rb +44 -34
- data/lib/fastpix_client/utils/query_params.rb +39 -29
- data/lib/fastpix_client/utils/request_bodies.rb +4 -8
- data/lib/fastpix_client/utils/security.rb +30 -18
- data/lib/fastpix_client/utils/url.rb +83 -60
- data/lib/fastpix_client/utils/utils.rb +19 -37
- data/lib/fastpix_client/views.rb +66 -90
- data/lib/fastpixapi.rb +10 -10
- data/lib/openssl_patch.rb +24 -24
- metadata +3 -2
|
@@ -14,6 +14,58 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class InVideoAIFeatures
|
|
16
16
|
extend T::Sig
|
|
17
|
+
|
|
18
|
+
API_ERROR_OCCURRED = 'API error occurred'
|
|
19
|
+
CONTENT_TYPE_HEADER = 'Content-Type'
|
|
20
|
+
CONTENT_TYPE_JSON = 'application/json'
|
|
21
|
+
DEFAULT_CONTENT_TYPE = 'application/octet-stream'
|
|
22
|
+
REQUEST_CONTENT_TYPE_HEADER = 'content-type'
|
|
23
|
+
UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
|
|
24
|
+
USER_AGENT_HEADER = 'user-agent'
|
|
25
|
+
|
|
26
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
27
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
28
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
29
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
30
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
31
|
+
error: error,
|
|
32
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
33
|
+
hook_ctx: hook_ctx
|
|
34
|
+
),
|
|
35
|
+
response: http_response
|
|
36
|
+
)
|
|
37
|
+
else
|
|
38
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
39
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
40
|
+
hook_ctx: hook_ctx
|
|
41
|
+
),
|
|
42
|
+
response: http_response
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if http_response.nil?
|
|
47
|
+
raise error unless error.nil?
|
|
48
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
http_response
|
|
52
|
+
end
|
|
53
|
+
private :apply_after_request_hooks
|
|
54
|
+
|
|
55
|
+
# Encodes the request body based on its serialized content type.
|
|
56
|
+
sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
|
|
57
|
+
def encode_request_body(req_content_type, data, form)
|
|
58
|
+
raise ArgumentError, 'request body is required' if data.nil? && form.nil?
|
|
59
|
+
|
|
60
|
+
if form
|
|
61
|
+
Utils.encode_form(form)
|
|
62
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
63
|
+
URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
64
|
+
else
|
|
65
|
+
data
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
private :encode_request_body
|
|
17
69
|
|
|
18
70
|
# Operations for AI-powered video features
|
|
19
71
|
|
|
@@ -75,18 +127,10 @@ module FastpixClient
|
|
|
75
127
|
headers = {}
|
|
76
128
|
headers = T.cast(headers, T::Hash[String, String])
|
|
77
129
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
78
|
-
headers[
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
body = Utils.encode_form(form)
|
|
83
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
84
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
85
|
-
else
|
|
86
|
-
body = data
|
|
87
|
-
end
|
|
88
|
-
headers['Accept'] = 'application/json'
|
|
89
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
130
|
+
headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
|
|
131
|
+
body = encode_request_body(req_content_type, data, form)
|
|
132
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
133
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
90
134
|
|
|
91
135
|
security = @sdk_configuration.security_source&.call
|
|
92
136
|
|
|
@@ -125,32 +169,12 @@ module FastpixClient
|
|
|
125
169
|
rescue StandardError => e
|
|
126
170
|
error = e
|
|
127
171
|
ensure
|
|
128
|
-
|
|
129
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
130
|
-
error: error,
|
|
131
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
132
|
-
hook_ctx: hook_ctx
|
|
133
|
-
),
|
|
134
|
-
response: http_response
|
|
135
|
-
)
|
|
136
|
-
else
|
|
137
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
138
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
139
|
-
hook_ctx: hook_ctx
|
|
140
|
-
),
|
|
141
|
-
response: http_response
|
|
142
|
-
)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
if http_response.nil?
|
|
146
|
-
raise error if !error.nil?
|
|
147
|
-
raise 'no response'
|
|
148
|
-
end
|
|
172
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
149
173
|
end
|
|
150
174
|
|
|
151
|
-
content_type = http_response.headers.fetch(
|
|
175
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
152
176
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
153
|
-
if Utils.match_content_type(content_type,
|
|
177
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
154
178
|
http_response = @sdk_configuration.hooks.after_success(
|
|
155
179
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
156
180
|
hook_ctx: hook_ctx
|
|
@@ -168,14 +192,14 @@ module FastpixClient
|
|
|
168
192
|
|
|
169
193
|
return response
|
|
170
194
|
else
|
|
171
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
195
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
172
196
|
end
|
|
173
197
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
174
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
198
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
175
199
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
176
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
200
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
177
201
|
else
|
|
178
|
-
if Utils.match_content_type(content_type,
|
|
202
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
179
203
|
http_response = @sdk_configuration.hooks.after_success(
|
|
180
204
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
181
205
|
hook_ctx: hook_ctx
|
|
@@ -193,7 +217,7 @@ module FastpixClient
|
|
|
193
217
|
|
|
194
218
|
return response
|
|
195
219
|
else
|
|
196
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
220
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
197
221
|
end
|
|
198
222
|
end
|
|
199
223
|
end
|
|
@@ -230,18 +254,10 @@ module FastpixClient
|
|
|
230
254
|
headers = {}
|
|
231
255
|
headers = T.cast(headers, T::Hash[String, String])
|
|
232
256
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
233
|
-
headers[
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
body = Utils.encode_form(form)
|
|
238
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
239
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
240
|
-
else
|
|
241
|
-
body = data
|
|
242
|
-
end
|
|
243
|
-
headers['Accept'] = 'application/json'
|
|
244
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
257
|
+
headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
|
|
258
|
+
body = encode_request_body(req_content_type, data, form)
|
|
259
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
260
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
245
261
|
|
|
246
262
|
security = @sdk_configuration.security_source&.call
|
|
247
263
|
|
|
@@ -280,32 +296,12 @@ module FastpixClient
|
|
|
280
296
|
rescue StandardError => e
|
|
281
297
|
error = e
|
|
282
298
|
ensure
|
|
283
|
-
|
|
284
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
285
|
-
error: error,
|
|
286
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
287
|
-
hook_ctx: hook_ctx
|
|
288
|
-
),
|
|
289
|
-
response: http_response
|
|
290
|
-
)
|
|
291
|
-
else
|
|
292
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
293
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
294
|
-
hook_ctx: hook_ctx
|
|
295
|
-
),
|
|
296
|
-
response: http_response
|
|
297
|
-
)
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
if http_response.nil?
|
|
301
|
-
raise error if !error.nil?
|
|
302
|
-
raise 'no response'
|
|
303
|
-
end
|
|
299
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
304
300
|
end
|
|
305
301
|
|
|
306
|
-
content_type = http_response.headers.fetch(
|
|
302
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
307
303
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
308
|
-
if Utils.match_content_type(content_type,
|
|
304
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
309
305
|
http_response = @sdk_configuration.hooks.after_success(
|
|
310
306
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
311
307
|
hook_ctx: hook_ctx
|
|
@@ -323,14 +319,14 @@ module FastpixClient
|
|
|
323
319
|
|
|
324
320
|
return response
|
|
325
321
|
else
|
|
326
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
322
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
327
323
|
end
|
|
328
324
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
329
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
325
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
330
326
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
331
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
327
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
332
328
|
else
|
|
333
|
-
if Utils.match_content_type(content_type,
|
|
329
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
334
330
|
http_response = @sdk_configuration.hooks.after_success(
|
|
335
331
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
336
332
|
hook_ctx: hook_ctx
|
|
@@ -348,7 +344,7 @@ module FastpixClient
|
|
|
348
344
|
|
|
349
345
|
return response
|
|
350
346
|
else
|
|
351
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
347
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
352
348
|
end
|
|
353
349
|
end
|
|
354
350
|
end
|
|
@@ -390,18 +386,10 @@ module FastpixClient
|
|
|
390
386
|
headers = {}
|
|
391
387
|
headers = T.cast(headers, T::Hash[String, String])
|
|
392
388
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
393
|
-
headers[
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
body = Utils.encode_form(form)
|
|
398
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
399
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
400
|
-
else
|
|
401
|
-
body = data
|
|
402
|
-
end
|
|
403
|
-
headers['Accept'] = 'application/json'
|
|
404
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
389
|
+
headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
|
|
390
|
+
body = encode_request_body(req_content_type, data, form)
|
|
391
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
392
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
405
393
|
|
|
406
394
|
security = @sdk_configuration.security_source&.call
|
|
407
395
|
|
|
@@ -440,32 +428,12 @@ module FastpixClient
|
|
|
440
428
|
rescue StandardError => e
|
|
441
429
|
error = e
|
|
442
430
|
ensure
|
|
443
|
-
|
|
444
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
445
|
-
error: error,
|
|
446
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
447
|
-
hook_ctx: hook_ctx
|
|
448
|
-
),
|
|
449
|
-
response: http_response
|
|
450
|
-
)
|
|
451
|
-
else
|
|
452
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
453
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
454
|
-
hook_ctx: hook_ctx
|
|
455
|
-
),
|
|
456
|
-
response: http_response
|
|
457
|
-
)
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
if http_response.nil?
|
|
461
|
-
raise error if !error.nil?
|
|
462
|
-
raise 'no response'
|
|
463
|
-
end
|
|
431
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
464
432
|
end
|
|
465
433
|
|
|
466
|
-
content_type = http_response.headers.fetch(
|
|
434
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
467
435
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
468
|
-
if Utils.match_content_type(content_type,
|
|
436
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
469
437
|
http_response = @sdk_configuration.hooks.after_success(
|
|
470
438
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
471
439
|
hook_ctx: hook_ctx
|
|
@@ -483,14 +451,14 @@ module FastpixClient
|
|
|
483
451
|
|
|
484
452
|
return response
|
|
485
453
|
else
|
|
486
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
454
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
487
455
|
end
|
|
488
456
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
489
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
457
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
490
458
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
491
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
459
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
492
460
|
else
|
|
493
|
-
if Utils.match_content_type(content_type,
|
|
461
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
494
462
|
http_response = @sdk_configuration.hooks.after_success(
|
|
495
463
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
496
464
|
hook_ctx: hook_ctx
|
|
@@ -508,7 +476,7 @@ module FastpixClient
|
|
|
508
476
|
|
|
509
477
|
return response
|
|
510
478
|
else
|
|
511
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
479
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
512
480
|
end
|
|
513
481
|
end
|
|
514
482
|
end
|
|
@@ -545,18 +513,10 @@ module FastpixClient
|
|
|
545
513
|
headers = {}
|
|
546
514
|
headers = T.cast(headers, T::Hash[String, String])
|
|
547
515
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
548
|
-
headers[
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
body = Utils.encode_form(form)
|
|
553
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
554
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
555
|
-
else
|
|
556
|
-
body = data
|
|
557
|
-
end
|
|
558
|
-
headers['Accept'] = 'application/json'
|
|
559
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
516
|
+
headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
|
|
517
|
+
body = encode_request_body(req_content_type, data, form)
|
|
518
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
519
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
560
520
|
|
|
561
521
|
security = @sdk_configuration.security_source&.call
|
|
562
522
|
|
|
@@ -595,32 +555,12 @@ module FastpixClient
|
|
|
595
555
|
rescue StandardError => e
|
|
596
556
|
error = e
|
|
597
557
|
ensure
|
|
598
|
-
|
|
599
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
600
|
-
error: error,
|
|
601
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
602
|
-
hook_ctx: hook_ctx
|
|
603
|
-
),
|
|
604
|
-
response: http_response
|
|
605
|
-
)
|
|
606
|
-
else
|
|
607
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
608
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
609
|
-
hook_ctx: hook_ctx
|
|
610
|
-
),
|
|
611
|
-
response: http_response
|
|
612
|
-
)
|
|
613
|
-
end
|
|
614
|
-
|
|
615
|
-
if http_response.nil?
|
|
616
|
-
raise error if !error.nil?
|
|
617
|
-
raise 'no response'
|
|
618
|
-
end
|
|
558
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
619
559
|
end
|
|
620
560
|
|
|
621
|
-
content_type = http_response.headers.fetch(
|
|
561
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
622
562
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
623
|
-
if Utils.match_content_type(content_type,
|
|
563
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
624
564
|
http_response = @sdk_configuration.hooks.after_success(
|
|
625
565
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
626
566
|
hook_ctx: hook_ctx
|
|
@@ -638,14 +578,14 @@ module FastpixClient
|
|
|
638
578
|
|
|
639
579
|
return response
|
|
640
580
|
else
|
|
641
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
581
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
642
582
|
end
|
|
643
583
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
644
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
584
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
645
585
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
646
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
586
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
647
587
|
else
|
|
648
|
-
if Utils.match_content_type(content_type,
|
|
588
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
649
589
|
http_response = @sdk_configuration.hooks.after_success(
|
|
650
590
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
651
591
|
hook_ctx: hook_ctx
|
|
@@ -663,7 +603,7 @@ module FastpixClient
|
|
|
663
603
|
|
|
664
604
|
return response
|
|
665
605
|
else
|
|
666
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
606
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
667
607
|
end
|
|
668
608
|
end
|
|
669
609
|
end
|
|
@@ -14,6 +14,54 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class InputVideo
|
|
16
16
|
extend T::Sig
|
|
17
|
+
|
|
18
|
+
API_ERROR_OCCURRED = 'API error occurred'
|
|
19
|
+
CONTENT_TYPE_JSON = 'application/json'
|
|
20
|
+
UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
|
|
21
|
+
|
|
22
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
23
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
24
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
25
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
26
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
27
|
+
error: error,
|
|
28
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
29
|
+
hook_ctx: hook_ctx
|
|
30
|
+
),
|
|
31
|
+
response: http_response
|
|
32
|
+
)
|
|
33
|
+
else
|
|
34
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
35
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
36
|
+
hook_ctx: hook_ctx
|
|
37
|
+
),
|
|
38
|
+
response: http_response
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if http_response.nil?
|
|
43
|
+
raise error unless error.nil?
|
|
44
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
http_response
|
|
48
|
+
end
|
|
49
|
+
private :apply_after_request_hooks
|
|
50
|
+
|
|
51
|
+
# Encodes the request body based on its serialized content type.
|
|
52
|
+
sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
|
|
53
|
+
def encode_request_body(req_content_type, data, form)
|
|
54
|
+
raise ArgumentError, 'request body is required' if data.nil? && form.nil?
|
|
55
|
+
|
|
56
|
+
if form
|
|
57
|
+
Utils.encode_form(form)
|
|
58
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
59
|
+
URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
60
|
+
else
|
|
61
|
+
data
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
private :encode_request_body
|
|
17
65
|
|
|
18
66
|
# Operations for inputting and creating video media
|
|
19
67
|
|
|
@@ -93,16 +141,8 @@ module FastpixClient
|
|
|
93
141
|
headers = T.cast(headers, T::Hash[String, String])
|
|
94
142
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
|
|
95
143
|
headers['content-type'] = req_content_type
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if form
|
|
99
|
-
body = Utils.encode_form(form)
|
|
100
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
101
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
102
|
-
else
|
|
103
|
-
body = data
|
|
104
|
-
end
|
|
105
|
-
headers['Accept'] = 'application/json'
|
|
144
|
+
body = encode_request_body(req_content_type, data, form)
|
|
145
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
106
146
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
107
147
|
|
|
108
148
|
security = @sdk_configuration.security_source&.call
|
|
@@ -142,32 +182,12 @@ module FastpixClient
|
|
|
142
182
|
rescue StandardError => e
|
|
143
183
|
error = e
|
|
144
184
|
ensure
|
|
145
|
-
|
|
146
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
147
|
-
error: error,
|
|
148
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
149
|
-
hook_ctx: hook_ctx
|
|
150
|
-
),
|
|
151
|
-
response: http_response
|
|
152
|
-
)
|
|
153
|
-
else
|
|
154
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
155
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
156
|
-
hook_ctx: hook_ctx
|
|
157
|
-
),
|
|
158
|
-
response: http_response
|
|
159
|
-
)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
if http_response.nil?
|
|
163
|
-
raise error if !error.nil?
|
|
164
|
-
raise 'no response'
|
|
165
|
-
end
|
|
185
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
166
186
|
end
|
|
167
187
|
|
|
168
188
|
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
169
189
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
170
|
-
if Utils.match_content_type(content_type,
|
|
190
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
171
191
|
http_response = @sdk_configuration.hooks.after_success(
|
|
172
192
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
173
193
|
hook_ctx: hook_ctx
|
|
@@ -185,14 +205,14 @@ module FastpixClient
|
|
|
185
205
|
|
|
186
206
|
return response
|
|
187
207
|
else
|
|
188
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
208
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
189
209
|
end
|
|
190
210
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
191
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
211
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
192
212
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
193
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
213
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
194
214
|
else
|
|
195
|
-
if Utils.match_content_type(content_type,
|
|
215
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
196
216
|
http_response = @sdk_configuration.hooks.after_success(
|
|
197
217
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
198
218
|
hook_ctx: hook_ctx
|
|
@@ -210,7 +230,7 @@ module FastpixClient
|
|
|
210
230
|
|
|
211
231
|
return response
|
|
212
232
|
else
|
|
213
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
233
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
214
234
|
end
|
|
215
235
|
end
|
|
216
236
|
end
|
|
@@ -256,16 +276,8 @@ module FastpixClient
|
|
|
256
276
|
headers = T.cast(headers, T::Hash[String, String])
|
|
257
277
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
|
|
258
278
|
headers['content-type'] = req_content_type
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if form
|
|
262
|
-
body = Utils.encode_form(form)
|
|
263
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
264
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
265
|
-
else
|
|
266
|
-
body = data
|
|
267
|
-
end
|
|
268
|
-
headers['Accept'] = 'application/json'
|
|
279
|
+
body = encode_request_body(req_content_type, data, form)
|
|
280
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
269
281
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
270
282
|
|
|
271
283
|
security = @sdk_configuration.security_source&.call
|
|
@@ -305,32 +317,12 @@ module FastpixClient
|
|
|
305
317
|
rescue StandardError => e
|
|
306
318
|
error = e
|
|
307
319
|
ensure
|
|
308
|
-
|
|
309
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
310
|
-
error: error,
|
|
311
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
312
|
-
hook_ctx: hook_ctx
|
|
313
|
-
),
|
|
314
|
-
response: http_response
|
|
315
|
-
)
|
|
316
|
-
else
|
|
317
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
318
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
319
|
-
hook_ctx: hook_ctx
|
|
320
|
-
),
|
|
321
|
-
response: http_response
|
|
322
|
-
)
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
if http_response.nil?
|
|
326
|
-
raise error if !error.nil?
|
|
327
|
-
raise 'no response'
|
|
328
|
-
end
|
|
320
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
329
321
|
end
|
|
330
322
|
|
|
331
323
|
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
332
324
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
333
|
-
if Utils.match_content_type(content_type,
|
|
325
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
334
326
|
http_response = @sdk_configuration.hooks.after_success(
|
|
335
327
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
336
328
|
hook_ctx: hook_ctx
|
|
@@ -348,14 +340,14 @@ module FastpixClient
|
|
|
348
340
|
|
|
349
341
|
return response
|
|
350
342
|
else
|
|
351
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
343
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
352
344
|
end
|
|
353
345
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
354
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
346
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
355
347
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
356
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
348
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
357
349
|
else
|
|
358
|
-
if Utils.match_content_type(content_type,
|
|
350
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
359
351
|
http_response = @sdk_configuration.hooks.after_success(
|
|
360
352
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
361
353
|
hook_ctx: hook_ctx
|
|
@@ -373,7 +365,7 @@ module FastpixClient
|
|
|
373
365
|
|
|
374
366
|
return response
|
|
375
367
|
else
|
|
376
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
368
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
377
369
|
end
|
|
378
370
|
end
|
|
379
371
|
end
|