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 SimulcastStream
|
|
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
|
+
SIMULCAST_PATH = '/live/streams/{streamId}/simulcast/{simulcastId}'
|
|
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 simulcast stream management
|
|
19
71
|
|
|
@@ -69,17 +121,9 @@ module FastpixClient
|
|
|
69
121
|
headers = T.cast(headers, T::Hash[String, String])
|
|
70
122
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
71
123
|
headers['content-type'] = req_content_type
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
body = Utils.encode_form(form)
|
|
76
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
77
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
78
|
-
else
|
|
79
|
-
body = data
|
|
80
|
-
end
|
|
81
|
-
headers['Accept'] = 'application/json'
|
|
82
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
124
|
+
body = encode_request_body(req_content_type, data, form)
|
|
125
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
126
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
83
127
|
|
|
84
128
|
security = @sdk_configuration.security_source&.call
|
|
85
129
|
|
|
@@ -118,32 +162,12 @@ module FastpixClient
|
|
|
118
162
|
rescue StandardError => e
|
|
119
163
|
error = e
|
|
120
164
|
ensure
|
|
121
|
-
|
|
122
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
123
|
-
error: error,
|
|
124
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
125
|
-
hook_ctx: hook_ctx
|
|
126
|
-
),
|
|
127
|
-
response: http_response
|
|
128
|
-
)
|
|
129
|
-
else
|
|
130
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
131
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
132
|
-
hook_ctx: hook_ctx
|
|
133
|
-
),
|
|
134
|
-
response: http_response
|
|
135
|
-
)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
if http_response.nil?
|
|
139
|
-
raise error if !error.nil?
|
|
140
|
-
raise 'no response'
|
|
141
|
-
end
|
|
165
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
142
166
|
end
|
|
143
167
|
|
|
144
|
-
content_type = http_response.headers.fetch(
|
|
168
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
145
169
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
146
|
-
if Utils.match_content_type(content_type,
|
|
170
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
147
171
|
http_response = @sdk_configuration.hooks.after_success(
|
|
148
172
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
149
173
|
hook_ctx: hook_ctx
|
|
@@ -161,14 +185,14 @@ module FastpixClient
|
|
|
161
185
|
|
|
162
186
|
return response
|
|
163
187
|
else
|
|
164
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
188
|
+
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
|
|
165
189
|
end
|
|
166
190
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
167
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
191
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
168
192
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
169
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
193
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
170
194
|
else
|
|
171
|
-
if Utils.match_content_type(content_type,
|
|
195
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
172
196
|
http_response = @sdk_configuration.hooks.after_success(
|
|
173
197
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
174
198
|
hook_ctx: hook_ctx
|
|
@@ -186,7 +210,7 @@ module FastpixClient
|
|
|
186
210
|
|
|
187
211
|
return response
|
|
188
212
|
else
|
|
189
|
-
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), UNKNOWN_CONTENT_TYPE_ERROR
|
|
190
214
|
end
|
|
191
215
|
end
|
|
192
216
|
end
|
|
@@ -211,13 +235,13 @@ module FastpixClient
|
|
|
211
235
|
url = Utils.generate_url(
|
|
212
236
|
Models::Operations::DeleteSimulcastOfStreamRequest,
|
|
213
237
|
base_url,
|
|
214
|
-
|
|
238
|
+
SIMULCAST_PATH,
|
|
215
239
|
request
|
|
216
240
|
)
|
|
217
241
|
headers = {}
|
|
218
242
|
headers = T.cast(headers, T::Hash[String, String])
|
|
219
|
-
headers['Accept'] =
|
|
220
|
-
headers[
|
|
243
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
244
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
221
245
|
|
|
222
246
|
security = @sdk_configuration.security_source&.call
|
|
223
247
|
|
|
@@ -255,32 +279,12 @@ module FastpixClient
|
|
|
255
279
|
rescue StandardError => e
|
|
256
280
|
error = e
|
|
257
281
|
ensure
|
|
258
|
-
|
|
259
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
260
|
-
error: error,
|
|
261
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
262
|
-
hook_ctx: hook_ctx
|
|
263
|
-
),
|
|
264
|
-
response: http_response
|
|
265
|
-
)
|
|
266
|
-
else
|
|
267
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
268
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
269
|
-
hook_ctx: hook_ctx
|
|
270
|
-
),
|
|
271
|
-
response: http_response
|
|
272
|
-
)
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
if http_response.nil?
|
|
276
|
-
raise error if !error.nil?
|
|
277
|
-
raise 'no response'
|
|
278
|
-
end
|
|
282
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
279
283
|
end
|
|
280
284
|
|
|
281
|
-
content_type = http_response.headers.fetch(
|
|
285
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
282
286
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
283
|
-
if Utils.match_content_type(content_type,
|
|
287
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
284
288
|
http_response = @sdk_configuration.hooks.after_success(
|
|
285
289
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
286
290
|
hook_ctx: hook_ctx
|
|
@@ -298,14 +302,14 @@ module FastpixClient
|
|
|
298
302
|
|
|
299
303
|
return response
|
|
300
304
|
else
|
|
301
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
305
|
+
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
|
|
302
306
|
end
|
|
303
307
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
304
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
308
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
305
309
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
306
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
310
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
307
311
|
else
|
|
308
|
-
if Utils.match_content_type(content_type,
|
|
312
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
309
313
|
http_response = @sdk_configuration.hooks.after_success(
|
|
310
314
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
311
315
|
hook_ctx: hook_ctx
|
|
@@ -323,7 +327,7 @@ module FastpixClient
|
|
|
323
327
|
|
|
324
328
|
return response
|
|
325
329
|
else
|
|
326
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
330
|
+
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
331
|
end
|
|
328
332
|
end
|
|
329
333
|
end
|
|
@@ -345,13 +349,13 @@ module FastpixClient
|
|
|
345
349
|
url = Utils.generate_url(
|
|
346
350
|
Models::Operations::GetSpecificSimulcastOfStreamRequest,
|
|
347
351
|
base_url,
|
|
348
|
-
|
|
352
|
+
SIMULCAST_PATH,
|
|
349
353
|
request
|
|
350
354
|
)
|
|
351
355
|
headers = {}
|
|
352
356
|
headers = T.cast(headers, T::Hash[String, String])
|
|
353
|
-
headers['Accept'] =
|
|
354
|
-
headers[
|
|
357
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
358
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
355
359
|
|
|
356
360
|
security = @sdk_configuration.security_source&.call
|
|
357
361
|
|
|
@@ -389,32 +393,12 @@ module FastpixClient
|
|
|
389
393
|
rescue StandardError => e
|
|
390
394
|
error = e
|
|
391
395
|
ensure
|
|
392
|
-
|
|
393
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
394
|
-
error: error,
|
|
395
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
396
|
-
hook_ctx: hook_ctx
|
|
397
|
-
),
|
|
398
|
-
response: http_response
|
|
399
|
-
)
|
|
400
|
-
else
|
|
401
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
402
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
403
|
-
hook_ctx: hook_ctx
|
|
404
|
-
),
|
|
405
|
-
response: http_response
|
|
406
|
-
)
|
|
407
|
-
end
|
|
408
|
-
|
|
409
|
-
if http_response.nil?
|
|
410
|
-
raise error if !error.nil?
|
|
411
|
-
raise 'no response'
|
|
412
|
-
end
|
|
396
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
413
397
|
end
|
|
414
398
|
|
|
415
|
-
content_type = http_response.headers.fetch(
|
|
399
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
416
400
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
417
|
-
if Utils.match_content_type(content_type,
|
|
401
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
418
402
|
http_response = @sdk_configuration.hooks.after_success(
|
|
419
403
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
420
404
|
hook_ctx: hook_ctx
|
|
@@ -432,14 +416,14 @@ module FastpixClient
|
|
|
432
416
|
|
|
433
417
|
return response
|
|
434
418
|
else
|
|
435
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
419
|
+
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
|
|
436
420
|
end
|
|
437
421
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
438
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
422
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
439
423
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
440
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
424
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
441
425
|
else
|
|
442
|
-
if Utils.match_content_type(content_type,
|
|
426
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
443
427
|
http_response = @sdk_configuration.hooks.after_success(
|
|
444
428
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
445
429
|
hook_ctx: hook_ctx
|
|
@@ -457,7 +441,7 @@ module FastpixClient
|
|
|
457
441
|
|
|
458
442
|
return response
|
|
459
443
|
else
|
|
460
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
444
|
+
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
|
|
461
445
|
end
|
|
462
446
|
end
|
|
463
447
|
end
|
|
@@ -482,24 +466,16 @@ module FastpixClient
|
|
|
482
466
|
url = Utils.generate_url(
|
|
483
467
|
Models::Operations::UpdateSpecificSimulcastOfStreamRequest,
|
|
484
468
|
base_url,
|
|
485
|
-
|
|
469
|
+
SIMULCAST_PATH,
|
|
486
470
|
request
|
|
487
471
|
)
|
|
488
472
|
headers = {}
|
|
489
473
|
headers = T.cast(headers, T::Hash[String, String])
|
|
490
474
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
491
475
|
headers['content-type'] = req_content_type
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
body = Utils.encode_form(form)
|
|
496
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
497
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
498
|
-
else
|
|
499
|
-
body = data
|
|
500
|
-
end
|
|
501
|
-
headers['Accept'] = 'application/json'
|
|
502
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
476
|
+
body = encode_request_body(req_content_type, data, form)
|
|
477
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
478
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
503
479
|
|
|
504
480
|
security = @sdk_configuration.security_source&.call
|
|
505
481
|
|
|
@@ -538,32 +514,12 @@ module FastpixClient
|
|
|
538
514
|
rescue StandardError => e
|
|
539
515
|
error = e
|
|
540
516
|
ensure
|
|
541
|
-
|
|
542
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
543
|
-
error: error,
|
|
544
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
545
|
-
hook_ctx: hook_ctx
|
|
546
|
-
),
|
|
547
|
-
response: http_response
|
|
548
|
-
)
|
|
549
|
-
else
|
|
550
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
551
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
552
|
-
hook_ctx: hook_ctx
|
|
553
|
-
),
|
|
554
|
-
response: http_response
|
|
555
|
-
)
|
|
556
|
-
end
|
|
557
|
-
|
|
558
|
-
if http_response.nil?
|
|
559
|
-
raise error if !error.nil?
|
|
560
|
-
raise 'no response'
|
|
561
|
-
end
|
|
517
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
562
518
|
end
|
|
563
519
|
|
|
564
|
-
content_type = http_response.headers.fetch(
|
|
520
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
565
521
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
566
|
-
if Utils.match_content_type(content_type,
|
|
522
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
567
523
|
http_response = @sdk_configuration.hooks.after_success(
|
|
568
524
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
569
525
|
hook_ctx: hook_ctx
|
|
@@ -581,14 +537,14 @@ module FastpixClient
|
|
|
581
537
|
|
|
582
538
|
return response
|
|
583
539
|
else
|
|
584
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
540
|
+
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
|
|
585
541
|
end
|
|
586
542
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
587
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
543
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
588
544
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
589
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
545
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
590
546
|
else
|
|
591
|
-
if Utils.match_content_type(content_type,
|
|
547
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
592
548
|
http_response = @sdk_configuration.hooks.after_success(
|
|
593
549
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
594
550
|
hook_ctx: hook_ctx
|
|
@@ -606,7 +562,7 @@ module FastpixClient
|
|
|
606
562
|
|
|
607
563
|
return response
|
|
608
564
|
else
|
|
609
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
565
|
+
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
|
|
610
566
|
end
|
|
611
567
|
end
|
|
612
568
|
end
|
|
@@ -14,6 +14,52 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class StartLiveStream
|
|
16
16
|
extend T::Sig
|
|
17
|
+
|
|
18
|
+
CONTENT_TYPE_JSON = 'application/json'
|
|
19
|
+
|
|
20
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
21
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
22
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
23
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
24
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
25
|
+
error: error,
|
|
26
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
27
|
+
hook_ctx: hook_ctx
|
|
28
|
+
),
|
|
29
|
+
response: http_response
|
|
30
|
+
)
|
|
31
|
+
else
|
|
32
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
33
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
34
|
+
hook_ctx: hook_ctx
|
|
35
|
+
),
|
|
36
|
+
response: http_response
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if http_response.nil?
|
|
41
|
+
raise error unless error.nil?
|
|
42
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
http_response
|
|
46
|
+
end
|
|
47
|
+
private :apply_after_request_hooks
|
|
48
|
+
|
|
49
|
+
# Encodes the request body based on its serialized content type.
|
|
50
|
+
sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
|
|
51
|
+
def encode_request_body(req_content_type, data, form)
|
|
52
|
+
raise ArgumentError, 'request body is required' if data.nil? && form.nil?
|
|
53
|
+
|
|
54
|
+
if form
|
|
55
|
+
Utils.encode_form(form)
|
|
56
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
57
|
+
URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
58
|
+
else
|
|
59
|
+
data
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
private :encode_request_body
|
|
17
63
|
|
|
18
64
|
# Operations for starting live streams
|
|
19
65
|
|
|
@@ -69,16 +115,8 @@ module FastpixClient
|
|
|
69
115
|
headers = T.cast(headers, T::Hash[String, String])
|
|
70
116
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
|
|
71
117
|
headers['content-type'] = req_content_type
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if form
|
|
75
|
-
body = Utils.encode_form(form)
|
|
76
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
77
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
78
|
-
else
|
|
79
|
-
body = data
|
|
80
|
-
end
|
|
81
|
-
headers['Accept'] = 'application/json'
|
|
118
|
+
body = encode_request_body(req_content_type, data, form)
|
|
119
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
82
120
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
83
121
|
|
|
84
122
|
security = @sdk_configuration.security_source&.call
|
|
@@ -118,32 +156,12 @@ module FastpixClient
|
|
|
118
156
|
rescue StandardError => e
|
|
119
157
|
error = e
|
|
120
158
|
ensure
|
|
121
|
-
|
|
122
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
123
|
-
error: error,
|
|
124
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
125
|
-
hook_ctx: hook_ctx
|
|
126
|
-
),
|
|
127
|
-
response: http_response
|
|
128
|
-
)
|
|
129
|
-
else
|
|
130
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
131
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
132
|
-
hook_ctx: hook_ctx
|
|
133
|
-
),
|
|
134
|
-
response: http_response
|
|
135
|
-
)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
if http_response.nil?
|
|
139
|
-
raise error if !error.nil?
|
|
140
|
-
raise 'no response'
|
|
141
|
-
end
|
|
159
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
142
160
|
end
|
|
143
161
|
|
|
144
162
|
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
145
163
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
146
|
-
if Utils.match_content_type(content_type,
|
|
164
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
147
165
|
http_response = @sdk_configuration.hooks.after_success(
|
|
148
166
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
149
167
|
hook_ctx: hook_ctx
|
|
@@ -168,7 +186,7 @@ module FastpixClient
|
|
|
168
186
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
169
187
|
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
170
188
|
else
|
|
171
|
-
if Utils.match_content_type(content_type,
|
|
189
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
172
190
|
http_response = @sdk_configuration.hooks.after_success(
|
|
173
191
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
174
192
|
hook_ctx: hook_ctx
|