fastpixapi 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) 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 +51 -58
  6. data/lib/fastpix_client/drm_configurations.rb +49 -56
  7. data/lib/fastpix_client/errors.rb +35 -24
  8. data/lib/fastpix_client/fastpixapi.rb +2 -4
  9. data/lib/fastpix_client/in_video_ai_features.rb +100 -160
  10. data/lib/fastpix_client/input_video.rb +66 -74
  11. data/lib/fastpix_client/live_playback.rb +82 -99
  12. data/lib/fastpix_client/manage_live_stream.rb +136 -252
  13. data/lib/fastpix_client/manage_videos.rb +228 -543
  14. data/lib/fastpix_client/metrics.rb +76 -120
  15. data/lib/fastpix_client/models/components/createlivestreamresponsedto.rb +10 -18
  16. data/lib/fastpix_client/models/components/createmediarequest.rb +9 -18
  17. data/lib/fastpix_client/models/components/getallmediaresponse.rb +13 -29
  18. data/lib/fastpix_client/models/components/getcreatelivestreamresponsedto.rb +9 -20
  19. data/lib/fastpix_client/models/components/getmediaresponse.rb +13 -29
  20. data/lib/fastpix_client/models/components/live_media_clips.rb +9 -21
  21. data/lib/fastpix_client/models/components/media.rb +11 -26
  22. data/lib/fastpix_client/models/components/patchresponsedata.rb +9 -18
  23. data/lib/fastpix_client/models/components/sourceaccessmedia.rb +11 -26
  24. data/lib/fastpix_client/models/components/update_media.rb +11 -26
  25. data/lib/fastpix_client/models/components/views.rb +51 -124
  26. data/lib/fastpix_client/models/errors/empty_response_error.rb +15 -0
  27. data/lib/fastpix_client/models/errors.rb +1 -0
  28. data/lib/fastpix_client/models/operations/push_media_settings.rb +9 -20
  29. data/lib/fastpix_client/playback.rb +122 -213
  30. data/lib/fastpix_client/playlist.rb +150 -296
  31. data/lib/fastpix_client/sdk_hooks/registration.rb +2 -2
  32. data/lib/fastpix_client/sdk_hooks/types.rb +4 -0
  33. data/lib/fastpix_client/sdkconfiguration.rb +3 -3
  34. data/lib/fastpix_client/signing_keys.rb +76 -120
  35. data/lib/fastpix_client/simulcast_stream.rb +97 -141
  36. data/lib/fastpix_client/start_live_stream.rb +51 -33
  37. data/lib/fastpix_client/utils/forms.rb +97 -101
  38. data/lib/fastpix_client/utils/headers.rb +44 -34
  39. data/lib/fastpix_client/utils/query_params.rb +39 -29
  40. data/lib/fastpix_client/utils/request_bodies.rb +4 -8
  41. data/lib/fastpix_client/utils/security.rb +30 -18
  42. data/lib/fastpix_client/utils/url.rb +83 -60
  43. data/lib/fastpix_client/utils/utils.rb +19 -37
  44. data/lib/fastpix_client/views.rb +66 -90
  45. data/lib/fastpixapi.rb +10 -10
  46. data/lib/openssl_patch.rb +24 -24
  47. metadata +3 -2
@@ -14,6 +14,58 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class ManageLiveStream
16
16
  extend T::Sig
17
+
18
+ API_ERROR_OCCURRED = 'API error occurred'
19
+ CONTENT_TYPE_HEADER = 'Content-Type'
20
+ CONTENT_TYPE_JSON = 'application/json'
21
+ DEFAULT_CONTENT_TYPE = 'application/octet-stream'
22
+ STREAM_PATH = '/live/streams/{streamId}'
23
+ UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
24
+ USER_AGENT_HEADER = 'user-agent'
25
+
26
+ # Applies the SDK after-request hooks and ensures a usable response is present.
27
+ sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
28
+ def apply_after_request_hooks(http_response, error, hook_ctx)
29
+ if http_response.nil? || Utils.error_status?(http_response.status)
30
+ http_response = @sdk_configuration.hooks.after_error(
31
+ error: error,
32
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
33
+ hook_ctx: hook_ctx
34
+ ),
35
+ response: http_response
36
+ )
37
+ else
38
+ http_response = @sdk_configuration.hooks.after_success(
39
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
40
+ hook_ctx: hook_ctx
41
+ ),
42
+ response: http_response
43
+ )
44
+ end
45
+
46
+ if http_response.nil?
47
+ raise error unless error.nil?
48
+ raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
49
+ end
50
+
51
+ http_response
52
+ end
53
+ private :apply_after_request_hooks
54
+
55
+ # Encodes the request body based on its serialized content type.
56
+ sig { params(req_content_type: T.nilable(String), data: T.untyped, form: T.untyped).returns(T.untyped) }
57
+ def encode_request_body(req_content_type, data, form)
58
+ raise ArgumentError, 'request body is required' if data.nil? && form.nil?
59
+
60
+ if form
61
+ Utils.encode_form(form)
62
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
63
+ URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
64
+ else
65
+ data
66
+ end
67
+ end
68
+ private :encode_request_body
17
69
 
18
70
  # Operations for managing live streams
19
71
 
@@ -59,8 +111,8 @@ module FastpixClient
59
111
  headers = {}
60
112
  headers = T.cast(headers, T::Hash[String, String])
61
113
  query_params = Utils.get_query_params(Models::Operations::GetAllStreamsRequest, request, nil)
62
- headers['Accept'] = 'application/json'
63
- headers['user-agent'] = @sdk_configuration.user_agent
114
+ headers['Accept'] = CONTENT_TYPE_JSON
115
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
64
116
 
65
117
  security = @sdk_configuration.security_source&.call
66
118
 
@@ -99,32 +151,12 @@ module FastpixClient
99
151
  rescue StandardError => e
100
152
  error = e
101
153
  ensure
102
- if http_response.nil? || Utils.error_status?(http_response.status)
103
- http_response = @sdk_configuration.hooks.after_error(
104
- error: error,
105
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
106
- hook_ctx: hook_ctx
107
- ),
108
- response: http_response
109
- )
110
- else
111
- http_response = @sdk_configuration.hooks.after_success(
112
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
113
- hook_ctx: hook_ctx
114
- ),
115
- response: http_response
116
- )
117
- end
118
-
119
- if http_response.nil?
120
- raise error if !error.nil?
121
- raise 'no response'
122
- end
154
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
123
155
  end
124
156
 
125
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
157
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
126
158
  if Utils.match_status_code(http_response.status, ['200'])
127
- if Utils.match_content_type(content_type, 'application/json')
159
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
128
160
  http_response = @sdk_configuration.hooks.after_success(
129
161
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
130
162
  hook_ctx: hook_ctx
@@ -142,14 +174,14 @@ module FastpixClient
142
174
 
143
175
  return response
144
176
  else
145
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
177
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
146
178
  end
147
179
  elsif Utils.match_status_code(http_response.status, ['4XX'])
148
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
180
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
149
181
  elsif Utils.match_status_code(http_response.status, ['5XX'])
150
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
182
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
151
183
  else
152
- if Utils.match_content_type(content_type, 'application/json')
184
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
153
185
  http_response = @sdk_configuration.hooks.after_success(
154
186
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
155
187
  hook_ctx: hook_ctx
@@ -167,7 +199,7 @@ module FastpixClient
167
199
 
168
200
  return response
169
201
  else
170
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
202
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
171
203
  end
172
204
  end
173
205
  end
@@ -198,8 +230,8 @@ module FastpixClient
198
230
  )
199
231
  headers = {}
200
232
  headers = T.cast(headers, T::Hash[String, String])
201
- headers['Accept'] = 'application/json'
202
- headers['user-agent'] = @sdk_configuration.user_agent
233
+ headers['Accept'] = CONTENT_TYPE_JSON
234
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
203
235
 
204
236
  security = @sdk_configuration.security_source&.call
205
237
 
@@ -237,32 +269,12 @@ module FastpixClient
237
269
  rescue StandardError => e
238
270
  error = e
239
271
  ensure
240
- if http_response.nil? || Utils.error_status?(http_response.status)
241
- http_response = @sdk_configuration.hooks.after_error(
242
- error: error,
243
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
244
- hook_ctx: hook_ctx
245
- ),
246
- response: http_response
247
- )
248
- else
249
- http_response = @sdk_configuration.hooks.after_success(
250
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
251
- hook_ctx: hook_ctx
252
- ),
253
- response: http_response
254
- )
255
- end
256
-
257
- if http_response.nil?
258
- raise error if !error.nil?
259
- raise 'no response'
260
- end
272
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
261
273
  end
262
274
 
263
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
275
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
264
276
  if Utils.match_status_code(http_response.status, ['200'])
265
- if Utils.match_content_type(content_type, 'application/json')
277
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
266
278
  http_response = @sdk_configuration.hooks.after_success(
267
279
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
268
280
  hook_ctx: hook_ctx
@@ -280,14 +292,14 @@ module FastpixClient
280
292
 
281
293
  return response
282
294
  else
283
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
295
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
284
296
  end
285
297
  elsif Utils.match_status_code(http_response.status, ['4XX'])
286
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
298
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
287
299
  elsif Utils.match_status_code(http_response.status, ['5XX'])
288
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
300
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
289
301
  else
290
- if Utils.match_content_type(content_type, 'application/json')
302
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
291
303
  http_response = @sdk_configuration.hooks.after_success(
292
304
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
293
305
  hook_ctx: hook_ctx
@@ -305,7 +317,7 @@ module FastpixClient
305
317
 
306
318
  return response
307
319
  else
308
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
320
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
309
321
  end
310
322
  end
311
323
  end
@@ -329,13 +341,13 @@ module FastpixClient
329
341
  url = Utils.generate_url(
330
342
  Models::Operations::GetLiveStreamByIdRequest,
331
343
  base_url,
332
- '/live/streams/{streamId}',
344
+ STREAM_PATH,
333
345
  request
334
346
  )
335
347
  headers = {}
336
348
  headers = T.cast(headers, T::Hash[String, String])
337
- headers['Accept'] = 'application/json'
338
- headers['user-agent'] = @sdk_configuration.user_agent
349
+ headers['Accept'] = CONTENT_TYPE_JSON
350
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
339
351
 
340
352
  security = @sdk_configuration.security_source&.call
341
353
 
@@ -373,32 +385,12 @@ module FastpixClient
373
385
  rescue StandardError => e
374
386
  error = e
375
387
  ensure
376
- if http_response.nil? || Utils.error_status?(http_response.status)
377
- http_response = @sdk_configuration.hooks.after_error(
378
- error: error,
379
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
380
- hook_ctx: hook_ctx
381
- ),
382
- response: http_response
383
- )
384
- else
385
- http_response = @sdk_configuration.hooks.after_success(
386
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
387
- hook_ctx: hook_ctx
388
- ),
389
- response: http_response
390
- )
391
- end
392
-
393
- if http_response.nil?
394
- raise error if !error.nil?
395
- raise 'no response'
396
- end
388
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
397
389
  end
398
390
 
399
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
391
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
400
392
  if Utils.match_status_code(http_response.status, ['200'])
401
- if Utils.match_content_type(content_type, 'application/json')
393
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
402
394
  http_response = @sdk_configuration.hooks.after_success(
403
395
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
404
396
  hook_ctx: hook_ctx
@@ -416,14 +408,14 @@ module FastpixClient
416
408
 
417
409
  return response
418
410
  else
419
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
411
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
420
412
  end
421
413
  elsif Utils.match_status_code(http_response.status, ['4XX'])
422
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
414
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
423
415
  elsif Utils.match_status_code(http_response.status, ['5XX'])
424
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
416
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
425
417
  else
426
- if Utils.match_content_type(content_type, 'application/json')
418
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
427
419
  http_response = @sdk_configuration.hooks.after_success(
428
420
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
429
421
  hook_ctx: hook_ctx
@@ -441,7 +433,7 @@ module FastpixClient
441
433
 
442
434
  return response
443
435
  else
444
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
436
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
445
437
  end
446
438
  end
447
439
  end
@@ -468,13 +460,13 @@ module FastpixClient
468
460
  url = Utils.generate_url(
469
461
  Models::Operations::DeleteLiveStreamRequest,
470
462
  base_url,
471
- '/live/streams/{streamId}',
463
+ STREAM_PATH,
472
464
  request
473
465
  )
474
466
  headers = {}
475
467
  headers = T.cast(headers, T::Hash[String, String])
476
- headers['Accept'] = 'application/json'
477
- headers['user-agent'] = @sdk_configuration.user_agent
468
+ headers['Accept'] = CONTENT_TYPE_JSON
469
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
478
470
 
479
471
  security = @sdk_configuration.security_source&.call
480
472
 
@@ -512,32 +504,12 @@ module FastpixClient
512
504
  rescue StandardError => e
513
505
  error = e
514
506
  ensure
515
- if http_response.nil? || Utils.error_status?(http_response.status)
516
- http_response = @sdk_configuration.hooks.after_error(
517
- error: error,
518
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
519
- hook_ctx: hook_ctx
520
- ),
521
- response: http_response
522
- )
523
- else
524
- http_response = @sdk_configuration.hooks.after_success(
525
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
526
- hook_ctx: hook_ctx
527
- ),
528
- response: http_response
529
- )
530
- end
531
-
532
- if http_response.nil?
533
- raise error if !error.nil?
534
- raise 'no response'
535
- end
507
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
536
508
  end
537
509
 
538
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
510
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
539
511
  if Utils.match_status_code(http_response.status, ['200'])
540
- if Utils.match_content_type(content_type, 'application/json')
512
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
541
513
  http_response = @sdk_configuration.hooks.after_success(
542
514
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
543
515
  hook_ctx: hook_ctx
@@ -555,14 +527,14 @@ module FastpixClient
555
527
 
556
528
  return response
557
529
  else
558
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
530
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
559
531
  end
560
532
  elsif Utils.match_status_code(http_response.status, ['4XX'])
561
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
533
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
562
534
  elsif Utils.match_status_code(http_response.status, ['5XX'])
563
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
535
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
564
536
  else
565
- if Utils.match_content_type(content_type, 'application/json')
537
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
566
538
  http_response = @sdk_configuration.hooks.after_success(
567
539
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
568
540
  hook_ctx: hook_ctx
@@ -580,7 +552,7 @@ module FastpixClient
580
552
 
581
553
  return response
582
554
  else
583
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
555
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
584
556
  end
585
557
  end
586
558
  end
@@ -610,24 +582,16 @@ module FastpixClient
610
582
  url = Utils.generate_url(
611
583
  Models::Operations::UpdateLiveStreamRequest,
612
584
  base_url,
613
- '/live/streams/{streamId}',
585
+ STREAM_PATH,
614
586
  request
615
587
  )
616
588
  headers = {}
617
589
  headers = T.cast(headers, T::Hash[String, String])
618
590
  req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
619
591
  headers['content-type'] = req_content_type
620
- raise StandardError, 'request body is required' if data.nil? && form.nil?
621
-
622
- if form
623
- body = Utils.encode_form(form)
624
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
625
- body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
626
- else
627
- body = data
628
- end
629
- headers['Accept'] = 'application/json'
630
- headers['user-agent'] = @sdk_configuration.user_agent
592
+ body = encode_request_body(req_content_type, data, form)
593
+ headers['Accept'] = CONTENT_TYPE_JSON
594
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
631
595
 
632
596
  security = @sdk_configuration.security_source&.call
633
597
 
@@ -666,32 +630,12 @@ module FastpixClient
666
630
  rescue StandardError => e
667
631
  error = e
668
632
  ensure
669
- if http_response.nil? || Utils.error_status?(http_response.status)
670
- http_response = @sdk_configuration.hooks.after_error(
671
- error: error,
672
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
673
- hook_ctx: hook_ctx
674
- ),
675
- response: http_response
676
- )
677
- else
678
- http_response = @sdk_configuration.hooks.after_success(
679
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
680
- hook_ctx: hook_ctx
681
- ),
682
- response: http_response
683
- )
684
- end
685
-
686
- if http_response.nil?
687
- raise error if !error.nil?
688
- raise 'no response'
689
- end
633
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
690
634
  end
691
635
 
692
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
636
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
693
637
  if Utils.match_status_code(http_response.status, ['200'])
694
- if Utils.match_content_type(content_type, 'application/json')
638
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
695
639
  http_response = @sdk_configuration.hooks.after_success(
696
640
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
697
641
  hook_ctx: hook_ctx
@@ -709,14 +653,14 @@ module FastpixClient
709
653
 
710
654
  return response
711
655
  else
712
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
656
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
713
657
  end
714
658
  elsif Utils.match_status_code(http_response.status, ['4XX'])
715
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
659
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
716
660
  elsif Utils.match_status_code(http_response.status, ['5XX'])
717
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
661
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
718
662
  else
719
- if Utils.match_content_type(content_type, 'application/json')
663
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
720
664
  http_response = @sdk_configuration.hooks.after_success(
721
665
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
722
666
  hook_ctx: hook_ctx
@@ -734,7 +678,7 @@ module FastpixClient
734
678
 
735
679
  return response
736
680
  else
737
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
681
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
738
682
  end
739
683
  end
740
684
  end
@@ -767,8 +711,8 @@ module FastpixClient
767
711
  )
768
712
  headers = {}
769
713
  headers = T.cast(headers, T::Hash[String, String])
770
- headers['Accept'] = 'application/json'
771
- headers['user-agent'] = @sdk_configuration.user_agent
714
+ headers['Accept'] = CONTENT_TYPE_JSON
715
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
772
716
 
773
717
  security = @sdk_configuration.security_source&.call
774
718
 
@@ -806,32 +750,12 @@ module FastpixClient
806
750
  rescue StandardError => e
807
751
  error = e
808
752
  ensure
809
- if http_response.nil? || Utils.error_status?(http_response.status)
810
- http_response = @sdk_configuration.hooks.after_error(
811
- error: error,
812
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
813
- hook_ctx: hook_ctx
814
- ),
815
- response: http_response
816
- )
817
- else
818
- http_response = @sdk_configuration.hooks.after_success(
819
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
820
- hook_ctx: hook_ctx
821
- ),
822
- response: http_response
823
- )
824
- end
825
-
826
- if http_response.nil?
827
- raise error if !error.nil?
828
- raise 'no response'
829
- end
753
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
830
754
  end
831
755
 
832
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
756
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
833
757
  if Utils.match_status_code(http_response.status, ['200'])
834
- if Utils.match_content_type(content_type, 'application/json')
758
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
835
759
  http_response = @sdk_configuration.hooks.after_success(
836
760
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
837
761
  hook_ctx: hook_ctx
@@ -849,14 +773,14 @@ module FastpixClient
849
773
 
850
774
  return response
851
775
  else
852
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
776
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
853
777
  end
854
778
  elsif Utils.match_status_code(http_response.status, ['4XX'])
855
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
779
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
856
780
  elsif Utils.match_status_code(http_response.status, ['5XX'])
857
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
781
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
858
782
  else
859
- if Utils.match_content_type(content_type, 'application/json')
783
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
860
784
  http_response = @sdk_configuration.hooks.after_success(
861
785
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
862
786
  hook_ctx: hook_ctx
@@ -874,7 +798,7 @@ module FastpixClient
874
798
 
875
799
  return response
876
800
  else
877
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
801
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
878
802
  end
879
803
  end
880
804
  end
@@ -905,8 +829,8 @@ module FastpixClient
905
829
  )
906
830
  headers = {}
907
831
  headers = T.cast(headers, T::Hash[String, String])
908
- headers['Accept'] = 'application/json'
909
- headers['user-agent'] = @sdk_configuration.user_agent
832
+ headers['Accept'] = CONTENT_TYPE_JSON
833
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
910
834
 
911
835
  security = @sdk_configuration.security_source&.call
912
836
 
@@ -944,32 +868,12 @@ module FastpixClient
944
868
  rescue StandardError => e
945
869
  error = e
946
870
  ensure
947
- if http_response.nil? || Utils.error_status?(http_response.status)
948
- http_response = @sdk_configuration.hooks.after_error(
949
- error: error,
950
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
951
- hook_ctx: hook_ctx
952
- ),
953
- response: http_response
954
- )
955
- else
956
- http_response = @sdk_configuration.hooks.after_success(
957
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
958
- hook_ctx: hook_ctx
959
- ),
960
- response: http_response
961
- )
962
- end
963
-
964
- if http_response.nil?
965
- raise error if !error.nil?
966
- raise 'no response'
967
- end
871
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
968
872
  end
969
873
 
970
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
874
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
971
875
  if Utils.match_status_code(http_response.status, ['200'])
972
- if Utils.match_content_type(content_type, 'application/json')
876
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
973
877
  http_response = @sdk_configuration.hooks.after_success(
974
878
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
975
879
  hook_ctx: hook_ctx
@@ -987,14 +891,14 @@ module FastpixClient
987
891
 
988
892
  return response
989
893
  else
990
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
894
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
991
895
  end
992
896
  elsif Utils.match_status_code(http_response.status, ['4XX'])
993
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
897
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
994
898
  elsif Utils.match_status_code(http_response.status, ['5XX'])
995
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
899
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
996
900
  else
997
- if Utils.match_content_type(content_type, 'application/json')
901
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
998
902
  http_response = @sdk_configuration.hooks.after_success(
999
903
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1000
904
  hook_ctx: hook_ctx
@@ -1012,7 +916,7 @@ module FastpixClient
1012
916
 
1013
917
  return response
1014
918
  else
1015
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
919
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
1016
920
  end
1017
921
  end
1018
922
  end
@@ -1045,8 +949,8 @@ module FastpixClient
1045
949
  )
1046
950
  headers = {}
1047
951
  headers = T.cast(headers, T::Hash[String, String])
1048
- headers['Accept'] = 'application/json'
1049
- headers['user-agent'] = @sdk_configuration.user_agent
952
+ headers['Accept'] = CONTENT_TYPE_JSON
953
+ headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
1050
954
 
1051
955
  security = @sdk_configuration.security_source&.call
1052
956
 
@@ -1084,32 +988,12 @@ module FastpixClient
1084
988
  rescue StandardError => e
1085
989
  error = e
1086
990
  ensure
1087
- if http_response.nil? || Utils.error_status?(http_response.status)
1088
- http_response = @sdk_configuration.hooks.after_error(
1089
- error: error,
1090
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
1091
- hook_ctx: hook_ctx
1092
- ),
1093
- response: http_response
1094
- )
1095
- else
1096
- http_response = @sdk_configuration.hooks.after_success(
1097
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1098
- hook_ctx: hook_ctx
1099
- ),
1100
- response: http_response
1101
- )
1102
- end
1103
-
1104
- if http_response.nil?
1105
- raise error if !error.nil?
1106
- raise 'no response'
1107
- end
991
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
1108
992
  end
1109
993
 
1110
- content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
994
+ content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
1111
995
  if Utils.match_status_code(http_response.status, ['200'])
1112
- if Utils.match_content_type(content_type, 'application/json')
996
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1113
997
  http_response = @sdk_configuration.hooks.after_success(
1114
998
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1115
999
  hook_ctx: hook_ctx
@@ -1127,14 +1011,14 @@ module FastpixClient
1127
1011
 
1128
1012
  return response
1129
1013
  else
1130
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
1014
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
1131
1015
  end
1132
1016
  elsif Utils.match_status_code(http_response.status, ['4XX'])
1133
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1017
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1134
1018
  elsif Utils.match_status_code(http_response.status, ['5XX'])
1135
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
1019
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
1136
1020
  else
1137
- if Utils.match_content_type(content_type, 'application/json')
1021
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
1138
1022
  http_response = @sdk_configuration.hooks.after_success(
1139
1023
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1140
1024
  hook_ctx: hook_ctx
@@ -1152,7 +1036,7 @@ module FastpixClient
1152
1036
 
1153
1037
  return response
1154
1038
  else
1155
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
1039
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
1156
1040
  end
1157
1041
  end
1158
1042
  end