fastpixapi 1.1.2 → 1.1.4

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/lib/crystalline/metadata_fields.rb +56 -48
  3. data/lib/crystalline/types.rb +3 -3
  4. data/lib/crystalline.rb +4 -5
  5. data/lib/fastpix_client/dimensions.rb +54 -61
  6. data/lib/fastpix_client/drm_configurations.rb +49 -56
  7. data/lib/fastpix_client/errors.rb +36 -25
  8. data/lib/fastpix_client/fastpixapi.rb +2 -4
  9. data/lib/fastpix_client/in_video_ai_features.rb +108 -168
  10. data/lib/fastpix_client/input_video.rb +70 -77
  11. data/lib/fastpix_client/live_playback.rb +82 -99
  12. data/lib/fastpix_client/manage_live_stream.rb +149 -264
  13. data/lib/fastpix_client/manage_videos.rb +249 -566
  14. data/lib/fastpix_client/metrics.rb +79 -123
  15. data/lib/fastpix_client/models/components/addtrackrequest.rb +6 -2
  16. data/lib/fastpix_client/models/components/addtrackrequest.rbi +2 -0
  17. data/lib/fastpix_client/models/components/addtrackresponse.rb +6 -2
  18. data/lib/fastpix_client/models/components/addtrackresponse.rbi +2 -0
  19. data/lib/fastpix_client/models/components/audiotrack.rb +6 -2
  20. data/lib/fastpix_client/models/components/audiotrack.rbi +2 -0
  21. data/lib/fastpix_client/models/components/createlivestreamresponsedto.rb +10 -18
  22. data/lib/fastpix_client/models/components/createmediarequest.rb +9 -18
  23. data/lib/fastpix_client/models/components/generatetrackresponse.rb +6 -2
  24. data/lib/fastpix_client/models/components/generatetrackresponse.rbi +2 -0
  25. data/lib/fastpix_client/models/components/getallmediaresponse.rb +20 -38
  26. data/lib/fastpix_client/models/components/getallmediaresponse.rbi +2 -0
  27. data/lib/fastpix_client/models/components/getallmediaresponse_mp4support.rb +32 -12
  28. data/lib/fastpix_client/models/components/getallmediaresponse_mp4support.rbi +11 -1
  29. data/lib/fastpix_client/models/components/getallmediaresponse_sourceresolution.rb +2 -0
  30. data/lib/fastpix_client/models/components/getcreatelivestreamresponsedto.rb +9 -20
  31. data/lib/fastpix_client/models/components/{getmediaresponse.rb → getmediadetailresponse.rb} +25 -43
  32. data/lib/fastpix_client/models/components/{getmediaresponse.rbi → getmediadetailresponse.rbi} +4 -2
  33. data/lib/fastpix_client/models/components/{getmediaresponse_maxresolution.rb → getmediadetailresponse_maxresolution.rb} +2 -2
  34. data/lib/fastpix_client/models/components/getmediadetailresponse_maxresolution.rbi +11 -0
  35. data/lib/fastpix_client/models/components/{getmediaresponse_mediaquality.rb → getmediadetailresponse_mediaquality.rb} +2 -2
  36. data/lib/fastpix_client/models/components/getmediadetailresponse_mediaquality.rbi +11 -0
  37. data/lib/fastpix_client/models/components/getmediadetailresponse_mp4support.rb +48 -0
  38. data/lib/fastpix_client/models/components/getmediadetailresponse_mp4support.rbi +21 -0
  39. data/lib/fastpix_client/models/components/{getmediaresponse_sourceresolution.rb → getmediadetailresponse_sourceresolution.rb} +4 -2
  40. data/lib/fastpix_client/models/components/getmediadetailresponse_sourceresolution.rbi +11 -0
  41. data/lib/fastpix_client/models/components/{getmediaresponse_status.rb → getmediadetailresponse_status.rb} +2 -2
  42. data/lib/fastpix_client/models/components/getmediadetailresponse_status.rbi +11 -0
  43. data/lib/fastpix_client/models/components/{getmediaresponse_track.rb → getmediadetailresponse_track.rb} +1 -1
  44. data/lib/fastpix_client/models/components/getmediadetailresponse_track.rbi +11 -0
  45. data/lib/fastpix_client/models/components/live_media_clips.rb +16 -30
  46. data/lib/fastpix_client/models/components/live_media_clips.rbi +2 -0
  47. data/lib/fastpix_client/models/components/live_media_clips_mp4support.rb +32 -12
  48. data/lib/fastpix_client/models/components/live_media_clips_mp4support.rbi +11 -1
  49. data/lib/fastpix_client/models/components/live_media_clips_sourceresolution.rb +2 -0
  50. data/lib/fastpix_client/models/components/media.rb +18 -35
  51. data/lib/fastpix_client/models/components/media.rbi +2 -0
  52. data/lib/fastpix_client/models/components/media_mp4support.rb +32 -12
  53. data/lib/fastpix_client/models/components/media_mp4support.rbi +11 -1
  54. data/lib/fastpix_client/models/components/media_sourceresolution.rb +2 -0
  55. data/lib/fastpix_client/models/components/patchresponsedata.rb +9 -18
  56. data/lib/fastpix_client/models/components/sourceaccessmedia.rb +18 -35
  57. data/lib/fastpix_client/models/components/sourceaccessmedia.rbi +2 -0
  58. data/lib/fastpix_client/models/components/sourceaccessmedia_mp4support.rb +32 -12
  59. data/lib/fastpix_client/models/components/sourceaccessmedia_mp4support.rbi +11 -1
  60. data/lib/fastpix_client/models/components/sourceaccessmedia_sourceresolution.rb +2 -0
  61. data/lib/fastpix_client/models/components/subtitletrack.rb +6 -2
  62. data/lib/fastpix_client/models/components/subtitletrack.rbi +2 -0
  63. data/lib/fastpix_client/models/components/tracksubtitlesgeneraterequest.rb +6 -2
  64. data/lib/fastpix_client/models/components/tracksubtitlesgeneraterequest.rbi +2 -0
  65. data/lib/fastpix_client/models/components/update_media.rb +18 -35
  66. data/lib/fastpix_client/models/components/update_media.rbi +2 -0
  67. data/lib/fastpix_client/models/components/update_media_maxresolution.rb +0 -1
  68. data/lib/fastpix_client/models/components/update_media_mp4support.rb +32 -12
  69. data/lib/fastpix_client/models/components/update_media_mp4support.rbi +11 -1
  70. data/lib/fastpix_client/models/components/updatetrackrequest.rb +7 -7
  71. data/lib/fastpix_client/models/components/updatetrackrequest.rbi +2 -2
  72. data/lib/fastpix_client/models/components/updatetrackresponse.rb +6 -2
  73. data/lib/fastpix_client/models/components/updatetrackresponse.rbi +2 -0
  74. data/lib/fastpix_client/models/components/videotrack.rb +6 -2
  75. data/lib/fastpix_client/models/components/videotrack.rbi +2 -0
  76. data/lib/fastpix_client/models/components/videotrackforgetall.rb +6 -2
  77. data/lib/fastpix_client/models/components/videotrackforgetall.rbi +2 -0
  78. data/lib/fastpix_client/models/components/views.rb +51 -124
  79. data/lib/fastpix_client/models/components.rb +7 -7
  80. data/lib/fastpix_client/models/errors/empty_response_error.rb +15 -0
  81. data/lib/fastpix_client/models/errors.rb +1 -0
  82. data/lib/fastpix_client/models/operations/get_media_response.rb +1 -1
  83. data/lib/fastpix_client/models/operations/get_media_responsebody.rb +2 -2
  84. data/lib/fastpix_client/models/operations/push_media_settings.rb +9 -20
  85. data/lib/fastpix_client/playback.rb +122 -213
  86. data/lib/fastpix_client/playlist.rb +152 -297
  87. data/lib/fastpix_client/sdk_hooks/registration.rb +2 -2
  88. data/lib/fastpix_client/sdk_hooks/types.rb +4 -0
  89. data/lib/fastpix_client/sdkconfiguration.rb +3 -3
  90. data/lib/fastpix_client/signing_keys.rb +76 -120
  91. data/lib/fastpix_client/simulcast_stream.rb +100 -144
  92. data/lib/fastpix_client/start_live_stream.rb +55 -37
  93. data/lib/fastpix_client/utils/forms.rb +97 -101
  94. data/lib/fastpix_client/utils/headers.rb +44 -34
  95. data/lib/fastpix_client/utils/query_params.rb +39 -29
  96. data/lib/fastpix_client/utils/request_bodies.rb +4 -8
  97. data/lib/fastpix_client/utils/security.rb +30 -18
  98. data/lib/fastpix_client/utils/url.rb +83 -60
  99. data/lib/fastpix_client/utils/utils.rb +19 -37
  100. data/lib/fastpix_client/views.rb +69 -93
  101. data/lib/fastpixapi.rb +10 -10
  102. data/lib/openssl_patch.rb +24 -24
  103. metadata +17 -18
  104. data/lib/fastpix_client/models/components/getmediaresponse_maxresolution.rbi +0 -11
  105. data/lib/fastpix_client/models/components/getmediaresponse_mediaquality.rbi +0 -11
  106. data/lib/fastpix_client/models/components/getmediaresponse_mp4support.rb +0 -28
  107. data/lib/fastpix_client/models/components/getmediaresponse_mp4support.rbi +0 -11
  108. data/lib/fastpix_client/models/components/getmediaresponse_sourceresolution.rbi +0 -11
  109. data/lib/fastpix_client/models/components/getmediaresponse_status.rbi +0 -11
  110. data/lib/fastpix_client/models/components/getmediaresponse_track.rbi +0 -11
  111. data/test/sdk_examples_test.rb +0 -20
  112. data/test/test_helper.rb +0 -29
@@ -14,6 +14,58 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class ManageLiveStream
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
+ STREAM_PATH = '/live/streams/{streamId}'
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 managing live streams
19
71
 
@@ -59,8 +111,8 @@ module FastpixClient
59
111
  headers = {}
60
112
  headers = T.cast(headers, T::Hash[String, String])
61
113
  query_params = Utils.get_query_params(Models::Operations::GetAllStreamsRequest, request, nil)
62
- headers['Accept'] = 'application/json'
63
- headers['user-agent'] = @sdk_configuration.user_agent
114
+ headers['Accept'] = CONTENT_TYPE_JSON
115
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
64
116
 
65
117
  security = @sdk_configuration.security_source&.call
66
118
 
@@ -99,32 +151,12 @@ module FastpixClient
99
151
  rescue StandardError => e
100
152
  error = e
101
153
  ensure
102
- if http_response.nil? || Utils.error_status?(http_response.status)
103
- http_response = @sdk_configuration.hooks.after_error(
104
- error: error,
105
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
106
- hook_ctx: hook_ctx
107
- ),
108
- response: http_response
109
- )
110
- else
111
- http_response = @sdk_configuration.hooks.after_success(
112
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
113
- hook_ctx: hook_ctx
114
- ),
115
- response: http_response
116
- )
117
- end
118
-
119
- if http_response.nil?
120
- raise error if !error.nil?
121
- raise 'no response'
122
- end
154
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
123
155
  end
124
156
 
125
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
157
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
126
158
  if Utils.match_status_code(http_response.status, ['200'])
127
- if Utils.match_content_type(content_type, 'application/json')
159
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
128
160
  http_response = @sdk_configuration.hooks.after_success(
129
161
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
130
162
  hook_ctx: hook_ctx
@@ -142,14 +174,14 @@ module FastpixClient
142
174
 
143
175
  return response
144
176
  else
145
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
177
+ 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
146
178
  end
147
179
  elsif Utils.match_status_code(http_response.status, ['4XX'])
148
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
180
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
149
181
  elsif Utils.match_status_code(http_response.status, ['5XX'])
150
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
182
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
151
183
  else
152
- if Utils.match_content_type(content_type, 'application/json')
184
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
153
185
  http_response = @sdk_configuration.hooks.after_success(
154
186
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
155
187
  hook_ctx: hook_ctx
@@ -167,7 +199,7 @@ module FastpixClient
167
199
 
168
200
  return response
169
201
  else
170
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
202
+ 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
171
203
  end
172
204
  end
173
205
  end
@@ -184,7 +216,7 @@ module FastpixClient
184
216
  #
185
217
  # Suppose a content creator is hosting a live concert and wants to display the number of live viewers on their dashboard. This endpoint can be queried to show up-to-date viewer statistics.
186
218
  #
187
- # Related guide: <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
219
+ # Related guide: <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#delete-a-stream">Manage streams</a>
188
220
  request = Models::Operations::GetLiveStreamViewerCountByIdRequest.new(
189
221
  stream_id: stream_id
190
222
  )
@@ -198,8 +230,8 @@ module FastpixClient
198
230
  )
199
231
  headers = {}
200
232
  headers = T.cast(headers, T::Hash[String, String])
201
- headers['Accept'] = 'application/json'
202
- headers['user-agent'] = @sdk_configuration.user_agent
233
+ headers['Accept'] = CONTENT_TYPE_JSON
234
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
203
235
 
204
236
  security = @sdk_configuration.security_source&.call
205
237
 
@@ -237,32 +269,12 @@ module FastpixClient
237
269
  rescue StandardError => e
238
270
  error = e
239
271
  ensure
240
- if http_response.nil? || Utils.error_status?(http_response.status)
241
- http_response = @sdk_configuration.hooks.after_error(
242
- error: error,
243
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
244
- hook_ctx: hook_ctx
245
- ),
246
- response: http_response
247
- )
248
- else
249
- http_response = @sdk_configuration.hooks.after_success(
250
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
251
- hook_ctx: hook_ctx
252
- ),
253
- response: http_response
254
- )
255
- end
256
-
257
- if http_response.nil?
258
- raise error if !error.nil?
259
- raise 'no response'
260
- end
272
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
261
273
  end
262
274
 
263
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
275
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
264
276
  if Utils.match_status_code(http_response.status, ['200'])
265
- if Utils.match_content_type(content_type, 'application/json')
277
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
266
278
  http_response = @sdk_configuration.hooks.after_success(
267
279
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
268
280
  hook_ctx: hook_ctx
@@ -280,14 +292,14 @@ module FastpixClient
280
292
 
281
293
  return response
282
294
  else
283
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
295
+ 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
284
296
  end
285
297
  elsif Utils.match_status_code(http_response.status, ['4XX'])
286
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
298
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
287
299
  elsif Utils.match_status_code(http_response.status, ['5XX'])
288
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
300
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
289
301
  else
290
- if Utils.match_content_type(content_type, 'application/json')
302
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
291
303
  http_response = @sdk_configuration.hooks.after_success(
292
304
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
293
305
  hook_ctx: hook_ctx
@@ -305,7 +317,7 @@ module FastpixClient
305
317
 
306
318
  return response
307
319
  else
308
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
320
+ 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
309
321
  end
310
322
  end
311
323
  end
@@ -319,8 +331,8 @@ module FastpixClient
319
331
  #
320
332
  # Suppose a news agency is broadcasting a live event and wants to track the configurations set for the live stream while also checking the stream's status.
321
333
  #
322
- #
323
- # Related guide: <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
334
+ # Related guide: <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#delete-a-stream">Manage streams</a>
335
+ #
324
336
  request = Models::Operations::GetLiveStreamByIdRequest.new(
325
337
  stream_id: stream_id
326
338
  )
@@ -329,13 +341,13 @@ module FastpixClient
329
341
  url = Utils.generate_url(
330
342
  Models::Operations::GetLiveStreamByIdRequest,
331
343
  base_url,
332
- '/live/streams/{streamId}',
344
+ STREAM_PATH,
333
345
  request
334
346
  )
335
347
  headers = {}
336
348
  headers = T.cast(headers, T::Hash[String, String])
337
- headers['Accept'] = 'application/json'
338
- headers['user-agent'] = @sdk_configuration.user_agent
349
+ headers['Accept'] = CONTENT_TYPE_JSON
350
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
339
351
 
340
352
  security = @sdk_configuration.security_source&.call
341
353
 
@@ -373,32 +385,12 @@ module FastpixClient
373
385
  rescue StandardError => e
374
386
  error = e
375
387
  ensure
376
- if http_response.nil? || Utils.error_status?(http_response.status)
377
- http_response = @sdk_configuration.hooks.after_error(
378
- error: error,
379
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
380
- hook_ctx: hook_ctx
381
- ),
382
- response: http_response
383
- )
384
- else
385
- http_response = @sdk_configuration.hooks.after_success(
386
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
387
- hook_ctx: hook_ctx
388
- ),
389
- response: http_response
390
- )
391
- end
392
-
393
- if http_response.nil?
394
- raise error if !error.nil?
395
- raise 'no response'
396
- end
388
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
397
389
  end
398
390
 
399
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
391
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
400
392
  if Utils.match_status_code(http_response.status, ['200'])
401
- if Utils.match_content_type(content_type, 'application/json')
393
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
402
394
  http_response = @sdk_configuration.hooks.after_success(
403
395
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
404
396
  hook_ctx: hook_ctx
@@ -416,14 +408,14 @@ module FastpixClient
416
408
 
417
409
  return response
418
410
  else
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 received'
411
+ 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
420
412
  end
421
413
  elsif Utils.match_status_code(http_response.status, ['4XX'])
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'
414
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
423
415
  elsif Utils.match_status_code(http_response.status, ['5XX'])
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'
416
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
425
417
  else
426
- if Utils.match_content_type(content_type, 'application/json')
418
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
427
419
  http_response = @sdk_configuration.hooks.after_success(
428
420
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
429
421
  hook_ctx: hook_ctx
@@ -441,7 +433,7 @@ module FastpixClient
441
433
 
442
434
  return response
443
435
  else
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 received'
436
+ 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
445
437
  end
446
438
  end
447
439
  end
@@ -452,14 +444,14 @@ module FastpixClient
452
444
  # delete_live_stream - Delete a stream
453
445
  # Permanently deletes a specified live stream from the workspace. If the stream is active, the encoder is disconnected and ingestion stops immediately. This action is irreversible, and any future playback attempts fail as a result.
454
446
  #
455
- # Provide the `streamId` in the request to terminate active connections and remove the stream from the workspace. You can further look for <a href="https://fastpix.com/docs/live-stream-events/live-events#videolive_streamdeleted">video.live_stream.deleted</a> webhook to notify your system about the status.
447
+ # Provide the `streamId` in the request to terminate active connections and remove the stream from the workspace. You can further look for <a href="https://fastpix.com/docs/webhooks/live-events#videolive_streamdeleted">video.live_stream.deleted</a> webhook to notify your system about the status.
456
448
  #
457
449
  # #### Example
458
450
  #
459
451
  # For an online concert platform, a trial stream was mistakenly made public. The event manager deletes the stream before the concert begins to avoid confusion among viewers.
460
452
  #
461
453
  #
462
- # Related guide: <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
454
+ # Related guide: <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#delete-a-stream">Manage streams</a>
463
455
  request = Models::Operations::DeleteLiveStreamRequest.new(
464
456
  stream_id: stream_id
465
457
  )
@@ -468,13 +460,13 @@ module FastpixClient
468
460
  url = Utils.generate_url(
469
461
  Models::Operations::DeleteLiveStreamRequest,
470
462
  base_url,
471
- '/live/streams/{streamId}',
463
+ STREAM_PATH,
472
464
  request
473
465
  )
474
466
  headers = {}
475
467
  headers = T.cast(headers, T::Hash[String, String])
476
- headers['Accept'] = 'application/json'
477
- headers['user-agent'] = @sdk_configuration.user_agent
468
+ headers['Accept'] = CONTENT_TYPE_JSON
469
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
478
470
 
479
471
  security = @sdk_configuration.security_source&.call
480
472
 
@@ -512,32 +504,12 @@ module FastpixClient
512
504
  rescue StandardError => e
513
505
  error = e
514
506
  ensure
515
- if http_response.nil? || Utils.error_status?(http_response.status)
516
- http_response = @sdk_configuration.hooks.after_error(
517
- error: error,
518
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
519
- hook_ctx: hook_ctx
520
- ),
521
- response: http_response
522
- )
523
- else
524
- http_response = @sdk_configuration.hooks.after_success(
525
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
526
- hook_ctx: hook_ctx
527
- ),
528
- response: http_response
529
- )
530
- end
531
-
532
- if http_response.nil?
533
- raise error if !error.nil?
534
- raise 'no response'
535
- end
507
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
536
508
  end
537
509
 
538
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
510
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
539
511
  if Utils.match_status_code(http_response.status, ['200'])
540
- if Utils.match_content_type(content_type, 'application/json')
512
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
541
513
  http_response = @sdk_configuration.hooks.after_success(
542
514
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
543
515
  hook_ctx: hook_ctx
@@ -555,14 +527,14 @@ module FastpixClient
555
527
 
556
528
  return response
557
529
  else
558
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
530
+ 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
559
531
  end
560
532
  elsif Utils.match_status_code(http_response.status, ['4XX'])
561
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
533
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
562
534
  elsif Utils.match_status_code(http_response.status, ['5XX'])
563
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
535
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
564
536
  else
565
- if Utils.match_content_type(content_type, 'application/json')
537
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
566
538
  http_response = @sdk_configuration.hooks.after_success(
567
539
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
568
540
  hook_ctx: hook_ctx
@@ -580,7 +552,7 @@ module FastpixClient
580
552
 
581
553
  return response
582
554
  else
583
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
555
+ 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
584
556
  end
585
557
  end
586
558
  end
@@ -592,15 +564,16 @@ module FastpixClient
592
564
  # This endpoint allows you to modify the parameters of an existing live stream, such as its `metadata` (title, description) or the `reconnectWindow`. It’s useful for making changes to a stream that has already been created but not yet ended. After the live stream is disabled, you cannot update a stream.
593
565
  #
594
566
  #
595
- # The updated stream parameters and the `streamId` needs to be shared in the request, and FastPix returns the updated stream details. After the update, <a href="https://fastpix.com/docs/live-stream-events/live-events#videolive_streamupdated">video.live_stream.updated</a> webhook event notifies your system.
596
- #
567
+ #
568
+ # The updated stream parameters and the `streamId` needs to be shared in the request, and FastPix returns the updated stream details. After the update, <a href="https://fastpix.com/docs/webhooks/live-events#videolive_streamupdated">video.live_stream.updated</a> webhook event notifies your system.
597
569
  # #### Example
598
570
  #
599
571
  # A host realizes they need to extend the reconnect window for their live stream in case they lose connection temporarily during the event. Or suppose during a multi-day online conference, the event organizers need to update the stream title to reflect the next day"s session while keeping the same stream ID for continuity.
600
572
  #
601
573
  #
602
- #
603
- # Related guide: <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
574
+ # Related guide: <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#delete-a-stream">Manage streams</a>
575
+ #
576
+ #
604
577
  request = Models::Operations::UpdateLiveStreamRequest.new(
605
578
  stream_id: stream_id,
606
579
  body: body
@@ -610,24 +583,16 @@ module FastpixClient
610
583
  url = Utils.generate_url(
611
584
  Models::Operations::UpdateLiveStreamRequest,
612
585
  base_url,
613
- '/live/streams/{streamId}',
586
+ STREAM_PATH,
614
587
  request
615
588
  )
616
589
  headers = {}
617
590
  headers = T.cast(headers, T::Hash[String, String])
618
591
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
619
592
  headers['content-type'] = req_content_type
620
- raise StandardError, 'request body is required' if data.nil? && form.nil?
621
-
622
- if form
623
- body = Utils.encode_form(form)
624
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
625
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
626
- else
627
- body = data
628
- end
629
- headers['Accept'] = 'application/json'
630
- headers['user-agent'] = @sdk_configuration.user_agent
593
+ body = encode_request_body(req_content_type, data, form)
594
+ headers['Accept'] = CONTENT_TYPE_JSON
595
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
631
596
 
632
597
  security = @sdk_configuration.security_source&.call
633
598
 
@@ -666,32 +631,12 @@ module FastpixClient
666
631
  rescue StandardError => e
667
632
  error = e
668
633
  ensure
669
- if http_response.nil? || Utils.error_status?(http_response.status)
670
- http_response = @sdk_configuration.hooks.after_error(
671
- error: error,
672
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
673
- hook_ctx: hook_ctx
674
- ),
675
- response: http_response
676
- )
677
- else
678
- http_response = @sdk_configuration.hooks.after_success(
679
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
680
- hook_ctx: hook_ctx
681
- ),
682
- response: http_response
683
- )
684
- end
685
-
686
- if http_response.nil?
687
- raise error if !error.nil?
688
- raise 'no response'
689
- end
634
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
690
635
  end
691
636
 
692
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
637
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
693
638
  if Utils.match_status_code(http_response.status, ['200'])
694
- if Utils.match_content_type(content_type, 'application/json')
639
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
695
640
  http_response = @sdk_configuration.hooks.after_success(
696
641
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
697
642
  hook_ctx: hook_ctx
@@ -709,14 +654,14 @@ module FastpixClient
709
654
 
710
655
  return response
711
656
  else
712
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
657
+ 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
713
658
  end
714
659
  elsif Utils.match_status_code(http_response.status, ['4XX'])
715
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
660
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
716
661
  elsif Utils.match_status_code(http_response.status, ['5XX'])
717
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
662
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
718
663
  else
719
- if Utils.match_content_type(content_type, 'application/json')
664
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
720
665
  http_response = @sdk_configuration.hooks.after_success(
721
666
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
722
667
  hook_ctx: hook_ctx
@@ -734,7 +679,7 @@ module FastpixClient
734
679
 
735
680
  return response
736
681
  else
737
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
682
+ 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
738
683
  end
739
684
  end
740
685
  end
@@ -753,7 +698,7 @@ module FastpixClient
753
698
  #
754
699
  # A creator disables a livestream to pause it temporarily. Later, they decide to continue the session. By calling this endpoint with the stream's ID, they can re-enable and restart the same livestream.
755
700
  #
756
- # Related guide <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
701
+ # Related guide <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#enable-a-stream">Manage streams</a>
757
702
  request = Models::Operations::EnableLiveStreamRequest.new(
758
703
  stream_id: stream_id
759
704
  )
@@ -767,8 +712,8 @@ module FastpixClient
767
712
  )
768
713
  headers = {}
769
714
  headers = T.cast(headers, T::Hash[String, String])
770
- headers['Accept'] = 'application/json'
771
- headers['user-agent'] = @sdk_configuration.user_agent
715
+ headers['Accept'] = CONTENT_TYPE_JSON
716
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
772
717
 
773
718
  security = @sdk_configuration.security_source&.call
774
719
 
@@ -806,32 +751,12 @@ module FastpixClient
806
751
  rescue StandardError => e
807
752
  error = e
808
753
  ensure
809
- if http_response.nil? || Utils.error_status?(http_response.status)
810
- http_response = @sdk_configuration.hooks.after_error(
811
- error: error,
812
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
813
- hook_ctx: hook_ctx
814
- ),
815
- response: http_response
816
- )
817
- else
818
- http_response = @sdk_configuration.hooks.after_success(
819
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
820
- hook_ctx: hook_ctx
821
- ),
822
- response: http_response
823
- )
824
- end
825
-
826
- if http_response.nil?
827
- raise error if !error.nil?
828
- raise 'no response'
829
- end
754
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
830
755
  end
831
756
 
832
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
757
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
833
758
  if Utils.match_status_code(http_response.status, ['200'])
834
- if Utils.match_content_type(content_type, 'application/json')
759
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
835
760
  http_response = @sdk_configuration.hooks.after_success(
836
761
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
837
762
  hook_ctx: hook_ctx
@@ -849,14 +774,14 @@ module FastpixClient
849
774
 
850
775
  return response
851
776
  else
852
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
777
+ 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
853
778
  end
854
779
  elsif Utils.match_status_code(http_response.status, ['4XX'])
855
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
780
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
856
781
  elsif Utils.match_status_code(http_response.status, ['5XX'])
857
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
782
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
858
783
  else
859
- if Utils.match_content_type(content_type, 'application/json')
784
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
860
785
  http_response = @sdk_configuration.hooks.after_success(
861
786
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
862
787
  hook_ctx: hook_ctx
@@ -874,7 +799,7 @@ module FastpixClient
874
799
 
875
800
  return response
876
801
  else
877
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
802
+ 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
878
803
  end
879
804
  end
880
805
  end
@@ -891,7 +816,7 @@ module FastpixClient
891
816
  #
892
817
  # A speaker finishes their live session and wants to prevent the stream from being mistakenly started again. By calling this endpoint, the stream is transitioned to a `disabled` state, ensuring it's permanently stopped (unless re-enabled on a paid plan).
893
818
  #
894
- # Related guide <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
819
+ #Related guide <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#enable-a-stream">Manage streams</a>
895
820
  request = Models::Operations::DisableLiveStreamRequest.new(
896
821
  stream_id: stream_id
897
822
  )
@@ -905,8 +830,8 @@ module FastpixClient
905
830
  )
906
831
  headers = {}
907
832
  headers = T.cast(headers, T::Hash[String, String])
908
- headers['Accept'] = 'application/json'
909
- headers['user-agent'] = @sdk_configuration.user_agent
833
+ headers['Accept'] = CONTENT_TYPE_JSON
834
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
910
835
 
911
836
  security = @sdk_configuration.security_source&.call
912
837
 
@@ -944,32 +869,12 @@ module FastpixClient
944
869
  rescue StandardError => e
945
870
  error = e
946
871
  ensure
947
- if http_response.nil? || Utils.error_status?(http_response.status)
948
- http_response = @sdk_configuration.hooks.after_error(
949
- error: error,
950
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
951
- hook_ctx: hook_ctx
952
- ),
953
- response: http_response
954
- )
955
- else
956
- http_response = @sdk_configuration.hooks.after_success(
957
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
958
- hook_ctx: hook_ctx
959
- ),
960
- response: http_response
961
- )
962
- end
963
-
964
- if http_response.nil?
965
- raise error if !error.nil?
966
- raise 'no response'
967
- end
872
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
968
873
  end
969
874
 
970
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
875
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
971
876
  if Utils.match_status_code(http_response.status, ['200'])
972
- if Utils.match_content_type(content_type, 'application/json')
877
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
973
878
  http_response = @sdk_configuration.hooks.after_success(
974
879
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
975
880
  hook_ctx: hook_ctx
@@ -987,14 +892,14 @@ module FastpixClient
987
892
 
988
893
  return response
989
894
  else
990
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
895
+ 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
991
896
  end
992
897
  elsif Utils.match_status_code(http_response.status, ['4XX'])
993
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
898
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
994
899
  elsif Utils.match_status_code(http_response.status, ['5XX'])
995
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
900
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
996
901
  else
997
- if Utils.match_content_type(content_type, 'application/json')
902
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
998
903
  http_response = @sdk_configuration.hooks.after_success(
999
904
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1000
905
  hook_ctx: hook_ctx
@@ -1012,7 +917,7 @@ module FastpixClient
1012
917
 
1013
918
  return response
1014
919
  else
1015
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
920
+ 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
1016
921
  end
1017
922
  end
1018
923
  end
@@ -1031,7 +936,7 @@ module FastpixClient
1031
936
  #
1032
937
  # A virtual event ends, and the system or host needs to close the livestream to prevent further streaming. This endpoint ensures the livestream status is changed from `active` to `idle`, indicating it's officially completed.
1033
938
  #
1034
- # Related guide <a href="https://fastpix.com/docs/manage-live-streams/create-and-manage-live-streams">Manage streams</a>
939
+ #Related guide <a href="https://fastpix.com/docs/live-streaming/create-and-manage-live-streams#enable-a-stream">Manage streams</a>
1035
940
  request = Models::Operations::CompleteLiveStreamRequest.new(
1036
941
  stream_id: stream_id
1037
942
  )
@@ -1045,8 +950,8 @@ module FastpixClient
1045
950
  )
1046
951
  headers = {}
1047
952
  headers = T.cast(headers, T::Hash[String, String])
1048
- headers['Accept'] = 'application/json'
1049
- headers['user-agent'] = @sdk_configuration.user_agent
953
+ headers['Accept'] = CONTENT_TYPE_JSON
954
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1050
955
 
1051
956
  security = @sdk_configuration.security_source&.call
1052
957
 
@@ -1084,32 +989,12 @@ module FastpixClient
1084
989
  rescue StandardError => e
1085
990
  error = e
1086
991
  ensure
1087
- if http_response.nil? || Utils.error_status?(http_response.status)
1088
- http_response = @sdk_configuration.hooks.after_error(
1089
- error: error,
1090
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1091
- hook_ctx: hook_ctx
1092
- ),
1093
- response: http_response
1094
- )
1095
- else
1096
- http_response = @sdk_configuration.hooks.after_success(
1097
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1098
- hook_ctx: hook_ctx
1099
- ),
1100
- response: http_response
1101
- )
1102
- end
1103
-
1104
- if http_response.nil?
1105
- raise error if !error.nil?
1106
- raise 'no response'
1107
- end
992
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1108
993
  end
1109
994
 
1110
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
995
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1111
996
  if Utils.match_status_code(http_response.status, ['200'])
1112
- if Utils.match_content_type(content_type, 'application/json')
997
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1113
998
  http_response = @sdk_configuration.hooks.after_success(
1114
999
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1115
1000
  hook_ctx: hook_ctx
@@ -1127,14 +1012,14 @@ module FastpixClient
1127
1012
 
1128
1013
  return response
1129
1014
  else
1130
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
1015
+ 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
1131
1016
  end
1132
1017
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1133
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1018
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1134
1019
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1135
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1020
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1136
1021
  else
1137
- if Utils.match_content_type(content_type, 'application/json')
1022
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1138
1023
  http_response = @sdk_configuration.hooks.after_success(
1139
1024
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1140
1025
  hook_ctx: hook_ctx
@@ -1152,7 +1037,7 @@ module FastpixClient
1152
1037
 
1153
1038
  return response
1154
1039
  else
1155
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
1040
+ 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
1156
1041
  end
1157
1042
  end
1158
1043
  end