fastpixapi 1.1.1 → 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.
Files changed (122) 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 +55 -62
  6. data/lib/fastpix_client/drm_configurations.rb +51 -58
  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 +75 -83
  11. data/lib/fastpix_client/live_playback.rb +82 -99
  12. data/lib/fastpix_client/manage_live_stream.rb +145 -261
  13. data/lib/fastpix_client/manage_videos.rb +252 -567
  14. data/lib/fastpix_client/metrics.rb +82 -126
  15. data/lib/fastpix_client/models/components/addtrackrequest.rb +1 -1
  16. data/lib/fastpix_client/models/components/createlivestreamresponsedto.rb +10 -18
  17. data/lib/fastpix_client/models/components/createmediarequest.rb +10 -19
  18. data/lib/fastpix_client/models/components/deletesigningkeyresponse.rb +6 -2
  19. data/lib/fastpix_client/models/components/deletesigningkeyresponsedata.rb +33 -0
  20. data/lib/fastpix_client/models/components/getallmediaresponse.rb +13 -29
  21. data/lib/fastpix_client/models/components/getcreatelivestreamresponsedto.rb +9 -20
  22. data/lib/fastpix_client/models/components/getmediaresponse.rb +13 -29
  23. data/lib/fastpix_client/models/components/live_media_clips.rb +9 -21
  24. data/lib/fastpix_client/models/components/media.rb +11 -26
  25. data/lib/fastpix_client/models/components/patchresponsedata.rb +9 -18
  26. data/lib/fastpix_client/models/components/pullvideoinput.rb +1 -1
  27. data/lib/fastpix_client/models/components/sourceaccessmedia.rb +11 -26
  28. data/lib/fastpix_client/models/components/update_media.rb +11 -26
  29. data/lib/fastpix_client/models/components/views.rb +52 -125
  30. data/lib/fastpix_client/models/components/watermarkinput.rb +1 -1
  31. data/lib/fastpix_client/models/components.rb +1 -0
  32. data/lib/fastpix_client/models/errors/empty_response_error.rb +15 -0
  33. data/lib/fastpix_client/models/errors.rb +1 -0
  34. data/lib/fastpix_client/models/operations/add_media_to_playlist_response.rb +1 -1
  35. data/lib/fastpix_client/models/operations/add_media_track_response.rb +1 -1
  36. data/lib/fastpix_client/models/operations/cancel_upload_response.rb +1 -1
  37. data/lib/fastpix_client/models/operations/change_media_order_in_playlist_response.rb +1 -1
  38. data/lib/fastpix_client/models/operations/complete_live_stream_response.rb +1 -1
  39. data/lib/fastpix_client/models/operations/create_a_playlist_response.rb +1 -1
  40. data/lib/fastpix_client/models/operations/create_media_playback_id_response.rb +1 -1
  41. data/lib/fastpix_client/models/operations/create_media_response.rb +1 -1
  42. data/lib/fastpix_client/models/operations/create_new_stream_response.rb +1 -1
  43. data/lib/fastpix_client/models/operations/create_playbackid_of_stream_response.rb +1 -1
  44. data/lib/fastpix_client/models/operations/create_signing_key_response.rb +1 -1
  45. data/lib/fastpix_client/models/operations/create_simulcast_of_stream_response.rb +1 -1
  46. data/lib/fastpix_client/models/operations/delete_a_playlist_response.rb +1 -1
  47. data/lib/fastpix_client/models/operations/delete_live_stream_response.rb +1 -1
  48. data/lib/fastpix_client/models/operations/delete_media_from_playlist_response.rb +1 -1
  49. data/lib/fastpix_client/models/operations/delete_media_playback_id_response.rb +1 -1
  50. data/lib/fastpix_client/models/operations/delete_media_response.rb +1 -1
  51. data/lib/fastpix_client/models/operations/delete_media_track_response.rb +1 -1
  52. data/lib/fastpix_client/models/operations/delete_playbackid_of_stream_response.rb +1 -1
  53. data/lib/fastpix_client/models/operations/delete_signing_key_response.rb +1 -1
  54. data/lib/fastpix_client/models/operations/delete_simulcast_of_stream_response.rb +1 -1
  55. data/lib/fastpix_client/models/operations/direct_upload_video_media_request.rb +1 -1
  56. data/lib/fastpix_client/models/operations/direct_upload_video_media_response.rb +1 -1
  57. data/lib/fastpix_client/models/operations/disable_live_stream_response.rb +1 -1
  58. data/lib/fastpix_client/models/operations/enable_live_stream_response.rb +1 -1
  59. data/lib/fastpix_client/models/operations/generate_subtitle_track_response.rb +1 -1
  60. data/lib/fastpix_client/models/operations/get_all_playlists_response.rb +1 -1
  61. data/lib/fastpix_client/models/operations/get_all_streams_response.rb +1 -1
  62. data/lib/fastpix_client/models/operations/get_live_stream_by_id_response.rb +1 -1
  63. data/lib/fastpix_client/models/operations/get_live_stream_playback_id_response.rb +1 -1
  64. data/lib/fastpix_client/models/operations/get_live_stream_viewer_count_by_id_response.rb +1 -1
  65. data/lib/fastpix_client/models/operations/get_media_clips_response.rb +1 -1
  66. data/lib/fastpix_client/models/operations/get_media_response.rb +1 -1
  67. data/lib/fastpix_client/models/operations/get_media_summary_response.rb +1 -1
  68. data/lib/fastpix_client/models/operations/get_playback_id_response.rb +1 -1
  69. data/lib/fastpix_client/models/operations/get_playlist_by_id_response.rb +1 -1
  70. data/lib/fastpix_client/models/operations/get_signing_key_by_id_response.rb +1 -1
  71. data/lib/fastpix_client/models/operations/get_specific_simulcast_of_stream_response.rb +1 -1
  72. data/lib/fastpix_client/models/operations/get_timeseries_data_response.rb +1 -1
  73. data/lib/fastpix_client/models/operations/get_video_view_details_response.rb +1 -1
  74. data/lib/fastpix_client/models/operations/getdrmconfiguration_response.rb +1 -1
  75. data/lib/fastpix_client/models/operations/getdrmconfigurationbyid_response.rb +1 -1
  76. data/lib/fastpix_client/models/operations/list_breakdown_values_response.rb +1 -1
  77. data/lib/fastpix_client/models/operations/list_by_top_content_response.rb +1 -1
  78. data/lib/fastpix_client/models/operations/list_comparison_values_response.rb +1 -1
  79. data/lib/fastpix_client/models/operations/list_dimensions_response.rb +1 -1
  80. data/lib/fastpix_client/models/operations/list_errors_response.rb +1 -1
  81. data/lib/fastpix_client/models/operations/list_filter_values_for_dimension_response.rb +1 -1
  82. data/lib/fastpix_client/models/operations/list_live_clips_response.rb +1 -1
  83. data/lib/fastpix_client/models/operations/list_media_response.rb +1 -1
  84. data/lib/fastpix_client/models/operations/list_overall_values_response.rb +1 -1
  85. data/lib/fastpix_client/models/operations/list_playback_ids_response.rb +1 -1
  86. data/lib/fastpix_client/models/operations/list_signing_keys_response.rb +1 -1
  87. data/lib/fastpix_client/models/operations/list_uploads_response.rb +1 -1
  88. data/lib/fastpix_client/models/operations/list_video_views_response.rb +1 -1
  89. data/lib/fastpix_client/models/operations/push_media_settings.rb +10 -21
  90. data/lib/fastpix_client/models/operations/retrievemediainputinfo_response.rb +1 -1
  91. data/lib/fastpix_client/models/operations/update_a_playlist_response.rb +1 -1
  92. data/lib/fastpix_client/models/operations/update_domain_restrictions_response.rb +1 -1
  93. data/lib/fastpix_client/models/operations/update_live_stream_response.rb +1 -1
  94. data/lib/fastpix_client/models/operations/update_media_chapters_response.rb +1 -1
  95. data/lib/fastpix_client/models/operations/update_media_moderation_response.rb +1 -1
  96. data/lib/fastpix_client/models/operations/update_media_named_entities_response.rb +1 -1
  97. data/lib/fastpix_client/models/operations/update_media_summary_response.rb +1 -1
  98. data/lib/fastpix_client/models/operations/update_media_track_response.rb +1 -1
  99. data/lib/fastpix_client/models/operations/update_specific_simulcast_of_stream_response.rb +1 -1
  100. data/lib/fastpix_client/models/operations/update_user_agent_restrictions_response.rb +1 -1
  101. data/lib/fastpix_client/models/operations/updated_media_response.rb +1 -1
  102. data/lib/fastpix_client/models/operations/updated_mp4support_response.rb +1 -1
  103. data/lib/fastpix_client/models/operations/updated_source_access_response.rb +1 -1
  104. data/lib/fastpix_client/playback.rb +123 -214
  105. data/lib/fastpix_client/playlist.rb +151 -297
  106. data/lib/fastpix_client/sdk_hooks/registration.rb +2 -2
  107. data/lib/fastpix_client/sdk_hooks/types.rb +4 -0
  108. data/lib/fastpix_client/sdkconfiguration.rb +4 -4
  109. data/lib/fastpix_client/signing_keys.rb +79 -123
  110. data/lib/fastpix_client/simulcast_stream.rb +101 -145
  111. data/lib/fastpix_client/start_live_stream.rb +54 -36
  112. data/lib/fastpix_client/utils/forms.rb +97 -101
  113. data/lib/fastpix_client/utils/headers.rb +44 -34
  114. data/lib/fastpix_client/utils/query_params.rb +39 -29
  115. data/lib/fastpix_client/utils/request_bodies.rb +4 -8
  116. data/lib/fastpix_client/utils/security.rb +30 -18
  117. data/lib/fastpix_client/utils/url.rb +83 -55
  118. data/lib/fastpix_client/utils/utils.rb +19 -37
  119. data/lib/fastpix_client/views.rb +71 -95
  120. data/lib/fastpixapi.rb +10 -10
  121. data/lib/openssl_patch.rb +24 -24
  122. metadata +20 -4
@@ -14,6 +14,59 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class ManageVideos
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
+ MEDIA_PATH = '/on-demand/{mediaId}'
23
+ REQUEST_CONTENT_TYPE_HEADER = 'content-type'
24
+ UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
25
+ USER_AGENT_HEADER = 'user-agent'
26
+
27
+ # Applies the SDK after-request hooks and ensures a usable response is present.
28
+ sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
29
+ def apply_after_request_hooks(http_response, error, hook_ctx)
30
+ if http_response.nil? || Utils.error_status?(http_response.status)
31
+ http_response = @sdk_configuration.hooks.after_error(
32
+ error: error,
33
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
34
+ hook_ctx: hook_ctx
35
+ ),
36
+ response: http_response
37
+ )
38
+ else
39
+ http_response = @sdk_configuration.hooks.after_success(
40
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
41
+ hook_ctx: hook_ctx
42
+ ),
43
+ response: http_response
44
+ )
45
+ end
46
+
47
+ if http_response.nil?
48
+ raise error unless error.nil?
49
+ raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
50
+ end
51
+
52
+ http_response
53
+ end
54
+ private :apply_after_request_hooks
55
+
56
+ # Encodes the request body based on its serialized content type.
57
+ sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
58
+ def encode_request_body(req_content_type, data, form)
59
+ raise ArgumentError, 'request body is required' if data.nil? && form.nil?
60
+
61
+ if form
62
+ Utils.encode_form(form)
63
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
64
+ URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
65
+ else
66
+ data
67
+ end
68
+ end
69
+ private :encode_request_body
17
70
 
18
71
  # Operations for managing video media
19
72
 
@@ -65,8 +118,8 @@ module FastpixClient
65
118
  headers = {}
66
119
  headers = T.cast(headers, T::Hash[String, String])
67
120
  query_params = Utils.get_query_params(Models::Operations::ListMediaRequest, request, nil)
68
- headers['Accept'] = 'application/json'
69
- headers['user-agent'] = @sdk_configuration.user_agent
121
+ headers['Accept'] = CONTENT_TYPE_JSON
122
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
70
123
 
71
124
  security = @sdk_configuration.security_source&.call
72
125
 
@@ -105,32 +158,12 @@ module FastpixClient
105
158
  rescue StandardError => e
106
159
  error = e
107
160
  ensure
108
- if http_response.nil? || Utils.error_status?(http_response.status)
109
- http_response = @sdk_configuration.hooks.after_error(
110
- error: error,
111
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
112
- hook_ctx: hook_ctx
113
- ),
114
- response: http_response
115
- )
116
- else
117
- http_response = @sdk_configuration.hooks.after_success(
118
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
119
- hook_ctx: hook_ctx
120
- ),
121
- response: http_response
122
- )
123
- end
124
-
125
- if http_response.nil?
126
- raise error if !error.nil?
127
- raise 'no response'
128
- end
161
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
129
162
  end
130
163
 
131
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
164
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
132
165
  if Utils.match_status_code(http_response.status, ['200'])
133
- if Utils.match_content_type(content_type, 'application/json')
166
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
134
167
  http_response = @sdk_configuration.hooks.after_success(
135
168
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
136
169
  hook_ctx: hook_ctx
@@ -148,14 +181,14 @@ module FastpixClient
148
181
 
149
182
  return response
150
183
  else
151
- 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'
184
+ 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
152
185
  end
153
186
  elsif Utils.match_status_code(http_response.status, ['4XX'])
154
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
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
155
188
  elsif Utils.match_status_code(http_response.status, ['5XX'])
156
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
189
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
157
190
  else
158
- if Utils.match_content_type(content_type, 'application/json')
191
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
159
192
  http_response = @sdk_configuration.hooks.after_success(
160
193
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
161
194
  hook_ctx: hook_ctx
@@ -173,7 +206,7 @@ module FastpixClient
173
206
 
174
207
  return response
175
208
  else
176
- 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'
209
+ 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
177
210
  end
178
211
  end
179
212
  end
@@ -194,7 +227,7 @@ module FastpixClient
194
227
  # Suppose you’re hosting a live gaming event and want to showcase key moments from the stream — such as top plays or final match highlights. You can use this endpoint to fetch all clips generated from that livestream, display them in your dashboard, or use them for post-event editing and sharing.
195
228
  #
196
229
  #
197
- # Related guide: <a href="https://docs.fastpix.io/docs/instant-live-clipping">Instant live clipping</a>
230
+ # Related guide: <a href="https://fastpix.com/docs/edit-and-transform-live-stream/clip-moments-from-a-live-stream">Instant live clipping</a>
198
231
  #
199
232
  request = Models::Operations::ListLiveClipsRequest.new(
200
233
  livestream_id: livestream_id,
@@ -213,8 +246,8 @@ module FastpixClient
213
246
  headers = {}
214
247
  headers = T.cast(headers, T::Hash[String, String])
215
248
  query_params = Utils.get_query_params(Models::Operations::ListLiveClipsRequest, request, nil)
216
- headers['Accept'] = 'application/json'
217
- headers['user-agent'] = @sdk_configuration.user_agent
249
+ headers['Accept'] = CONTENT_TYPE_JSON
250
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
218
251
 
219
252
  security = @sdk_configuration.security_source&.call
220
253
 
@@ -253,32 +286,12 @@ module FastpixClient
253
286
  rescue StandardError => e
254
287
  error = e
255
288
  ensure
256
- if http_response.nil? || Utils.error_status?(http_response.status)
257
- http_response = @sdk_configuration.hooks.after_error(
258
- error: error,
259
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
260
- hook_ctx: hook_ctx
261
- ),
262
- response: http_response
263
- )
264
- else
265
- http_response = @sdk_configuration.hooks.after_success(
266
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
267
- hook_ctx: hook_ctx
268
- ),
269
- response: http_response
270
- )
271
- end
272
-
273
- if http_response.nil?
274
- raise error if !error.nil?
275
- raise 'no response'
276
- end
289
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
277
290
  end
278
291
 
279
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
292
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
280
293
  if Utils.match_status_code(http_response.status, ['200'])
281
- if Utils.match_content_type(content_type, 'application/json')
294
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
282
295
  http_response = @sdk_configuration.hooks.after_success(
283
296
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
284
297
  hook_ctx: hook_ctx
@@ -296,14 +309,14 @@ module FastpixClient
296
309
 
297
310
  return response
298
311
  else
299
- 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'
312
+ 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
300
313
  end
301
314
  elsif Utils.match_status_code(http_response.status, ['4XX'])
302
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
315
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
303
316
  elsif Utils.match_status_code(http_response.status, ['5XX'])
304
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
317
+ 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
318
  else
306
- if Utils.match_content_type(content_type, 'application/json')
319
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
307
320
  http_response = @sdk_configuration.hooks.after_success(
308
321
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
309
322
  hook_ctx: hook_ctx
@@ -321,7 +334,7 @@ module FastpixClient
321
334
 
322
335
  return response
323
336
  else
324
- 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'
337
+ 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
325
338
  end
326
339
  end
327
340
  end
@@ -342,7 +355,7 @@ module FastpixClient
342
355
  # - **status** – Indicates whether the media is still *Processing* or has transitioned to *Ready*.
343
356
  # - **playbackId** – A unique identifier that allows you to stream the media once it is *Ready*.
344
357
  # You can construct the stream URL as follows:
345
- # `https://stream.fastpix.io/<playbackId>.m3u8`
358
+ # `https://stream.fastpix.com/<playbackId>.m3u8`
346
359
  #
347
360
  # #### Example
348
361
  #
@@ -356,13 +369,13 @@ module FastpixClient
356
369
  url = Utils.generate_url(
357
370
  Models::Operations::GetMediaRequest,
358
371
  base_url,
359
- '/on-demand/{mediaId}',
372
+ MEDIA_PATH,
360
373
  request
361
374
  )
362
375
  headers = {}
363
376
  headers = T.cast(headers, T::Hash[String, String])
364
- headers['Accept'] = 'application/json'
365
- headers['user-agent'] = @sdk_configuration.user_agent
377
+ headers['Accept'] = CONTENT_TYPE_JSON
378
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
366
379
 
367
380
  security = @sdk_configuration.security_source&.call
368
381
 
@@ -400,32 +413,12 @@ module FastpixClient
400
413
  rescue StandardError => e
401
414
  error = e
402
415
  ensure
403
- if http_response.nil? || Utils.error_status?(http_response.status)
404
- http_response = @sdk_configuration.hooks.after_error(
405
- error: error,
406
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
407
- hook_ctx: hook_ctx
408
- ),
409
- response: http_response
410
- )
411
- else
412
- http_response = @sdk_configuration.hooks.after_success(
413
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
414
- hook_ctx: hook_ctx
415
- ),
416
- response: http_response
417
- )
418
- end
419
-
420
- if http_response.nil?
421
- raise error if !error.nil?
422
- raise 'no response'
423
- end
416
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
424
417
  end
425
418
 
426
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
419
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
427
420
  if Utils.match_status_code(http_response.status, ['200'])
428
- if Utils.match_content_type(content_type, 'application/json')
421
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
429
422
  http_response = @sdk_configuration.hooks.after_success(
430
423
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
431
424
  hook_ctx: hook_ctx
@@ -443,14 +436,14 @@ module FastpixClient
443
436
 
444
437
  return response
445
438
  else
446
- 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'
439
+ 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
447
440
  end
448
441
  elsif Utils.match_status_code(http_response.status, ['4XX'])
449
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
442
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
450
443
  elsif Utils.match_status_code(http_response.status, ['5XX'])
451
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
444
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
452
445
  else
453
- if Utils.match_content_type(content_type, 'application/json')
446
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
454
447
  http_response = @sdk_configuration.hooks.after_success(
455
448
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
456
449
  hook_ctx: hook_ctx
@@ -468,7 +461,7 @@ module FastpixClient
468
461
 
469
462
  return response
470
463
  else
471
- 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'
464
+ 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
472
465
  end
473
466
  end
474
467
  end
@@ -488,7 +481,7 @@ module FastpixClient
488
481
  #
489
482
  # 3. The response returns the updated media data, confirming the changes.
490
483
  #
491
- # 4. Monitor the <a href="https://docs.fastpix.io/docs/media-events#videomediaupdated">video.media.updated</a> webhook event to track the update status in your system.
484
+ # 4. Monitor the <a href="https://fastpix.com/docs/vod-events/media-events#videomediaupdated">video.media.updated</a> webhook event to track the update status in your system.
492
485
  #
493
486
  # #### Example
494
487
  # If a user uploads a video and later needs to change the title, add a new description, or update tags, you can use this endpoint to update the media metadata without re-uploading the entire video.
@@ -502,24 +495,16 @@ module FastpixClient
502
495
  url = Utils.generate_url(
503
496
  Models::Operations::UpdatedMediaRequest,
504
497
  base_url,
505
- '/on-demand/{mediaId}',
498
+ MEDIA_PATH,
506
499
  request
507
500
  )
508
501
  headers = {}
509
502
  headers = T.cast(headers, T::Hash[String, String])
510
503
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
511
- headers['content-type'] = req_content_type
512
- raise StandardError, 'request body is required' if data.nil? && form.nil?
513
-
514
- if form
515
- body = Utils.encode_form(form)
516
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
517
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
518
- else
519
- body = data
520
- end
521
- headers['Accept'] = 'application/json'
522
- headers['user-agent'] = @sdk_configuration.user_agent
504
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
505
+ body = encode_request_body(req_content_type, data, form)
506
+ headers['Accept'] = CONTENT_TYPE_JSON
507
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
523
508
 
524
509
  security = @sdk_configuration.security_source&.call
525
510
 
@@ -558,32 +543,12 @@ module FastpixClient
558
543
  rescue StandardError => e
559
544
  error = e
560
545
  ensure
561
- if http_response.nil? || Utils.error_status?(http_response.status)
562
- http_response = @sdk_configuration.hooks.after_error(
563
- error: error,
564
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
565
- hook_ctx: hook_ctx
566
- ),
567
- response: http_response
568
- )
569
- else
570
- http_response = @sdk_configuration.hooks.after_success(
571
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
572
- hook_ctx: hook_ctx
573
- ),
574
- response: http_response
575
- )
576
- end
577
-
578
- if http_response.nil?
579
- raise error if !error.nil?
580
- raise 'no response'
581
- end
546
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
582
547
  end
583
548
 
584
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
549
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
585
550
  if Utils.match_status_code(http_response.status, ['200'])
586
- if Utils.match_content_type(content_type, 'application/json')
551
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
587
552
  http_response = @sdk_configuration.hooks.after_success(
588
553
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
589
554
  hook_ctx: hook_ctx
@@ -601,14 +566,14 @@ module FastpixClient
601
566
 
602
567
  return response
603
568
  else
604
- 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'
569
+ 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
605
570
  end
606
571
  elsif Utils.match_status_code(http_response.status, ['4XX'])
607
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
572
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
608
573
  elsif Utils.match_status_code(http_response.status, ['5XX'])
609
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
574
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
610
575
  else
611
- if Utils.match_content_type(content_type, 'application/json')
576
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
612
577
  http_response = @sdk_configuration.hooks.after_success(
613
578
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
614
579
  hook_ctx: hook_ctx
@@ -626,7 +591,7 @@ module FastpixClient
626
591
 
627
592
  return response
628
593
  else
629
- 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'
594
+ 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
630
595
  end
631
596
  end
632
597
  end
@@ -645,7 +610,7 @@ module FastpixClient
645
610
  #
646
611
  # 2. This action is irreversible. Make sure you no longer need the media before proceeding. Once deleted, the media can’t be retrieved or played back.
647
612
  #
648
- # 3. Monitor the following webhook event: <a href="https://docs.fastpix.io/docs/media-events#videomediadeleted">video.media.deleted</a>
613
+ # 3. Monitor the following webhook event: <a href="https://fastpix.com/docs/vod-events/media-events#videomediadeleted">video.media.deleted</a>
649
614
  #
650
615
  # #### Example
651
616
  # A user on a video-sharing platform decides to remove an old video from their profile, or suppose you're running a content moderation system, and one of the videos uploaded by a user violates your platform's policies. Using this endpoint, the media is permanently deleted from your library, ensuring it's no longer accessible or viewable by other users.
@@ -658,13 +623,13 @@ module FastpixClient
658
623
  url = Utils.generate_url(
659
624
  Models::Operations::DeleteMediaRequest,
660
625
  base_url,
661
- '/on-demand/{mediaId}',
626
+ MEDIA_PATH,
662
627
  request
663
628
  )
664
629
  headers = {}
665
630
  headers = T.cast(headers, T::Hash[String, String])
666
- headers['Accept'] = 'application/json'
667
- headers['user-agent'] = @sdk_configuration.user_agent
631
+ headers['Accept'] = CONTENT_TYPE_JSON
632
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
668
633
 
669
634
  security = @sdk_configuration.security_source&.call
670
635
 
@@ -702,32 +667,12 @@ module FastpixClient
702
667
  rescue StandardError => e
703
668
  error = e
704
669
  ensure
705
- if http_response.nil? || Utils.error_status?(http_response.status)
706
- http_response = @sdk_configuration.hooks.after_error(
707
- error: error,
708
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
709
- hook_ctx: hook_ctx
710
- ),
711
- response: http_response
712
- )
713
- else
714
- http_response = @sdk_configuration.hooks.after_success(
715
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
716
- hook_ctx: hook_ctx
717
- ),
718
- response: http_response
719
- )
720
- end
721
-
722
- if http_response.nil?
723
- raise error if !error.nil?
724
- raise 'no response'
725
- end
670
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
726
671
  end
727
672
 
728
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
673
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
729
674
  if Utils.match_status_code(http_response.status, ['200'])
730
- if Utils.match_content_type(content_type, 'application/json')
675
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
731
676
  http_response = @sdk_configuration.hooks.after_success(
732
677
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
733
678
  hook_ctx: hook_ctx
@@ -745,14 +690,14 @@ module FastpixClient
745
690
 
746
691
  return response
747
692
  else
748
- 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'
693
+ 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
749
694
  end
750
695
  elsif Utils.match_status_code(http_response.status, ['4XX'])
751
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
696
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
752
697
  elsif Utils.match_status_code(http_response.status, ['5XX'])
753
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
698
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
754
699
  else
755
- if Utils.match_content_type(content_type, 'application/json')
700
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
756
701
  http_response = @sdk_configuration.hooks.after_success(
757
702
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
758
703
  hook_ctx: hook_ctx
@@ -770,7 +715,7 @@ module FastpixClient
770
715
 
771
716
  return response
772
717
  else
773
- 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'
718
+ 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
774
719
  end
775
720
  end
776
721
  end
@@ -793,17 +738,17 @@ module FastpixClient
793
738
  #
794
739
  # #### Webhook events
795
740
  #
796
- # 1. After successfully adding a track, your system must receive the webhook event <a href="https://docs.fastpix.io/docs/transform-media-events#videomediatrackcreated">video.media.track.created</a>.
741
+ # 1. After successfully adding a track, your system must receive the webhook event <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediatrackcreated">video.media.track.created</a>.
797
742
  #
798
- # 2. Once the track is processed and ready, you must receive the webhook event <a href="https://docs.fastpix.io/docs/transform-media-events#videomediatrackready">video.media.track.ready</a>.
743
+ # 2. Once the track is processed and ready, you must receive the webhook event <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediatrackready">video.media.track.ready</a>.
799
744
  #
800
- # 3. Finally, an update event <a href="https://docs.fastpix.io/docs/media-events#videomediaupdated">video.media.updated</a> must notify your system about the media's updated status.
745
+ # 3. Finally, an update event <a href="https://fastpix.com/docs/vod-events/media-events#videomediaupdated">video.media.updated</a> must notify your system about the media's updated status.
801
746
  #
802
747
  #
803
748
  # #### Example
804
- # Suppose you have a video uploaded to the FastPix platform, and you want to add an Italian audio track to it. By calling this API, you can attach an external audio file (https://static.fastpix.io/music-1.mp3) to the media file. Similarly, if you need to add subtitles in different languages, you can specify type: `subtitle` with the corresponding subtitle `url`, `languageCode` and `languageName`.
749
+ # Suppose you have a video uploaded to the FastPix platform, and you want to add an Italian audio track to it. By calling this API, you can attach an external audio file (https://static.fastpix.com/music-1.mp3) to the media file. Similarly, if you need to add subtitles in different languages, you can specify type: `subtitle` with the corresponding subtitle `url`, `languageCode` and `languageName`.
805
750
  #
806
- # Related guides: <a href="https://docs.fastpix.io/docs/manage-subtitle-tracks">Add own subtitle tracks</a>, <a href="https://docs.fastpix.io/docs/manage-audio-tracks">Add own audio tracks</a>
751
+ # Related guides: <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/add-subtitles-to-a-video">Add own subtitle tracks</a>, <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/add-audio-to-a-video">Add own audio tracks</a>
807
752
  #
808
753
  request = Models::Operations::AddMediaTrackRequest.new(
809
754
  media_id: media_id,
@@ -820,18 +765,10 @@ module FastpixClient
820
765
  headers = {}
821
766
  headers = T.cast(headers, T::Hash[String, String])
822
767
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
823
- headers['content-type'] = req_content_type
824
- raise StandardError, 'request body is required' if data.nil? && form.nil?
825
-
826
- if form
827
- body = Utils.encode_form(form)
828
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
829
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
830
- else
831
- body = data
832
- end
833
- headers['Accept'] = 'application/json'
834
- headers['user-agent'] = @sdk_configuration.user_agent
768
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
769
+ body = encode_request_body(req_content_type, data, form)
770
+ headers['Accept'] = CONTENT_TYPE_JSON
771
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
835
772
 
836
773
  security = @sdk_configuration.security_source&.call
837
774
 
@@ -870,32 +807,12 @@ module FastpixClient
870
807
  rescue StandardError => e
871
808
  error = e
872
809
  ensure
873
- if http_response.nil? || Utils.error_status?(http_response.status)
874
- http_response = @sdk_configuration.hooks.after_error(
875
- error: error,
876
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
877
- hook_ctx: hook_ctx
878
- ),
879
- response: http_response
880
- )
881
- else
882
- http_response = @sdk_configuration.hooks.after_success(
883
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
884
- hook_ctx: hook_ctx
885
- ),
886
- response: http_response
887
- )
888
- end
889
-
890
- if http_response.nil?
891
- raise error if !error.nil?
892
- raise 'no response'
893
- end
810
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
894
811
  end
895
812
 
896
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
813
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
897
814
  if Utils.match_status_code(http_response.status, ['201'])
898
- if Utils.match_content_type(content_type, 'application/json')
815
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
899
816
  http_response = @sdk_configuration.hooks.after_success(
900
817
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
901
818
  hook_ctx: hook_ctx
@@ -913,14 +830,14 @@ module FastpixClient
913
830
 
914
831
  return response
915
832
  else
916
- 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'
833
+ 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
917
834
  end
918
835
  elsif Utils.match_status_code(http_response.status, ['4XX'])
919
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
836
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
920
837
  elsif Utils.match_status_code(http_response.status, ['5XX'])
921
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
838
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
922
839
  else
923
- if Utils.match_content_type(content_type, 'application/json')
840
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
924
841
  http_response = @sdk_configuration.hooks.after_success(
925
842
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
926
843
  hook_ctx: hook_ctx
@@ -938,7 +855,7 @@ module FastpixClient
938
855
 
939
856
  return response
940
857
  else
941
- 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'
858
+ 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
942
859
  end
943
860
  end
944
861
  end
@@ -956,7 +873,7 @@ module FastpixClient
956
873
  #
957
874
  # #### Webhook Events
958
875
  #
959
- # Once the upload is cancelled, you must receive the webhook event <a href="https://docs.fastpix.io/docs/media-events#videomediauploadcancelled">video.media.upload.cancelled</a>.
876
+ # Once the upload is cancelled, you must receive the webhook event <a href="https://fastpix.com/docs/vod-events/media-events#videomediauploadcancelled">video.media.upload.cancelled</a>.
960
877
  #
961
878
  # #### Example
962
879
  #
@@ -975,8 +892,8 @@ module FastpixClient
975
892
  )
976
893
  headers = {}
977
894
  headers = T.cast(headers, T::Hash[String, String])
978
- headers['Accept'] = 'application/json'
979
- headers['user-agent'] = @sdk_configuration.user_agent
895
+ headers['Accept'] = CONTENT_TYPE_JSON
896
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
980
897
 
981
898
  security = @sdk_configuration.security_source&.call
982
899
 
@@ -1014,32 +931,12 @@ module FastpixClient
1014
931
  rescue StandardError => e
1015
932
  error = e
1016
933
  ensure
1017
- if http_response.nil? || Utils.error_status?(http_response.status)
1018
- http_response = @sdk_configuration.hooks.after_error(
1019
- error: error,
1020
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1021
- hook_ctx: hook_ctx
1022
- ),
1023
- response: http_response
1024
- )
1025
- else
1026
- http_response = @sdk_configuration.hooks.after_success(
1027
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1028
- hook_ctx: hook_ctx
1029
- ),
1030
- response: http_response
1031
- )
1032
- end
1033
-
1034
- if http_response.nil?
1035
- raise error if !error.nil?
1036
- raise 'no response'
1037
- end
934
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1038
935
  end
1039
936
 
1040
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
937
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1041
938
  if Utils.match_status_code(http_response.status, ['200'])
1042
- if Utils.match_content_type(content_type, 'application/json')
939
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1043
940
  http_response = @sdk_configuration.hooks.after_success(
1044
941
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1045
942
  hook_ctx: hook_ctx
@@ -1057,14 +954,14 @@ module FastpixClient
1057
954
 
1058
955
  return response
1059
956
  else
1060
- 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'
957
+ 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
1061
958
  end
1062
959
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1063
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
960
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1064
961
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1065
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
962
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1066
963
  else
1067
- if Utils.match_content_type(content_type, 'application/json')
964
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1068
965
  http_response = @sdk_configuration.hooks.after_success(
1069
966
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1070
967
  hook_ctx: hook_ctx
@@ -1082,7 +979,7 @@ module FastpixClient
1082
979
 
1083
980
  return response
1084
981
  else
1085
- 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'
982
+ 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
1086
983
  end
1087
984
  end
1088
985
  end
@@ -1106,11 +1003,11 @@ module FastpixClient
1106
1003
  #
1107
1004
  # After updating a track, your system must receive webhook notifications:
1108
1005
  #
1109
- # 1. After successfully updating a track, your system must receive the webhook event <a href="https://docs.fastpix.io/docs/transform-media-events#videomediatrackupdated">video.media.track.updated</a>.
1006
+ # 1. After successfully updating a track, your system must receive the webhook event <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediatrackupdated">video.media.track.updated</a>.
1110
1007
  #
1111
- # 2. Once the new track is processed and ready, you must receive the webhook event <a href="https://docs.fastpix.io/docs/transform-media-events#videomediatrackready">video.media.track.ready</a>.
1008
+ # 2. Once the new track is processed and ready, you must receive the webhook event <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediatrackready">video.media.track.ready</a>.
1112
1009
  #
1113
- # 3. Once the media file is updated with the new track details, a <a href="https://docs.fastpix.io/docs/media-events#videomediaupdated">video.media.updated</a> event must be triggered.
1010
+ # 3. Once the media file is updated with the new track details, a <a href="https://fastpix.com/docs/vod-events/media-events#videomediaupdated">video.media.updated</a> event must be triggered.
1114
1011
  #
1115
1012
  #
1116
1013
  # #### Example
@@ -1119,7 +1016,7 @@ module FastpixClient
1119
1016
  # - The original track file has errors and needs correction.
1120
1017
  # - You want to improve subtitle translations or replace an audio track with a better-quality version.
1121
1018
  #
1122
- # Related guides: <a href="https://docs.fastpix.io/docs/manage-subtitle-tracks">Add own subtitle tracks</a>, <a href="https://docs.fastpix.io/docs/manage-audio-tracks">Add own audio tracks</a>
1019
+ # Related guides: <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/add-subtitles-to-a-video">Add own subtitle tracks</a>, <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/add-audio-to-a-video">Add own audio tracks</a>
1123
1020
  #
1124
1021
  request = Models::Operations::UpdateMediaTrackRequest.new(
1125
1022
  track_id: track_id,
@@ -1137,18 +1034,10 @@ module FastpixClient
1137
1034
  headers = {}
1138
1035
  headers = T.cast(headers, T::Hash[String, String])
1139
1036
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
1140
- headers['content-type'] = req_content_type
1141
- raise StandardError, 'request body is required' if data.nil? && form.nil?
1142
-
1143
- if form
1144
- body = Utils.encode_form(form)
1145
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
1146
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1147
- else
1148
- body = data
1149
- end
1150
- headers['Accept'] = 'application/json'
1151
- headers['user-agent'] = @sdk_configuration.user_agent
1037
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
1038
+ body = encode_request_body(req_content_type, data, form)
1039
+ headers['Accept'] = CONTENT_TYPE_JSON
1040
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1152
1041
 
1153
1042
  security = @sdk_configuration.security_source&.call
1154
1043
 
@@ -1187,32 +1076,12 @@ module FastpixClient
1187
1076
  rescue StandardError => e
1188
1077
  error = e
1189
1078
  ensure
1190
- if http_response.nil? || Utils.error_status?(http_response.status)
1191
- http_response = @sdk_configuration.hooks.after_error(
1192
- error: error,
1193
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1194
- hook_ctx: hook_ctx
1195
- ),
1196
- response: http_response
1197
- )
1198
- else
1199
- http_response = @sdk_configuration.hooks.after_success(
1200
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1201
- hook_ctx: hook_ctx
1202
- ),
1203
- response: http_response
1204
- )
1205
- end
1206
-
1207
- if http_response.nil?
1208
- raise error if !error.nil?
1209
- raise 'no response'
1210
- end
1079
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1211
1080
  end
1212
1081
 
1213
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1082
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1214
1083
  if Utils.match_status_code(http_response.status, ['200'])
1215
- if Utils.match_content_type(content_type, 'application/json')
1084
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1216
1085
  http_response = @sdk_configuration.hooks.after_success(
1217
1086
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1218
1087
  hook_ctx: hook_ctx
@@ -1230,14 +1099,14 @@ module FastpixClient
1230
1099
 
1231
1100
  return response
1232
1101
  else
1233
- 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'
1102
+ 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
1234
1103
  end
1235
1104
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1236
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1105
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1237
1106
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1238
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1107
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1239
1108
  else
1240
- if Utils.match_content_type(content_type, 'application/json')
1109
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1241
1110
  http_response = @sdk_configuration.hooks.after_success(
1242
1111
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1243
1112
  hook_ctx: hook_ctx
@@ -1255,7 +1124,7 @@ module FastpixClient
1255
1124
 
1256
1125
  return response
1257
1126
  else
1258
- 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'
1127
+ 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
1259
1128
  end
1260
1129
  end
1261
1130
  end
@@ -1278,7 +1147,7 @@ module FastpixClient
1278
1147
  #
1279
1148
  # 1. After successfully deleting a track, your system must receive the webhook event **video.media.track.deleted**.
1280
1149
  #
1281
- # 2. Once the media file is updated to reflect the track removal, a <a href="https://docs.fastpix.io/docs/media-events#videomediaupdated">video.media.updated</a> event must be triggered.
1150
+ # 2. Once the media file is updated to reflect the track removal, a <a href="https://fastpix.com/docs/vod-events/media-events#videomediaupdated">video.media.updated</a> event must be triggered.
1282
1151
  #
1283
1152
  #
1284
1153
  # #### Example
@@ -1288,7 +1157,7 @@ module FastpixClient
1288
1157
  # - The content owner requests the removal of a specific subtitle or audio track.
1289
1158
  # - A new version of the track gets uploaded to replace the existing one.
1290
1159
  #
1291
- # Related guides: <a href="https://docs.fastpix.io/docs/manage-subtitle-tracks">Add own subtitle tracks</a>, <a href="https://docs.fastpix.io/docs/manage-audio-tracks">Add own audio tracks</a>
1160
+ # Related guides: <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/add-subtitles-to-a-video">Add own subtitle tracks</a>, <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/add-audio-to-a-video">Add own audio tracks</a>
1292
1161
  #
1293
1162
  request = Models::Operations::DeleteMediaTrackRequest.new(
1294
1163
  media_id: media_id,
@@ -1304,8 +1173,8 @@ module FastpixClient
1304
1173
  )
1305
1174
  headers = {}
1306
1175
  headers = T.cast(headers, T::Hash[String, String])
1307
- headers['Accept'] = 'application/json'
1308
- headers['user-agent'] = @sdk_configuration.user_agent
1176
+ headers['Accept'] = CONTENT_TYPE_JSON
1177
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1309
1178
 
1310
1179
  security = @sdk_configuration.security_source&.call
1311
1180
 
@@ -1343,32 +1212,12 @@ module FastpixClient
1343
1212
  rescue StandardError => e
1344
1213
  error = e
1345
1214
  ensure
1346
- if http_response.nil? || Utils.error_status?(http_response.status)
1347
- http_response = @sdk_configuration.hooks.after_error(
1348
- error: error,
1349
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1350
- hook_ctx: hook_ctx
1351
- ),
1352
- response: http_response
1353
- )
1354
- else
1355
- http_response = @sdk_configuration.hooks.after_success(
1356
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1357
- hook_ctx: hook_ctx
1358
- ),
1359
- response: http_response
1360
- )
1361
- end
1362
-
1363
- if http_response.nil?
1364
- raise error if !error.nil?
1365
- raise 'no response'
1366
- end
1215
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1367
1216
  end
1368
1217
 
1369
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1218
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1370
1219
  if Utils.match_status_code(http_response.status, ['200'])
1371
- if Utils.match_content_type(content_type, 'application/json')
1220
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1372
1221
  http_response = @sdk_configuration.hooks.after_success(
1373
1222
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1374
1223
  hook_ctx: hook_ctx
@@ -1386,14 +1235,14 @@ module FastpixClient
1386
1235
 
1387
1236
  return response
1388
1237
  else
1389
- 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'
1238
+ 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
1390
1239
  end
1391
1240
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1392
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1241
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1393
1242
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1394
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1243
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1395
1244
  else
1396
- if Utils.match_content_type(content_type, 'application/json')
1245
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1397
1246
  http_response = @sdk_configuration.hooks.after_success(
1398
1247
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1399
1248
  hook_ctx: hook_ctx
@@ -1411,7 +1260,7 @@ module FastpixClient
1411
1260
 
1412
1261
  return response
1413
1262
  else
1414
- 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'
1263
+ 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
1415
1264
  end
1416
1265
  end
1417
1266
  end
@@ -1432,11 +1281,11 @@ module FastpixClient
1432
1281
  #
1433
1282
  # #### Webhook Events
1434
1283
  #
1435
- # 1. After the subtitle track is generated and ready, you receive the webhook event <a href="https://docs.fastpix.io/docs/transform-media-events#videomediasubtitlegeneratedready">video.media.subtitle.generated.ready</a>.
1284
+ # 1. After the subtitle track is generated and ready, you receive the webhook event <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediasubtitlegeneratedready">video.media.subtitle.generated.ready</a>.
1436
1285
  #
1437
- # 2. Finally the <a href="https://docs.fastpix.io/docs/media-events#videomediaupdated">video.media.updated</a> event notifies your system about the media’s updated status.
1286
+ # 2. Finally the <a href="https://fastpix.com/docs/vod-events/media-events#videomediaupdated">video.media.updated</a> event notifies your system about the media’s updated status.
1438
1287
  #
1439
- # </br> Related guide: <a href="https://docs.fastpix.io/docs/add-auto-generated-subtitles-to-videos">Add auto-generated subtitles</a>
1288
+ # </br> Related guide: <a href="https://fastpix.com/docs/manage-audio-and-subtitle-tracks/generate-subtitles-automatically">Add auto-generated subtitles</a>
1440
1289
  #
1441
1290
  request = Models::Operations::GenerateSubtitleTrackRequest.new(
1442
1291
  media_id: media_id,
@@ -1454,18 +1303,10 @@ module FastpixClient
1454
1303
  headers = {}
1455
1304
  headers = T.cast(headers, T::Hash[String, String])
1456
1305
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
1457
- headers['content-type'] = req_content_type
1458
- raise StandardError, 'request body is required' if data.nil? && form.nil?
1459
-
1460
- if form
1461
- body = Utils.encode_form(form)
1462
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
1463
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1464
- else
1465
- body = data
1466
- end
1467
- headers['Accept'] = 'application/json'
1468
- headers['user-agent'] = @sdk_configuration.user_agent
1306
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
1307
+ body = encode_request_body(req_content_type, data, form)
1308
+ headers['Accept'] = CONTENT_TYPE_JSON
1309
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1469
1310
 
1470
1311
  security = @sdk_configuration.security_source&.call
1471
1312
 
@@ -1504,32 +1345,12 @@ module FastpixClient
1504
1345
  rescue StandardError => e
1505
1346
  error = e
1506
1347
  ensure
1507
- if http_response.nil? || Utils.error_status?(http_response.status)
1508
- http_response = @sdk_configuration.hooks.after_error(
1509
- error: error,
1510
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1511
- hook_ctx: hook_ctx
1512
- ),
1513
- response: http_response
1514
- )
1515
- else
1516
- http_response = @sdk_configuration.hooks.after_success(
1517
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1518
- hook_ctx: hook_ctx
1519
- ),
1520
- response: http_response
1521
- )
1522
- end
1523
-
1524
- if http_response.nil?
1525
- raise error if !error.nil?
1526
- raise 'no response'
1527
- end
1348
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1528
1349
  end
1529
1350
 
1530
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1351
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1531
1352
  if Utils.match_status_code(http_response.status, ['200'])
1532
- if Utils.match_content_type(content_type, 'application/json')
1353
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1533
1354
  http_response = @sdk_configuration.hooks.after_success(
1534
1355
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1535
1356
  hook_ctx: hook_ctx
@@ -1547,14 +1368,14 @@ module FastpixClient
1547
1368
 
1548
1369
  return response
1549
1370
  else
1550
- 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'
1371
+ 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
1551
1372
  end
1552
1373
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1553
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1374
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1554
1375
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1555
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1376
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1556
1377
  else
1557
- if Utils.match_content_type(content_type, 'application/json')
1378
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1558
1379
  http_response = @sdk_configuration.hooks.after_success(
1559
1380
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1560
1381
  hook_ctx: hook_ctx
@@ -1572,7 +1393,7 @@ module FastpixClient
1572
1393
 
1573
1394
  return response
1574
1395
  else
1575
- 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'
1396
+ 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
1576
1397
  end
1577
1398
  end
1578
1399
  end
@@ -1607,8 +1428,8 @@ module FastpixClient
1607
1428
  )
1608
1429
  headers = {}
1609
1430
  headers = T.cast(headers, T::Hash[String, String])
1610
- headers['Accept'] = 'application/json'
1611
- headers['user-agent'] = @sdk_configuration.user_agent
1431
+ headers['Accept'] = CONTENT_TYPE_JSON
1432
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1612
1433
 
1613
1434
  security = @sdk_configuration.security_source&.call
1614
1435
 
@@ -1646,32 +1467,12 @@ module FastpixClient
1646
1467
  rescue StandardError => e
1647
1468
  error = e
1648
1469
  ensure
1649
- if http_response.nil? || Utils.error_status?(http_response.status)
1650
- http_response = @sdk_configuration.hooks.after_error(
1651
- error: error,
1652
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1653
- hook_ctx: hook_ctx
1654
- ),
1655
- response: http_response
1656
- )
1657
- else
1658
- http_response = @sdk_configuration.hooks.after_success(
1659
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1660
- hook_ctx: hook_ctx
1661
- ),
1662
- response: http_response
1663
- )
1664
- end
1665
-
1666
- if http_response.nil?
1667
- raise error if !error.nil?
1668
- raise 'no response'
1669
- end
1470
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1670
1471
  end
1671
1472
 
1672
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1473
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1673
1474
  if Utils.match_status_code(http_response.status, ['200'])
1674
- if Utils.match_content_type(content_type, 'application/json')
1475
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1675
1476
  http_response = @sdk_configuration.hooks.after_success(
1676
1477
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1677
1478
  hook_ctx: hook_ctx
@@ -1689,14 +1490,14 @@ module FastpixClient
1689
1490
 
1690
1491
  return response
1691
1492
  else
1692
- 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'
1493
+ 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
1693
1494
  end
1694
1495
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1695
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1496
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1696
1497
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1697
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1498
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1698
1499
  else
1699
- if Utils.match_content_type(content_type, 'application/json')
1500
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1700
1501
  http_response = @sdk_configuration.hooks.after_success(
1701
1502
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1702
1503
  hook_ctx: hook_ctx
@@ -1714,7 +1515,7 @@ module FastpixClient
1714
1515
 
1715
1516
  return response
1716
1517
  else
1717
- 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'
1518
+ 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
1718
1519
  end
1719
1520
  end
1720
1521
  end
@@ -1732,7 +1533,7 @@ module FastpixClient
1732
1533
  # 2. Include the updated `sourceAccess` parameter in the request body.
1733
1534
  #
1734
1535
  # 3. You receive a response confirming the update to the media’s source access status.
1735
- # 4. Webhook events: <a href="https://docs.fastpix.io/docs/transform-media-events#videomediasourceready">video.media.source.ready</a>, <a href="https://docs.fastpix.io/docs/transform-media-events#videomediasourcedeleted">video.media.source.deleted</a>
1536
+ # 4. Webhook events: <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediasourceready">video.media.source.ready</a>, <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediasourcedeleted">video.media.source.deleted</a>
1736
1537
  #
1737
1538
  request = Models::Operations::UpdatedSourceAccessRequest.new(
1738
1539
  media_id: media_id,
@@ -1749,18 +1550,10 @@ module FastpixClient
1749
1550
  headers = {}
1750
1551
  headers = T.cast(headers, T::Hash[String, String])
1751
1552
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
1752
- headers['content-type'] = req_content_type
1753
- raise StandardError, 'request body is required' if data.nil? && form.nil?
1754
-
1755
- if form
1756
- body = Utils.encode_form(form)
1757
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
1758
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1759
- else
1760
- body = data
1761
- end
1762
- headers['Accept'] = 'application/json'
1763
- headers['user-agent'] = @sdk_configuration.user_agent
1553
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
1554
+ body = encode_request_body(req_content_type, data, form)
1555
+ headers['Accept'] = CONTENT_TYPE_JSON
1556
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1764
1557
 
1765
1558
  security = @sdk_configuration.security_source&.call
1766
1559
 
@@ -1799,32 +1592,12 @@ module FastpixClient
1799
1592
  rescue StandardError => e
1800
1593
  error = e
1801
1594
  ensure
1802
- if http_response.nil? || Utils.error_status?(http_response.status)
1803
- http_response = @sdk_configuration.hooks.after_error(
1804
- error: error,
1805
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1806
- hook_ctx: hook_ctx
1807
- ),
1808
- response: http_response
1809
- )
1810
- else
1811
- http_response = @sdk_configuration.hooks.after_success(
1812
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1813
- hook_ctx: hook_ctx
1814
- ),
1815
- response: http_response
1816
- )
1817
- end
1818
-
1819
- if http_response.nil?
1820
- raise error if !error.nil?
1821
- raise 'no response'
1822
- end
1595
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1823
1596
  end
1824
1597
 
1825
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1598
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1826
1599
  if Utils.match_status_code(http_response.status, ['200'])
1827
- if Utils.match_content_type(content_type, 'application/json')
1600
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1828
1601
  http_response = @sdk_configuration.hooks.after_success(
1829
1602
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1830
1603
  hook_ctx: hook_ctx
@@ -1842,14 +1615,14 @@ module FastpixClient
1842
1615
 
1843
1616
  return response
1844
1617
  else
1845
- 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'
1618
+ 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
1846
1619
  end
1847
1620
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1848
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1621
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1849
1622
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1850
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1623
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1851
1624
  else
1852
- if Utils.match_content_type(content_type, 'application/json')
1625
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1853
1626
  http_response = @sdk_configuration.hooks.after_success(
1854
1627
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1855
1628
  hook_ctx: hook_ctx
@@ -1867,7 +1640,7 @@ module FastpixClient
1867
1640
 
1868
1641
  return response
1869
1642
  else
1870
- 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'
1643
+ 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
1871
1644
  end
1872
1645
  end
1873
1646
  end
@@ -1898,13 +1671,13 @@ module FastpixClient
1898
1671
  #
1899
1672
  # #### Webhook events
1900
1673
  #
1901
- # - <a href="https://docs.fastpix.io/docs/transform-media-events#videomediamp4supportready">video.media.mp4Support.ready</a> – Triggered when the MP4 support setting is successfully updated.
1674
+ # - <a href="https://fastpix.com/docs/vod-events/transform-media-events#videomediamp4supportready">video.media.mp4Support.ready</a> – Triggered when the MP4 support setting is successfully updated.
1902
1675
  #
1903
1676
  # #### Example
1904
- # Suppose you have a video uploaded to the FastPix platform, and you want to allow users to download the video in MP4 format. By setting "mp4Support": "capped_4k", the system generates an MP4 rendition of the video up to 4K resolution, making it available for download through the stream URL(`https://stream.fastpix.io/{playbackId}/{capped-4k.mp4 | audio.m4a}`). If you want users to stream only the audio from the media file, you can set "mp4Support": "audioOnly". This provides an audio-only stream URL that allows users to listen to the media without video. By setting "mp4Support": "audioOnly,capped_4k", both options are enabled. Users can download the MP4 video and also stream just the audio version of the media.
1677
+ # Suppose you have a video uploaded to the FastPix platform, and you want to allow users to download the video in MP4 format. By setting "mp4Support": "capped_4k", the system generates an MP4 rendition of the video up to 4K resolution, making it available for download through the stream URL(`https://stream.fastpix.com/{playbackId}/{capped-4k.mp4 | audio.m4a}`). If you want users to stream only the audio from the media file, you can set "mp4Support": "audioOnly". This provides an audio-only stream URL that allows users to listen to the media without video. By setting "mp4Support": "audioOnly,capped_4k", both options are enabled. Users can download the MP4 video and also stream just the audio version of the media.
1905
1678
  #
1906
1679
  #
1907
- # Related guide: <a href="https://docs.fastpix.io/docs/mp4-support-for-offline-viewing">Use MP4 support for offline viewing</a>
1680
+ # Related guide: <a href="https://fastpix.com/docs/playback-and-delivery/enable-mp4-support-for-offline-viewing">Use MP4 support for offline viewing</a>
1908
1681
  #
1909
1682
  request = Models::Operations::UpdatedMp4SupportRequest.new(
1910
1683
  media_id: media_id,
@@ -1921,18 +1694,10 @@ module FastpixClient
1921
1694
  headers = {}
1922
1695
  headers = T.cast(headers, T::Hash[String, String])
1923
1696
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
1924
- headers['content-type'] = req_content_type
1925
- raise StandardError, 'request body is required' if data.nil? && form.nil?
1926
-
1927
- if form
1928
- body = Utils.encode_form(form)
1929
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
1930
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1931
- else
1932
- body = data
1933
- end
1934
- headers['Accept'] = 'application/json'
1935
- headers['user-agent'] = @sdk_configuration.user_agent
1697
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
1698
+ body = encode_request_body(req_content_type, data, form)
1699
+ headers['Accept'] = CONTENT_TYPE_JSON
1700
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1936
1701
 
1937
1702
  security = @sdk_configuration.security_source&.call
1938
1703
 
@@ -1971,32 +1736,12 @@ module FastpixClient
1971
1736
  rescue StandardError => e
1972
1737
  error = e
1973
1738
  ensure
1974
- if http_response.nil? || Utils.error_status?(http_response.status)
1975
- http_response = @sdk_configuration.hooks.after_error(
1976
- error: error,
1977
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1978
- hook_ctx: hook_ctx
1979
- ),
1980
- response: http_response
1981
- )
1982
- else
1983
- http_response = @sdk_configuration.hooks.after_success(
1984
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1985
- hook_ctx: hook_ctx
1986
- ),
1987
- response: http_response
1988
- )
1989
- end
1990
-
1991
- if http_response.nil?
1992
- raise error if !error.nil?
1993
- raise 'no response'
1994
- end
1739
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1995
1740
  end
1996
1741
 
1997
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1742
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1998
1743
  if Utils.match_status_code(http_response.status, ['200'])
1999
- if Utils.match_content_type(content_type, 'application/json')
1744
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2000
1745
  http_response = @sdk_configuration.hooks.after_success(
2001
1746
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2002
1747
  hook_ctx: hook_ctx
@@ -2014,14 +1759,14 @@ module FastpixClient
2014
1759
 
2015
1760
  return response
2016
1761
  else
2017
- 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'
1762
+ 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
2018
1763
  end
2019
1764
  elsif Utils.match_status_code(http_response.status, ['4XX'])
2020
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1765
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2021
1766
  elsif Utils.match_status_code(http_response.status, ['5XX'])
2022
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1767
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2023
1768
  else
2024
- if Utils.match_content_type(content_type, 'application/json')
1769
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2025
1770
  http_response = @sdk_configuration.hooks.after_success(
2026
1771
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2027
1772
  hook_ctx: hook_ctx
@@ -2039,7 +1784,7 @@ module FastpixClient
2039
1784
 
2040
1785
  return response
2041
1786
  else
2042
- 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'
1787
+ 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
2043
1788
  end
2044
1789
  end
2045
1790
  end
@@ -2076,8 +1821,8 @@ module FastpixClient
2076
1821
  )
2077
1822
  headers = {}
2078
1823
  headers = T.cast(headers, T::Hash[String, String])
2079
- headers['Accept'] = 'application/json'
2080
- headers['user-agent'] = @sdk_configuration.user_agent
1824
+ headers['Accept'] = CONTENT_TYPE_JSON
1825
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
2081
1826
 
2082
1827
  security = @sdk_configuration.security_source&.call
2083
1828
 
@@ -2115,32 +1860,12 @@ module FastpixClient
2115
1860
  rescue StandardError => e
2116
1861
  error = e
2117
1862
  ensure
2118
- if http_response.nil? || Utils.error_status?(http_response.status)
2119
- http_response = @sdk_configuration.hooks.after_error(
2120
- error: error,
2121
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
2122
- hook_ctx: hook_ctx
2123
- ),
2124
- response: http_response
2125
- )
2126
- else
2127
- http_response = @sdk_configuration.hooks.after_success(
2128
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2129
- hook_ctx: hook_ctx
2130
- ),
2131
- response: http_response
2132
- )
2133
- end
2134
-
2135
- if http_response.nil?
2136
- raise error if !error.nil?
2137
- raise 'no response'
2138
- end
1863
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
2139
1864
  end
2140
1865
 
2141
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1866
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
2142
1867
  if Utils.match_status_code(http_response.status, ['200'])
2143
- if Utils.match_content_type(content_type, 'application/json')
1868
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2144
1869
  http_response = @sdk_configuration.hooks.after_success(
2145
1870
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2146
1871
  hook_ctx: hook_ctx
@@ -2158,14 +1883,14 @@ module FastpixClient
2158
1883
 
2159
1884
  return response
2160
1885
  else
2161
- 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'
1886
+ 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
2162
1887
  end
2163
1888
  elsif Utils.match_status_code(http_response.status, ['4XX'])
2164
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1889
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2165
1890
  elsif Utils.match_status_code(http_response.status, ['5XX'])
2166
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1891
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2167
1892
  else
2168
- if Utils.match_content_type(content_type, 'application/json')
1893
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2169
1894
  http_response = @sdk_configuration.hooks.after_success(
2170
1895
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2171
1896
  hook_ctx: hook_ctx
@@ -2183,7 +1908,7 @@ module FastpixClient
2183
1908
 
2184
1909
  return response
2185
1910
  else
2186
- 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'
1911
+ 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
2187
1912
  end
2188
1913
  end
2189
1914
  end
@@ -2220,8 +1945,8 @@ module FastpixClient
2220
1945
  headers = {}
2221
1946
  headers = T.cast(headers, T::Hash[String, String])
2222
1947
  query_params = Utils.get_query_params(Models::Operations::ListUploadsRequest, request, nil)
2223
- headers['Accept'] = 'application/json'
2224
- headers['user-agent'] = @sdk_configuration.user_agent
1948
+ headers['Accept'] = CONTENT_TYPE_JSON
1949
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
2225
1950
 
2226
1951
  security = @sdk_configuration.security_source&.call
2227
1952
 
@@ -2260,32 +1985,12 @@ module FastpixClient
2260
1985
  rescue StandardError => e
2261
1986
  error = e
2262
1987
  ensure
2263
- if http_response.nil? || Utils.error_status?(http_response.status)
2264
- http_response = @sdk_configuration.hooks.after_error(
2265
- error: error,
2266
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
2267
- hook_ctx: hook_ctx
2268
- ),
2269
- response: http_response
2270
- )
2271
- else
2272
- http_response = @sdk_configuration.hooks.after_success(
2273
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2274
- hook_ctx: hook_ctx
2275
- ),
2276
- response: http_response
2277
- )
2278
- end
2279
-
2280
- if http_response.nil?
2281
- raise error if !error.nil?
2282
- raise 'no response'
2283
- end
1988
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
2284
1989
  end
2285
1990
 
2286
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
1991
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
2287
1992
  if Utils.match_status_code(http_response.status, ['200'])
2288
- if Utils.match_content_type(content_type, 'application/json')
1993
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2289
1994
  http_response = @sdk_configuration.hooks.after_success(
2290
1995
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2291
1996
  hook_ctx: hook_ctx
@@ -2303,14 +2008,14 @@ module FastpixClient
2303
2008
 
2304
2009
  return response
2305
2010
  else
2306
- 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'
2011
+ 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
2307
2012
  end
2308
2013
  elsif Utils.match_status_code(http_response.status, ['4XX'])
2309
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
2014
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2310
2015
  elsif Utils.match_status_code(http_response.status, ['5XX'])
2311
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
2016
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2312
2017
  else
2313
- if Utils.match_content_type(content_type, 'application/json')
2018
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2314
2019
  http_response = @sdk_configuration.hooks.after_success(
2315
2020
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2316
2021
  hook_ctx: hook_ctx
@@ -2328,7 +2033,7 @@ module FastpixClient
2328
2033
 
2329
2034
  return response
2330
2035
  else
2331
- 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'
2036
+ 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
2332
2037
  end
2333
2038
  end
2334
2039
  end
@@ -2354,7 +2059,7 @@ module FastpixClient
2354
2059
  #
2355
2060
  # Imagine you’re managing a video editing platform where users upload full-length videos and create short clips for social media sharing. To keep track of all clips linked to a particular video, you call this API with the sourceMediaId. The response provides a list of all associated clips, allowing you to manage, edit, or repurpose them as needed.
2356
2061
  #
2357
- # Related guide: <a href="https://docs.fastpix.io/docs/create-clips-from-existing-media">Create clips from existing media</a>
2062
+ # Related guide: <a href="https://fastpix.com/docs/edit-and-transform-videos/clip-and-trim-videos">Create clips from existing media</a>
2358
2063
  #
2359
2064
  request = Models::Operations::GetMediaClipsRequest.new(
2360
2065
  media_id: media_id,
@@ -2373,8 +2078,8 @@ module FastpixClient
2373
2078
  headers = {}
2374
2079
  headers = T.cast(headers, T::Hash[String, String])
2375
2080
  query_params = Utils.get_query_params(Models::Operations::GetMediaClipsRequest, request, nil)
2376
- headers['Accept'] = 'application/json'
2377
- headers['user-agent'] = @sdk_configuration.user_agent
2081
+ headers['Accept'] = CONTENT_TYPE_JSON
2082
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
2378
2083
 
2379
2084
  security = @sdk_configuration.security_source&.call
2380
2085
 
@@ -2413,32 +2118,12 @@ module FastpixClient
2413
2118
  rescue StandardError => e
2414
2119
  error = e
2415
2120
  ensure
2416
- if http_response.nil? || Utils.error_status?(http_response.status)
2417
- http_response = @sdk_configuration.hooks.after_error(
2418
- error: error,
2419
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
2420
- hook_ctx: hook_ctx
2421
- ),
2422
- response: http_response
2423
- )
2424
- else
2425
- http_response = @sdk_configuration.hooks.after_success(
2426
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2427
- hook_ctx: hook_ctx
2428
- ),
2429
- response: http_response
2430
- )
2431
- end
2432
-
2433
- if http_response.nil?
2434
- raise error if !error.nil?
2435
- raise 'no response'
2436
- end
2121
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
2437
2122
  end
2438
2123
 
2439
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
2124
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
2440
2125
  if Utils.match_status_code(http_response.status, ['200'])
2441
- if Utils.match_content_type(content_type, 'application/json')
2126
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2442
2127
  http_response = @sdk_configuration.hooks.after_success(
2443
2128
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2444
2129
  hook_ctx: hook_ctx
@@ -2456,14 +2141,14 @@ module FastpixClient
2456
2141
 
2457
2142
  return response
2458
2143
  else
2459
- 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'
2144
+ 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
2460
2145
  end
2461
2146
  elsif Utils.match_status_code(http_response.status, ['4XX'])
2462
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
2147
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2463
2148
  elsif Utils.match_status_code(http_response.status, ['5XX'])
2464
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
2149
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
2465
2150
  else
2466
- if Utils.match_content_type(content_type, 'application/json')
2151
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
2467
2152
  http_response = @sdk_configuration.hooks.after_success(
2468
2153
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2469
2154
  hook_ctx: hook_ctx
@@ -2481,7 +2166,7 @@ module FastpixClient
2481
2166
 
2482
2167
  return response
2483
2168
  else
2484
- 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'
2169
+ 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
2485
2170
  end
2486
2171
  end
2487
2172
  end