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,37 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class Errors
16
16
  extend T::Sig
17
+
18
+ CONTENT_TYPE_JSON = 'application/json'
19
+
20
+ # Applies the SDK after-request hooks and ensures a usable response is present.
21
+ sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
22
+ def apply_after_request_hooks(http_response, error, hook_ctx)
23
+ if http_response.nil? || Utils.error_status?(http_response.status)
24
+ http_response = @sdk_configuration.hooks.after_error(
25
+ error: error,
26
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
27
+ hook_ctx: hook_ctx
28
+ ),
29
+ response: http_response
30
+ )
31
+ else
32
+ http_response = @sdk_configuration.hooks.after_success(
33
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
34
+ hook_ctx: hook_ctx
35
+ ),
36
+ response: http_response
37
+ )
38
+ end
39
+
40
+ if http_response.nil?
41
+ raise error unless error.nil?
42
+ raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
43
+ end
44
+
45
+ http_response
46
+ end
47
+ private :apply_after_request_hooks
17
48
 
18
49
  # Operations involving errors
19
50
 
@@ -58,7 +89,7 @@ module FastpixClient
58
89
  # * **code:** The error code associated with the specific error.
59
90
  #
60
91
  #
61
- # Related guide: <a href="https://docs.fastpix.io/docs/track-playback-errors">Troubleshoot errors</a>
92
+ # Related guide: <a href="https://fastpix.com/docs/working-with-video-data/troubleshoot-playback-errors">Troubleshoot errors</a>
62
93
  #
63
94
  request = Models::Operations::ListErrorsRequest.new(
64
95
  timespan: timespan,
@@ -71,7 +102,7 @@ module FastpixClient
71
102
  headers = {}
72
103
  headers = T.cast(headers, T::Hash[String, String])
73
104
  query_params = Utils.get_query_params(Models::Operations::ListErrorsRequest, request, nil)
74
- headers['Accept'] = 'application/json'
105
+ headers['Accept'] = CONTENT_TYPE_JSON
75
106
  headers['user-agent'] = @sdk_configuration.user_agent
76
107
 
77
108
  security = @sdk_configuration.security_source&.call
@@ -111,32 +142,12 @@ module FastpixClient
111
142
  rescue StandardError => e
112
143
  error = e
113
144
  ensure
114
- if http_response.nil? || Utils.error_status?(http_response.status)
115
- http_response = @sdk_configuration.hooks.after_error(
116
- error: error,
117
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
118
- hook_ctx: hook_ctx
119
- ),
120
- response: http_response
121
- )
122
- else
123
- http_response = @sdk_configuration.hooks.after_success(
124
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
125
- hook_ctx: hook_ctx
126
- ),
127
- response: http_response
128
- )
129
- end
130
-
131
- if http_response.nil?
132
- raise error if !error.nil?
133
- raise 'no response'
134
- end
145
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
135
146
  end
136
147
 
137
148
  content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
138
149
  if Utils.match_status_code(http_response.status, ['200'])
139
- if Utils.match_content_type(content_type, 'application/json')
150
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
140
151
  http_response = @sdk_configuration.hooks.after_success(
141
152
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
142
153
  hook_ctx: hook_ctx
@@ -161,7 +172,7 @@ module FastpixClient
161
172
  elsif Utils.match_status_code(http_response.status, ['5XX'])
162
173
  raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
163
174
  else
164
- if Utils.match_content_type(content_type, 'application/json')
175
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
165
176
  http_response = @sdk_configuration.hooks.after_success(
166
177
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
167
178
  hook_ctx: hook_ctx
@@ -54,10 +54,8 @@ module FastpixClient
54
54
  # f.response :logger, nil, { headers: true, bodies: true, errors: true }
55
55
  end
56
56
 
57
- if !server_url.nil?
58
- if !url_params.nil?
59
- server_url = Utils.template_url(server_url, url_params)
60
- end
57
+ if !server_url.nil? && !url_params.nil?
58
+ server_url = Utils.template_url(server_url, url_params)
61
59
  end
62
60
 
63
61
  server_idx = 0 if server_idx.nil?
@@ -14,6 +14,58 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class InVideoAIFeatures
16
16
  extend T::Sig
17
+
18
+ API_ERROR_OCCURRED = 'API error occurred'
19
+ CONTENT_TYPE_HEADER = 'Content-Type'
20
+ CONTENT_TYPE_JSON = 'application/json'
21
+ DEFAULT_CONTENT_TYPE = 'application/octet-stream'
22
+ REQUEST_CONTENT_TYPE_HEADER = 'content-type'
23
+ UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
24
+ USER_AGENT_HEADER = 'user-agent'
25
+
26
+ # Applies the SDK after-request hooks and ensures a usable response is present.
27
+ sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
28
+ def apply_after_request_hooks(http_response, error, hook_ctx)
29
+ if http_response.nil? || Utils.error_status?(http_response.status)
30
+ http_response = @sdk_configuration.hooks.after_error(
31
+ error: error,
32
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
33
+ hook_ctx: hook_ctx
34
+ ),
35
+ response: http_response
36
+ )
37
+ else
38
+ http_response = @sdk_configuration.hooks.after_success(
39
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
40
+ hook_ctx: hook_ctx
41
+ ),
42
+ response: http_response
43
+ )
44
+ end
45
+
46
+ if http_response.nil?
47
+ raise error unless error.nil?
48
+ raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
49
+ end
50
+
51
+ http_response
52
+ end
53
+ private :apply_after_request_hooks
54
+
55
+ # Encodes the request body based on its serialized content type.
56
+ sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
57
+ def encode_request_body(req_content_type, data, form)
58
+ raise ArgumentError, 'request body is required' if data.nil? && form.nil?
59
+
60
+ if form
61
+ Utils.encode_form(form)
62
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
63
+ URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
64
+ else
65
+ data
66
+ end
67
+ end
68
+ private :encode_request_body
17
69
 
18
70
  # Operations for AI-powered video features
19
71
 
@@ -50,7 +102,7 @@ module FastpixClient
50
102
  # 3. Include the `summaryLength` parameter, specify the desired length of the summary in words (for example, 120 words), this determines how concise or detailed the summary will be. If no specific summary length is provided, the default length will be 100 words.
51
103
  # 4. The response includes the updated media data and confirmation of the changes applied.
52
104
  #
53
- # You can use the <a href="https://docs.fastpix.io/docs/ai-events#videomediaaisummaryready">video.mediaAI.summary.ready</a> webhook event to track and notify about the summary generation.
105
+ # You can use the <a href="https://fastpix.com/docs/ai-events/in-video-ai-events#videomediaaisummaryready">video.mediaAI.summary.ready</a> webhook event to track and notify about the summary generation.
54
106
  #
55
107
  #
56
108
  #
@@ -58,7 +110,7 @@ module FastpixClient
58
110
  #
59
111
  # **Use case**: This is particularly useful when a user uploads a video and later chooses to generate a summary without needing to re-upload the video.
60
112
  #
61
- # Related guide: <a href="https://docs.fastpix.io/docs/generate-video-summary">Video summary</a>
113
+ # Related guide: <a href="https://fastpix.com/docs/video-intelligence/generate-a-video-summary">Video summary</a>
62
114
  #
63
115
  request = Models::Operations::UpdateMediaSummaryRequest.new(
64
116
  media_id: media_id,
@@ -75,18 +127,10 @@ module FastpixClient
75
127
  headers = {}
76
128
  headers = T.cast(headers, T::Hash[String, String])
77
129
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
78
- headers['content-type'] = req_content_type
79
- raise StandardError, 'request body is required' if data.nil? && form.nil?
80
-
81
- if form
82
- body = Utils.encode_form(form)
83
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
84
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
85
- else
86
- body = data
87
- end
88
- headers['Accept'] = 'application/json'
89
- headers['user-agent'] = @sdk_configuration.user_agent
130
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
131
+ body = encode_request_body(req_content_type, data, form)
132
+ headers['Accept'] = CONTENT_TYPE_JSON
133
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
90
134
 
91
135
  security = @sdk_configuration.security_source&.call
92
136
 
@@ -125,32 +169,12 @@ module FastpixClient
125
169
  rescue StandardError => e
126
170
  error = e
127
171
  ensure
128
- if http_response.nil? || Utils.error_status?(http_response.status)
129
- http_response = @sdk_configuration.hooks.after_error(
130
- error: error,
131
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
132
- hook_ctx: hook_ctx
133
- ),
134
- response: http_response
135
- )
136
- else
137
- http_response = @sdk_configuration.hooks.after_success(
138
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
139
- hook_ctx: hook_ctx
140
- ),
141
- response: http_response
142
- )
143
- end
144
-
145
- if http_response.nil?
146
- raise error if !error.nil?
147
- raise 'no response'
148
- end
172
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
149
173
  end
150
174
 
151
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
175
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
152
176
  if Utils.match_status_code(http_response.status, ['200'])
153
- if Utils.match_content_type(content_type, 'application/json')
177
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
154
178
  http_response = @sdk_configuration.hooks.after_success(
155
179
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
156
180
  hook_ctx: hook_ctx
@@ -168,14 +192,14 @@ module FastpixClient
168
192
 
169
193
  return response
170
194
  else
171
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
195
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
172
196
  end
173
197
  elsif Utils.match_status_code(http_response.status, ['4XX'])
174
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
198
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
175
199
  elsif Utils.match_status_code(http_response.status, ['5XX'])
176
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
200
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
177
201
  else
178
- if Utils.match_content_type(content_type, 'application/json')
202
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
179
203
  http_response = @sdk_configuration.hooks.after_success(
180
204
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
181
205
  hook_ctx: hook_ctx
@@ -193,7 +217,7 @@ module FastpixClient
193
217
 
194
218
  return response
195
219
  else
196
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
220
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
197
221
  end
198
222
  end
199
223
  end
@@ -209,11 +233,11 @@ module FastpixClient
209
233
  # 2. Include the `chapters` parameter in the request body to enable.
210
234
  # 3. The response contains the updated media data, confirming the changes made.
211
235
  #
212
- # You can use the <a href="https://docs.fastpix.io/docs/ai-events#videomediaaichaptersready">video.mediaAI.chapters.ready</a> webhook event to track and notify about the chapters generation.
236
+ # You can use the <a href="https://fastpix.com/docs/ai-events/in-video-ai-events#videomediaaichaptersready">video.mediaAI.chapters.ready</a> webhook event to track and notify about the chapters generation.
213
237
  #
214
238
  # **Use case:** This is particularly useful when a user uploads a video and later decides to enable chapters without re-uploading the entire video.
215
239
  #
216
- # Related guide: <a href="https://docs.fastpix.io/docs/generate-video-chapters">Video chapters</a>
240
+ # Related guide: <a href="https://fastpix.com/docs/video-intelligence/generate-video-chapters">Video chapters</a>
217
241
  #
218
242
  request = Models::Operations::UpdateMediaChaptersRequest.new(
219
243
  media_id: media_id,
@@ -230,18 +254,10 @@ module FastpixClient
230
254
  headers = {}
231
255
  headers = T.cast(headers, T::Hash[String, String])
232
256
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
233
- headers['content-type'] = req_content_type
234
- raise StandardError, 'request body is required' if data.nil? && form.nil?
235
-
236
- if form
237
- body = Utils.encode_form(form)
238
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
239
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
240
- else
241
- body = data
242
- end
243
- headers['Accept'] = 'application/json'
244
- headers['user-agent'] = @sdk_configuration.user_agent
257
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
258
+ body = encode_request_body(req_content_type, data, form)
259
+ headers['Accept'] = CONTENT_TYPE_JSON
260
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
245
261
 
246
262
  security = @sdk_configuration.security_source&.call
247
263
 
@@ -280,32 +296,12 @@ module FastpixClient
280
296
  rescue StandardError => e
281
297
  error = e
282
298
  ensure
283
- if http_response.nil? || Utils.error_status?(http_response.status)
284
- http_response = @sdk_configuration.hooks.after_error(
285
- error: error,
286
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
287
- hook_ctx: hook_ctx
288
- ),
289
- response: http_response
290
- )
291
- else
292
- http_response = @sdk_configuration.hooks.after_success(
293
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
294
- hook_ctx: hook_ctx
295
- ),
296
- response: http_response
297
- )
298
- end
299
-
300
- if http_response.nil?
301
- raise error if !error.nil?
302
- raise 'no response'
303
- end
299
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
304
300
  end
305
301
 
306
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
302
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
307
303
  if Utils.match_status_code(http_response.status, ['200'])
308
- if Utils.match_content_type(content_type, 'application/json')
304
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
309
305
  http_response = @sdk_configuration.hooks.after_success(
310
306
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
311
307
  hook_ctx: hook_ctx
@@ -323,14 +319,14 @@ module FastpixClient
323
319
 
324
320
  return response
325
321
  else
326
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
322
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
327
323
  end
328
324
  elsif Utils.match_status_code(http_response.status, ['4XX'])
329
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
325
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
330
326
  elsif Utils.match_status_code(http_response.status, ['5XX'])
331
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
327
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
332
328
  else
333
- if Utils.match_content_type(content_type, 'application/json')
329
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
334
330
  http_response = @sdk_configuration.hooks.after_success(
335
331
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
336
332
  hook_ctx: hook_ctx
@@ -348,7 +344,7 @@ module FastpixClient
348
344
 
349
345
  return response
350
346
  else
351
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
347
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
352
348
  end
353
349
  end
354
350
  end
@@ -369,11 +365,11 @@ module FastpixClient
369
365
  # 2. Include the `namedEntities` parameter in the request body to enable.
370
366
  # 3. Receive a response containing the updated media data, confirming the changes made.
371
367
  #
372
- # You can use the <a href="https://docs.fastpix.io/docs/ai-events#videomediaainamedentitiesready">video.mediaAI.named-entities.ready</a> webhook event to track and notify about the named entities extraction.
368
+ # You can use the <a href="https://fastpix.com/docs/ai-events/in-video-ai-events#videomediaainamedentitiesready">video.mediaAI.named-entities.ready</a> webhook event to track and notify about the named entities extraction.
373
369
  #
374
370
  # **Use case:** If a user uploads a video and later decides to enable named entity extraction without re-uploading the entire video.
375
371
  #
376
- # Related guide: <a href="https://docs.fastpix.io/docs/generate-named-entities">Named entities</a>
372
+ # Related guide: <a href="https://fastpix.com/docs/video-intelligence/extract-named-entities-from-a-video">Named entities</a>
377
373
  #
378
374
  request = Models::Operations::UpdateMediaNamedEntitiesRequest.new(
379
375
  media_id: media_id,
@@ -390,18 +386,10 @@ module FastpixClient
390
386
  headers = {}
391
387
  headers = T.cast(headers, T::Hash[String, String])
392
388
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
393
- headers['content-type'] = req_content_type
394
- raise StandardError, 'request body is required' if data.nil? && form.nil?
395
-
396
- if form
397
- body = Utils.encode_form(form)
398
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
399
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
400
- else
401
- body = data
402
- end
403
- headers['Accept'] = 'application/json'
404
- headers['user-agent'] = @sdk_configuration.user_agent
389
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
390
+ body = encode_request_body(req_content_type, data, form)
391
+ headers['Accept'] = CONTENT_TYPE_JSON
392
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
405
393
 
406
394
  security = @sdk_configuration.security_source&.call
407
395
 
@@ -440,32 +428,12 @@ module FastpixClient
440
428
  rescue StandardError => e
441
429
  error = e
442
430
  ensure
443
- if http_response.nil? || Utils.error_status?(http_response.status)
444
- http_response = @sdk_configuration.hooks.after_error(
445
- error: error,
446
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
447
- hook_ctx: hook_ctx
448
- ),
449
- response: http_response
450
- )
451
- else
452
- http_response = @sdk_configuration.hooks.after_success(
453
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
454
- hook_ctx: hook_ctx
455
- ),
456
- response: http_response
457
- )
458
- end
459
-
460
- if http_response.nil?
461
- raise error if !error.nil?
462
- raise 'no response'
463
- end
431
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
464
432
  end
465
433
 
466
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
434
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
467
435
  if Utils.match_status_code(http_response.status, ['200'])
468
- if Utils.match_content_type(content_type, 'application/json')
436
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
469
437
  http_response = @sdk_configuration.hooks.after_success(
470
438
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
471
439
  hook_ctx: hook_ctx
@@ -483,14 +451,14 @@ module FastpixClient
483
451
 
484
452
  return response
485
453
  else
486
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
454
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
487
455
  end
488
456
  elsif Utils.match_status_code(http_response.status, ['4XX'])
489
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
457
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
490
458
  elsif Utils.match_status_code(http_response.status, ['5XX'])
491
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
459
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
492
460
  else
493
- if Utils.match_content_type(content_type, 'application/json')
461
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
494
462
  http_response = @sdk_configuration.hooks.after_success(
495
463
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
496
464
  hook_ctx: hook_ctx
@@ -508,7 +476,7 @@ module FastpixClient
508
476
 
509
477
  return response
510
478
  else
511
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
479
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
512
480
  end
513
481
  end
514
482
  end
@@ -524,11 +492,11 @@ module FastpixClient
524
492
  # 2. Include the `moderation` object and provide the requried `type` parameter in the request body to specify the media type (for example, video/audio/av).
525
493
  # 4. The response contains the updated media data, confirming the changes made.
526
494
  #
527
- # You can use the <a href="https://docs.fastpix.io/docs/ai-events#videomediaaimoderationready">video.mediaAI.moderation.ready</a> webhook event to track and notify about the detected moderation results.
495
+ # You can use the <a href="https://fastpix.com/docs/ai-events/in-video-ai-events#videomediaaimoderationready">video.mediaAI.moderation.ready</a> webhook event to track and notify about the detected moderation results.
528
496
  #
529
497
  # **Use case:** This is particularly useful when a user uploads a video and later decides to enable moderation detection without the need to re-upload it.
530
498
  #
531
- # Related guide: <a href="https://docs.fastpix.io/docs/using-nsfw-and-profanity-filter-for-video-moderation">Moderate NSFW & Profanity</a>
499
+ # Related guide: <a href="https://fastpix.com/docs/video-intelligence/detect-nsfw-content-and-profanity">Moderate NSFW & Profanity</a>
532
500
  #
533
501
  request = Models::Operations::UpdateMediaModerationRequest.new(
534
502
  media_id: media_id,
@@ -545,18 +513,10 @@ module FastpixClient
545
513
  headers = {}
546
514
  headers = T.cast(headers, T::Hash[String, String])
547
515
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
548
- headers['content-type'] = req_content_type
549
- raise StandardError, 'request body is required' if data.nil? && form.nil?
550
-
551
- if form
552
- body = Utils.encode_form(form)
553
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
554
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
555
- else
556
- body = data
557
- end
558
- headers['Accept'] = 'application/json'
559
- headers['user-agent'] = @sdk_configuration.user_agent
516
+ headers[REQUEST_CONTENT_TYPE_HEADER] = req_content_type
517
+ body = encode_request_body(req_content_type, data, form)
518
+ headers['Accept'] = CONTENT_TYPE_JSON
519
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
560
520
 
561
521
  security = @sdk_configuration.security_source&.call
562
522
 
@@ -595,32 +555,12 @@ module FastpixClient
595
555
  rescue StandardError => e
596
556
  error = e
597
557
  ensure
598
- if http_response.nil? || Utils.error_status?(http_response.status)
599
- http_response = @sdk_configuration.hooks.after_error(
600
- error: error,
601
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
602
- hook_ctx: hook_ctx
603
- ),
604
- response: http_response
605
- )
606
- else
607
- http_response = @sdk_configuration.hooks.after_success(
608
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
609
- hook_ctx: hook_ctx
610
- ),
611
- response: http_response
612
- )
613
- end
614
-
615
- if http_response.nil?
616
- raise error if !error.nil?
617
- raise 'no response'
618
- end
558
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
619
559
  end
620
560
 
621
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
561
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
622
562
  if Utils.match_status_code(http_response.status, ['200'])
623
- if Utils.match_content_type(content_type, 'application/json')
563
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
624
564
  http_response = @sdk_configuration.hooks.after_success(
625
565
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
626
566
  hook_ctx: hook_ctx
@@ -638,14 +578,14 @@ module FastpixClient
638
578
 
639
579
  return response
640
580
  else
641
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
581
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
642
582
  end
643
583
  elsif Utils.match_status_code(http_response.status, ['4XX'])
644
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
584
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
645
585
  elsif Utils.match_status_code(http_response.status, ['5XX'])
646
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
586
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
647
587
  else
648
- if Utils.match_content_type(content_type, 'application/json')
588
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
649
589
  http_response = @sdk_configuration.hooks.after_success(
650
590
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
651
591
  hook_ctx: hook_ctx
@@ -663,7 +603,7 @@ module FastpixClient
663
603
 
664
604
  return response
665
605
  else
666
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
606
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
667
607
  end
668
608
  end
669
609
  end