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.
- checksums.yaml +4 -4
- data/lib/crystalline/metadata_fields.rb +56 -48
- data/lib/crystalline/types.rb +3 -3
- data/lib/crystalline.rb +4 -5
- data/lib/fastpix_client/dimensions.rb +55 -62
- data/lib/fastpix_client/drm_configurations.rb +51 -58
- data/lib/fastpix_client/errors.rb +36 -25
- data/lib/fastpix_client/fastpixapi.rb +2 -4
- data/lib/fastpix_client/in_video_ai_features.rb +108 -168
- data/lib/fastpix_client/input_video.rb +75 -83
- data/lib/fastpix_client/live_playback.rb +82 -99
- data/lib/fastpix_client/manage_live_stream.rb +145 -261
- data/lib/fastpix_client/manage_videos.rb +252 -567
- data/lib/fastpix_client/metrics.rb +82 -126
- data/lib/fastpix_client/models/components/addtrackrequest.rb +1 -1
- data/lib/fastpix_client/models/components/createlivestreamresponsedto.rb +10 -18
- data/lib/fastpix_client/models/components/createmediarequest.rb +10 -19
- data/lib/fastpix_client/models/components/deletesigningkeyresponse.rb +6 -2
- data/lib/fastpix_client/models/components/deletesigningkeyresponsedata.rb +33 -0
- data/lib/fastpix_client/models/components/getallmediaresponse.rb +13 -29
- data/lib/fastpix_client/models/components/getcreatelivestreamresponsedto.rb +9 -20
- data/lib/fastpix_client/models/components/getmediaresponse.rb +13 -29
- data/lib/fastpix_client/models/components/live_media_clips.rb +9 -21
- data/lib/fastpix_client/models/components/media.rb +11 -26
- data/lib/fastpix_client/models/components/patchresponsedata.rb +9 -18
- data/lib/fastpix_client/models/components/pullvideoinput.rb +1 -1
- data/lib/fastpix_client/models/components/sourceaccessmedia.rb +11 -26
- data/lib/fastpix_client/models/components/update_media.rb +11 -26
- data/lib/fastpix_client/models/components/views.rb +52 -125
- data/lib/fastpix_client/models/components/watermarkinput.rb +1 -1
- data/lib/fastpix_client/models/components.rb +1 -0
- data/lib/fastpix_client/models/errors/empty_response_error.rb +15 -0
- data/lib/fastpix_client/models/errors.rb +1 -0
- data/lib/fastpix_client/models/operations/add_media_to_playlist_response.rb +1 -1
- data/lib/fastpix_client/models/operations/add_media_track_response.rb +1 -1
- data/lib/fastpix_client/models/operations/cancel_upload_response.rb +1 -1
- data/lib/fastpix_client/models/operations/change_media_order_in_playlist_response.rb +1 -1
- data/lib/fastpix_client/models/operations/complete_live_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_a_playlist_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_media_playback_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_media_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_new_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_playbackid_of_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_signing_key_response.rb +1 -1
- data/lib/fastpix_client/models/operations/create_simulcast_of_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_a_playlist_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_live_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_media_from_playlist_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_media_playback_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_media_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_media_track_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_playbackid_of_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_signing_key_response.rb +1 -1
- data/lib/fastpix_client/models/operations/delete_simulcast_of_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/direct_upload_video_media_request.rb +1 -1
- data/lib/fastpix_client/models/operations/direct_upload_video_media_response.rb +1 -1
- data/lib/fastpix_client/models/operations/disable_live_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/enable_live_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/generate_subtitle_track_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_all_playlists_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_all_streams_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_live_stream_by_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_live_stream_playback_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_live_stream_viewer_count_by_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_media_clips_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_media_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_media_summary_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_playback_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_playlist_by_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_signing_key_by_id_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_specific_simulcast_of_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_timeseries_data_response.rb +1 -1
- data/lib/fastpix_client/models/operations/get_video_view_details_response.rb +1 -1
- data/lib/fastpix_client/models/operations/getdrmconfiguration_response.rb +1 -1
- data/lib/fastpix_client/models/operations/getdrmconfigurationbyid_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_breakdown_values_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_by_top_content_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_comparison_values_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_dimensions_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_errors_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_filter_values_for_dimension_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_live_clips_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_media_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_overall_values_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_playback_ids_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_signing_keys_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_uploads_response.rb +1 -1
- data/lib/fastpix_client/models/operations/list_video_views_response.rb +1 -1
- data/lib/fastpix_client/models/operations/push_media_settings.rb +10 -21
- data/lib/fastpix_client/models/operations/retrievemediainputinfo_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_a_playlist_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_domain_restrictions_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_live_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_media_chapters_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_media_moderation_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_media_named_entities_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_media_summary_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_media_track_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_specific_simulcast_of_stream_response.rb +1 -1
- data/lib/fastpix_client/models/operations/update_user_agent_restrictions_response.rb +1 -1
- data/lib/fastpix_client/models/operations/updated_media_response.rb +1 -1
- data/lib/fastpix_client/models/operations/updated_mp4support_response.rb +1 -1
- data/lib/fastpix_client/models/operations/updated_source_access_response.rb +1 -1
- data/lib/fastpix_client/playback.rb +123 -214
- data/lib/fastpix_client/playlist.rb +151 -297
- data/lib/fastpix_client/sdk_hooks/registration.rb +2 -2
- data/lib/fastpix_client/sdk_hooks/types.rb +4 -0
- data/lib/fastpix_client/sdkconfiguration.rb +4 -4
- data/lib/fastpix_client/signing_keys.rb +79 -123
- data/lib/fastpix_client/simulcast_stream.rb +101 -145
- data/lib/fastpix_client/start_live_stream.rb +54 -36
- data/lib/fastpix_client/utils/forms.rb +97 -101
- data/lib/fastpix_client/utils/headers.rb +44 -34
- data/lib/fastpix_client/utils/query_params.rb +39 -29
- data/lib/fastpix_client/utils/request_bodies.rb +4 -8
- data/lib/fastpix_client/utils/security.rb +30 -18
- data/lib/fastpix_client/utils/url.rb +83 -55
- data/lib/fastpix_client/utils/utils.rb +19 -37
- data/lib/fastpix_client/views.rb +71 -95
- data/lib/fastpixapi.rb +10 -10
- data/lib/openssl_patch.rb +24 -24
- metadata +20 -4
|
@@ -14,6 +14,54 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class InputVideo
|
|
16
16
|
extend T::Sig
|
|
17
|
+
|
|
18
|
+
API_ERROR_OCCURRED = 'API error occurred'
|
|
19
|
+
CONTENT_TYPE_JSON = 'application/json'
|
|
20
|
+
UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
|
|
21
|
+
|
|
22
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
23
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
24
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
25
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
26
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
27
|
+
error: error,
|
|
28
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
29
|
+
hook_ctx: hook_ctx
|
|
30
|
+
),
|
|
31
|
+
response: http_response
|
|
32
|
+
)
|
|
33
|
+
else
|
|
34
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
35
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
36
|
+
hook_ctx: hook_ctx
|
|
37
|
+
),
|
|
38
|
+
response: http_response
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if http_response.nil?
|
|
43
|
+
raise error unless error.nil?
|
|
44
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
http_response
|
|
48
|
+
end
|
|
49
|
+
private :apply_after_request_hooks
|
|
50
|
+
|
|
51
|
+
# Encodes the request body based on its serialized content type.
|
|
52
|
+
sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
|
|
53
|
+
def encode_request_body(req_content_type, data, form)
|
|
54
|
+
raise ArgumentError, 'request body is required' if data.nil? && form.nil?
|
|
55
|
+
|
|
56
|
+
if form
|
|
57
|
+
Utils.encode_form(form)
|
|
58
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
59
|
+
URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
60
|
+
else
|
|
61
|
+
data
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
private :encode_request_body
|
|
17
65
|
|
|
18
66
|
# Operations for inputting and creating video media
|
|
19
67
|
|
|
@@ -77,14 +125,14 @@ module FastpixClient
|
|
|
77
125
|
#
|
|
78
126
|
# 3. Receive a response containing the unique id for the newly created media item.
|
|
79
127
|
#
|
|
80
|
-
# 4. Use the id in subsequent API calls, such as checking the status of the media with the <a href="https://
|
|
128
|
+
# 4. Use the id in subsequent API calls, such as checking the status of the media with the <a href="https://fastpix.com/docs/video-on-demand-api/manage-videos/get-media">Get Media by ID</a> endpoint to determine when the media is ready for playback.
|
|
81
129
|
#
|
|
82
|
-
# FastPix uses webhooks to tell your application about things that happen in the background, outside of the API regular request flow. For instance, after the media file is created (but not yet processed or encoded), FastPix sends a `POST` request to your specified webhook URL with the event <a href="https://
|
|
130
|
+
# FastPix uses webhooks to tell your application about things that happen in the background, outside of the API regular request flow. For instance, after the media file is created (but not yet processed or encoded), FastPix sends a `POST` request to your specified webhook URL with the event <a href="https://fastpix.com/docs/vod-events/media-events#videomediacreated">video.media.created</a>.
|
|
83
131
|
#
|
|
84
132
|
#
|
|
85
|
-
# After processing completes, monitor the events <a href="https://
|
|
133
|
+
# After processing completes, monitor the events <a href="https://fastpix.com/docs/vod-events/media-events#videomediaready">video.media.ready</a> and <a href="https://fastpix.com/docs/vod-events/media-events#videomediafailed">video.media.failed</a> to track the status of the media file.
|
|
86
134
|
#
|
|
87
|
-
# Related guide: <a href="https://
|
|
135
|
+
# Related guide: <a href="https://fastpix.com/docs/upload-videos/upload-videos-from-a-url">Upload videos from URL</a>
|
|
88
136
|
#
|
|
89
137
|
url, params = @sdk_configuration.get_server_details
|
|
90
138
|
base_url = Utils.template_url(url, params)
|
|
@@ -93,16 +141,8 @@ module FastpixClient
|
|
|
93
141
|
headers = T.cast(headers, T::Hash[String, String])
|
|
94
142
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
|
|
95
143
|
headers['content-type'] = req_content_type
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if form
|
|
99
|
-
body = Utils.encode_form(form)
|
|
100
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
101
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
102
|
-
else
|
|
103
|
-
body = data
|
|
104
|
-
end
|
|
105
|
-
headers['Accept'] = 'application/json'
|
|
144
|
+
body = encode_request_body(req_content_type, data, form)
|
|
145
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
106
146
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
107
147
|
|
|
108
148
|
security = @sdk_configuration.security_source&.call
|
|
@@ -142,32 +182,12 @@ module FastpixClient
|
|
|
142
182
|
rescue StandardError => e
|
|
143
183
|
error = e
|
|
144
184
|
ensure
|
|
145
|
-
|
|
146
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
147
|
-
error: error,
|
|
148
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
149
|
-
hook_ctx: hook_ctx
|
|
150
|
-
),
|
|
151
|
-
response: http_response
|
|
152
|
-
)
|
|
153
|
-
else
|
|
154
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
155
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
156
|
-
hook_ctx: hook_ctx
|
|
157
|
-
),
|
|
158
|
-
response: http_response
|
|
159
|
-
)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
if http_response.nil?
|
|
163
|
-
raise error if !error.nil?
|
|
164
|
-
raise 'no response'
|
|
165
|
-
end
|
|
185
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
166
186
|
end
|
|
167
187
|
|
|
168
188
|
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
169
189
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
170
|
-
if Utils.match_content_type(content_type,
|
|
190
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
171
191
|
http_response = @sdk_configuration.hooks.after_success(
|
|
172
192
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
173
193
|
hook_ctx: hook_ctx
|
|
@@ -185,14 +205,14 @@ module FastpixClient
|
|
|
185
205
|
|
|
186
206
|
return response
|
|
187
207
|
else
|
|
188
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
208
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
189
209
|
end
|
|
190
210
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
191
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
211
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
192
212
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
193
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
213
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
194
214
|
else
|
|
195
|
-
if Utils.match_content_type(content_type,
|
|
215
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
196
216
|
http_response = @sdk_configuration.hooks.after_success(
|
|
197
217
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
198
218
|
hook_ctx: hook_ctx
|
|
@@ -210,7 +230,7 @@ module FastpixClient
|
|
|
210
230
|
|
|
211
231
|
return response
|
|
212
232
|
else
|
|
213
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
233
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
214
234
|
end
|
|
215
235
|
end
|
|
216
236
|
end
|
|
@@ -223,7 +243,7 @@ module FastpixClient
|
|
|
223
243
|
#
|
|
224
244
|
# > **NOTE**
|
|
225
245
|
# >
|
|
226
|
-
# > This version now supports uploads with no file size limitations and offers faster uploads. The previous endpoint (which had a 500MB size limit) is now deprecated. You can find details in the [changelog](https://
|
|
246
|
+
# > This version now supports uploads with no file size limitations and offers faster uploads. The previous endpoint (which had a 500MB size limit) is now deprecated. You can find details in the [changelog](https://fastpix.com/docs/changelog/release-notes).
|
|
227
247
|
#
|
|
228
248
|
# #### How it works
|
|
229
249
|
#
|
|
@@ -231,23 +251,23 @@ module FastpixClient
|
|
|
231
251
|
#
|
|
232
252
|
# 2. The response includes an `uploadId` and a signed `url` for direct video file upload.
|
|
233
253
|
#
|
|
234
|
-
# 3. Upload your video file to the provided url by making a PUT request. The API accepts the media file from your device and uploads it to the FastPix platform. (Refer to <a href="https://
|
|
254
|
+
# 3. Upload your video file to the provided url by making a PUT request. The API accepts the media file from your device and uploads it to the FastPix platform. (Refer to <a href="https://fastpix.com/docs/upload-videos/upload-videos-from-device#step-3-initiate-the-upload">Step 3: Initiate the upload</a> for complete instructions.)
|
|
235
255
|
#
|
|
236
256
|
#
|
|
237
257
|
# 4. Once uploaded, the media undergoes processing and is assigned a unique ID for tracking. Retain this `uploadId` for any future operations related to this upload.
|
|
238
258
|
#
|
|
239
259
|
#
|
|
240
260
|
#
|
|
241
|
-
# After uploading, you can use the <a href="https://
|
|
261
|
+
# After uploading, you can use the <a href="https://fastpix.com/docs/video-on-demand-api/manage-videos/get-media">Get Media by ID</a> endpoint to check the status of the uploaded media asset and see if it has transitioned to a `Ready` status for playback.
|
|
242
262
|
#
|
|
243
|
-
# To notify your application about the status of this API request check for the webhooks for <a href="https://
|
|
263
|
+
# To notify your application about the status of this API request check for the webhooks for <a href="https://fastpix.com/docs/webhooks/webhook-event-reference#media-related-events">media related events</a>.
|
|
244
264
|
#
|
|
245
265
|
#
|
|
246
266
|
# #### Example
|
|
247
267
|
#
|
|
248
268
|
# A social media platform allows users to upload video content directly from their phones or computers. This endpoint facilitates the upload process. For example, if you are developing a video-sharing app where users can upload short clips from their mobile devices, this endpoint enables them to select a video, upload it to the platform.
|
|
249
269
|
#
|
|
250
|
-
# Related guide: <a href="https://
|
|
270
|
+
# Related guide: <a href="https://fastpix.com/docs/upload-videos/upload-videos-from-device">Upload videos directly</a>
|
|
251
271
|
#
|
|
252
272
|
url, params = @sdk_configuration.get_server_details
|
|
253
273
|
base_url = Utils.template_url(url, params)
|
|
@@ -256,16 +276,8 @@ module FastpixClient
|
|
|
256
276
|
headers = T.cast(headers, T::Hash[String, String])
|
|
257
277
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
|
|
258
278
|
headers['content-type'] = req_content_type
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if form
|
|
262
|
-
body = Utils.encode_form(form)
|
|
263
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
264
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
265
|
-
else
|
|
266
|
-
body = data
|
|
267
|
-
end
|
|
268
|
-
headers['Accept'] = 'application/json'
|
|
279
|
+
body = encode_request_body(req_content_type, data, form)
|
|
280
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
269
281
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
270
282
|
|
|
271
283
|
security = @sdk_configuration.security_source&.call
|
|
@@ -305,32 +317,12 @@ module FastpixClient
|
|
|
305
317
|
rescue StandardError => e
|
|
306
318
|
error = e
|
|
307
319
|
ensure
|
|
308
|
-
|
|
309
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
310
|
-
error: error,
|
|
311
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
312
|
-
hook_ctx: hook_ctx
|
|
313
|
-
),
|
|
314
|
-
response: http_response
|
|
315
|
-
)
|
|
316
|
-
else
|
|
317
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
318
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
319
|
-
hook_ctx: hook_ctx
|
|
320
|
-
),
|
|
321
|
-
response: http_response
|
|
322
|
-
)
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
if http_response.nil?
|
|
326
|
-
raise error if !error.nil?
|
|
327
|
-
raise 'no response'
|
|
328
|
-
end
|
|
320
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
329
321
|
end
|
|
330
322
|
|
|
331
323
|
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
332
324
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
333
|
-
if Utils.match_content_type(content_type,
|
|
325
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
334
326
|
http_response = @sdk_configuration.hooks.after_success(
|
|
335
327
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
336
328
|
hook_ctx: hook_ctx
|
|
@@ -348,14 +340,14 @@ module FastpixClient
|
|
|
348
340
|
|
|
349
341
|
return response
|
|
350
342
|
else
|
|
351
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
343
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
352
344
|
end
|
|
353
345
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
354
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
346
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
355
347
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
356
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
348
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
357
349
|
else
|
|
358
|
-
if Utils.match_content_type(content_type,
|
|
350
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
359
351
|
http_response = @sdk_configuration.hooks.after_success(
|
|
360
352
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
361
353
|
hook_ctx: hook_ctx
|
|
@@ -373,7 +365,7 @@ module FastpixClient
|
|
|
373
365
|
|
|
374
366
|
return response
|
|
375
367
|
else
|
|
376
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
368
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
377
369
|
end
|
|
378
370
|
end
|
|
379
371
|
end
|
|
@@ -14,6 +14,57 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class LivePlayback
|
|
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
|
+
UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
|
|
23
|
+
USER_AGENT_HEADER = 'user-agent'
|
|
24
|
+
|
|
25
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
26
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
27
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
28
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
29
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
30
|
+
error: error,
|
|
31
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
32
|
+
hook_ctx: hook_ctx
|
|
33
|
+
),
|
|
34
|
+
response: http_response
|
|
35
|
+
)
|
|
36
|
+
else
|
|
37
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
38
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
39
|
+
hook_ctx: hook_ctx
|
|
40
|
+
),
|
|
41
|
+
response: http_response
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if http_response.nil?
|
|
46
|
+
raise error unless error.nil?
|
|
47
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
http_response
|
|
51
|
+
end
|
|
52
|
+
private :apply_after_request_hooks
|
|
53
|
+
|
|
54
|
+
# Encodes the request body based on its serialized content type.
|
|
55
|
+
sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
|
|
56
|
+
def encode_request_body(req_content_type, data, form)
|
|
57
|
+
raise ArgumentError, 'request body is required' if data.nil? && form.nil?
|
|
58
|
+
|
|
59
|
+
if form
|
|
60
|
+
Utils.encode_form(form)
|
|
61
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
62
|
+
URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
63
|
+
else
|
|
64
|
+
data
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
private :encode_request_body
|
|
17
68
|
|
|
18
69
|
# Operations for live stream playback management
|
|
19
70
|
|
|
@@ -65,17 +116,9 @@ module FastpixClient
|
|
|
65
116
|
headers = T.cast(headers, T::Hash[String, String])
|
|
66
117
|
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
67
118
|
headers['content-type'] = req_content_type
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
body = Utils.encode_form(form)
|
|
72
|
-
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
|
73
|
-
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
74
|
-
else
|
|
75
|
-
body = data
|
|
76
|
-
end
|
|
77
|
-
headers['Accept'] = 'application/json'
|
|
78
|
-
headers['user-agent'] = @sdk_configuration.user_agent
|
|
119
|
+
body = encode_request_body(req_content_type, data, form)
|
|
120
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
121
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
79
122
|
|
|
80
123
|
security = @sdk_configuration.security_source&.call
|
|
81
124
|
|
|
@@ -114,32 +157,12 @@ module FastpixClient
|
|
|
114
157
|
rescue StandardError => e
|
|
115
158
|
error = e
|
|
116
159
|
ensure
|
|
117
|
-
|
|
118
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
119
|
-
error: error,
|
|
120
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
121
|
-
hook_ctx: hook_ctx
|
|
122
|
-
),
|
|
123
|
-
response: http_response
|
|
124
|
-
)
|
|
125
|
-
else
|
|
126
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
127
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
128
|
-
hook_ctx: hook_ctx
|
|
129
|
-
),
|
|
130
|
-
response: http_response
|
|
131
|
-
)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
if http_response.nil?
|
|
135
|
-
raise error if !error.nil?
|
|
136
|
-
raise 'no response'
|
|
137
|
-
end
|
|
160
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
138
161
|
end
|
|
139
162
|
|
|
140
|
-
content_type = http_response.headers.fetch(
|
|
163
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
141
164
|
if Utils.match_status_code(http_response.status, ['201'])
|
|
142
|
-
if Utils.match_content_type(content_type,
|
|
165
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
143
166
|
http_response = @sdk_configuration.hooks.after_success(
|
|
144
167
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
145
168
|
hook_ctx: hook_ctx
|
|
@@ -157,14 +180,14 @@ module FastpixClient
|
|
|
157
180
|
|
|
158
181
|
return response
|
|
159
182
|
else
|
|
160
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
183
|
+
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
|
|
161
184
|
end
|
|
162
185
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
163
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
186
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
164
187
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
165
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
188
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
166
189
|
else
|
|
167
|
-
if Utils.match_content_type(content_type,
|
|
190
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
168
191
|
http_response = @sdk_configuration.hooks.after_success(
|
|
169
192
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
170
193
|
hook_ctx: hook_ctx
|
|
@@ -182,7 +205,7 @@ module FastpixClient
|
|
|
182
205
|
|
|
183
206
|
return response
|
|
184
207
|
else
|
|
185
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
208
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
186
209
|
end
|
|
187
210
|
end
|
|
188
211
|
end
|
|
@@ -210,8 +233,8 @@ module FastpixClient
|
|
|
210
233
|
headers = {}
|
|
211
234
|
headers = T.cast(headers, T::Hash[String, String])
|
|
212
235
|
query_params = Utils.get_query_params(Models::Operations::DeletePlaybackIdOfStreamRequest, request, nil)
|
|
213
|
-
headers['Accept'] =
|
|
214
|
-
headers[
|
|
236
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
237
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
215
238
|
|
|
216
239
|
security = @sdk_configuration.security_source&.call
|
|
217
240
|
|
|
@@ -250,32 +273,12 @@ module FastpixClient
|
|
|
250
273
|
rescue StandardError => e
|
|
251
274
|
error = e
|
|
252
275
|
ensure
|
|
253
|
-
|
|
254
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
255
|
-
error: error,
|
|
256
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
257
|
-
hook_ctx: hook_ctx
|
|
258
|
-
),
|
|
259
|
-
response: http_response
|
|
260
|
-
)
|
|
261
|
-
else
|
|
262
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
263
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
264
|
-
hook_ctx: hook_ctx
|
|
265
|
-
),
|
|
266
|
-
response: http_response
|
|
267
|
-
)
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
if http_response.nil?
|
|
271
|
-
raise error if !error.nil?
|
|
272
|
-
raise 'no response'
|
|
273
|
-
end
|
|
276
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
274
277
|
end
|
|
275
278
|
|
|
276
|
-
content_type = http_response.headers.fetch(
|
|
279
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
277
280
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
278
|
-
if Utils.match_content_type(content_type,
|
|
281
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
279
282
|
http_response = @sdk_configuration.hooks.after_success(
|
|
280
283
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
281
284
|
hook_ctx: hook_ctx
|
|
@@ -293,14 +296,14 @@ module FastpixClient
|
|
|
293
296
|
|
|
294
297
|
return response
|
|
295
298
|
else
|
|
296
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
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_ERROR
|
|
297
300
|
end
|
|
298
301
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
299
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
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
|
|
300
303
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
301
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
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
|
|
302
305
|
else
|
|
303
|
-
if Utils.match_content_type(content_type,
|
|
306
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
304
307
|
http_response = @sdk_configuration.hooks.after_success(
|
|
305
308
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
306
309
|
hook_ctx: hook_ctx
|
|
@@ -318,7 +321,7 @@ module FastpixClient
|
|
|
318
321
|
|
|
319
322
|
return response
|
|
320
323
|
else
|
|
321
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
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_ERROR
|
|
322
325
|
end
|
|
323
326
|
end
|
|
324
327
|
end
|
|
@@ -345,8 +348,8 @@ module FastpixClient
|
|
|
345
348
|
)
|
|
346
349
|
headers = {}
|
|
347
350
|
headers = T.cast(headers, T::Hash[String, String])
|
|
348
|
-
headers['Accept'] =
|
|
349
|
-
headers[
|
|
351
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
352
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
350
353
|
|
|
351
354
|
security = @sdk_configuration.security_source&.call
|
|
352
355
|
|
|
@@ -384,32 +387,12 @@ module FastpixClient
|
|
|
384
387
|
rescue StandardError => e
|
|
385
388
|
error = e
|
|
386
389
|
ensure
|
|
387
|
-
|
|
388
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
389
|
-
error: error,
|
|
390
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
391
|
-
hook_ctx: hook_ctx
|
|
392
|
-
),
|
|
393
|
-
response: http_response
|
|
394
|
-
)
|
|
395
|
-
else
|
|
396
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
397
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
398
|
-
hook_ctx: hook_ctx
|
|
399
|
-
),
|
|
400
|
-
response: http_response
|
|
401
|
-
)
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
if http_response.nil?
|
|
405
|
-
raise error if !error.nil?
|
|
406
|
-
raise 'no response'
|
|
407
|
-
end
|
|
390
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
408
391
|
end
|
|
409
392
|
|
|
410
|
-
content_type = http_response.headers.fetch(
|
|
393
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
411
394
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
412
|
-
if Utils.match_content_type(content_type,
|
|
395
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
413
396
|
http_response = @sdk_configuration.hooks.after_success(
|
|
414
397
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
415
398
|
hook_ctx: hook_ctx
|
|
@@ -427,14 +410,14 @@ module FastpixClient
|
|
|
427
410
|
|
|
428
411
|
return response
|
|
429
412
|
else
|
|
430
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
413
|
+
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
|
|
431
414
|
end
|
|
432
415
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
433
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
416
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
434
417
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
435
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
418
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
436
419
|
else
|
|
437
|
-
if Utils.match_content_type(content_type,
|
|
420
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
438
421
|
http_response = @sdk_configuration.hooks.after_success(
|
|
439
422
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
440
423
|
hook_ctx: hook_ctx
|
|
@@ -452,7 +435,7 @@ module FastpixClient
|
|
|
452
435
|
|
|
453
436
|
return response
|
|
454
437
|
else
|
|
455
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
438
|
+
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
|
|
456
439
|
end
|
|
457
440
|
end
|
|
458
441
|
end
|