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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b15d42c270409c62322989c4699c7be3300b754eba4efb2249333debaf4e205
4
- data.tar.gz: 851361def468046ea55fb4af42b18ef0c2207c3a957774eb0025b6c87e906010
3
+ metadata.gz: b6ae3027c5f37f777cf9a979ddd36123a1bb1e93e0ff5f2a9b70a4d27928e73c
4
+ data.tar.gz: c097e0cfb9dc6c84144740416b8a7bdc7e476ca55dab42714ca19db73d7d91bc
5
5
  SHA512:
6
- metadata.gz: 025c583ba23437e0274f656ce88c368712642991ce7294296c511eea7b545b4dca8fadd697e0c2a8f57f34c2d95a3c889a29120487d8ebd795f94d44d7a2f24a
7
- data.tar.gz: 5b8b2e17a03b9957e54f6cbe648774dda1e0182567a959164fdabedc7da07d856289ef1ef868d84140693d35b821751a744f87f1f6b79722a7f56682e4bfc487
6
+ metadata.gz: 070f775ab0edfac491bb4667b3b94f4f031e67fc460435ab227e9821c389a7a49ab4a913c8b97a60069849d2e61f13dbf3e2d54c3ea40759aaf296ab02d44131
7
+ data.tar.gz: dd6640b41c25a8dd2df43f4790b3506f1b35b285362073343bc856bed854de6347304b6edb7e5a5f119eb0666ac22c7427b486c2b50a949e76b6b403ce1d07aa
@@ -48,6 +48,7 @@ module Crystalline
48
48
  begin
49
49
  value = JSON.parse(value)
50
50
  rescue TypeError, JSON::ParserError
51
+ # Not valid JSON; keep the original value unchanged.
51
52
  end
52
53
  # rubocop:enable Lint/SuppressedException
53
54
  return value
@@ -84,54 +85,61 @@ module Crystalline
84
85
  # If field is nilable, and the value is not in the dict, just move to the next field
85
86
  next if value.nil?
86
87
 
87
- if Crystalline::Utils.arr? field_type
88
- inner_type = Crystalline::Utils.arr_of(field_type)
89
- unmarshalled_array = value.map { |f| unmarshal_single(inner_type, f, format_metadata) }
90
- to_build[key] = unmarshalled_array
91
- elsif Crystalline::Utils.hash? field_type
92
- val_type = Crystalline::Utils.hash_of(field_type)
93
-
94
- # rubocop:disable Style/HashTransformValues
95
- unmarshalled_hash = value.map { |k, v| [k, unmarshal_single(val_type, v, format_metadata)] }.to_h
96
- # rubocop:enable Style/HashTransformValues
97
- to_build[key] = unmarshalled_hash
98
- elsif Crystalline::Utils.union? field_type
99
- discriminator = field.metadata.fetch(:discriminator, nil)
100
- discriminator_mapping = field.metadata.fetch(:discriminator_mapping, nil)
101
- if !discriminator.nil?
102
- discriminator_value = value.fetch(discriminator)
103
- if !discriminator_mapping.nil?
104
- # Use explicit mapping from discriminator value to type
105
- type_to_deserialize = discriminator_mapping[discriminator_value]
106
- else
107
- # Fallback: try to match discriminator value against type name
108
- type_to_deserialize = Crystalline::Utils.get_union_types(field_type).find { |t| t.name.split('::').last == discriminator_value }
109
- end
110
- to_build[key] = Crystalline.unmarshal_json(value, type_to_deserialize)
88
+ result = unmarshal_field_value(field, field_type, value, format_metadata)
89
+ to_build[key] = result unless result.equal?(UNRESOLVED_UNION)
90
+ end
91
+ new(**to_build)
92
+ end
93
+
94
+ # Sentinel returned when a union value cannot be resolved to any member type,
95
+ # so the caller can leave the field unset (instead of assigning nil).
96
+ UNRESOLVED_UNION = Object.new
97
+
98
+ # Dispatches unmarshalling of a single field value based on its declared type.
99
+ def unmarshal_field_value(field, field_type, value, format_metadata)
100
+ if Crystalline::Utils.arr? field_type
101
+ inner_type = Crystalline::Utils.arr_of(field_type)
102
+ value.map { |f| unmarshal_single(inner_type, f, format_metadata) }
103
+ elsif Crystalline::Utils.hash? field_type
104
+ val_type = Crystalline::Utils.hash_of(field_type)
105
+ # rubocop:disable Style/HashTransformValues
106
+ value.map { |k, v| [k, unmarshal_single(val_type, v, format_metadata)] }.to_h
107
+ # rubocop:enable Style/HashTransformValues
108
+ elsif Crystalline::Utils.union? field_type
109
+ unmarshal_union(field, field_type, value)
110
+ elsif field_type.instance_of?(Class) && field_type.include?(::Crystalline::MetadataFields)
111
+ Crystalline.unmarshal_json(value, field_type)
112
+ else
113
+ unmarshal_single(field_type, value, format_metadata)
114
+ end
115
+ end
116
+
117
+ # Resolves a union-typed value, using a discriminator when present and otherwise
118
+ # trying each candidate type in turn. Returns UNRESOLVED_UNION if none match.
119
+ def unmarshal_union(field, field_type, value)
120
+ discriminator = field.metadata.fetch(:discriminator, nil)
121
+ unless discriminator.nil?
122
+ discriminator_mapping = field.metadata.fetch(:discriminator_mapping, nil)
123
+ discriminator_value = value.fetch(discriminator)
124
+ type_to_deserialize =
125
+ if discriminator_mapping.nil?
126
+ # Fallback: try to match discriminator value against type name
127
+ Crystalline::Utils.get_union_types(field_type).find { |t| t.name.split('::').last == discriminator_value }
111
128
  else
112
- union_types = Crystalline::Utils.get_union_types(field_type)
113
- union_types = union_types.sort_by { |klass| Crystalline.non_nilable_attr_count(klass) }
114
-
115
- union_types.each do |union_type|
116
- begin
117
- to_build[key] = Crystalline.unmarshal_json(value, union_type)
118
- rescue TypeError
119
- next
120
- rescue NoMethodError
121
- next
122
- rescue KeyError
123
- next
124
- end
125
- break
126
- end
129
+ # Use explicit mapping from discriminator value to type
130
+ discriminator_mapping[discriminator_value]
127
131
  end
128
- elsif field_type.instance_of?(Class) && field_type.include?(::Crystalline::MetadataFields)
129
- to_build[key] = Crystalline.unmarshal_json(value, field_type)
130
- else
131
- to_build[key] = unmarshal_single(field_type, value, format_metadata)
132
- end
132
+ return Crystalline.unmarshal_json(value, type_to_deserialize)
133
133
  end
134
- new(**to_build)
134
+
135
+ union_types = Crystalline::Utils.get_union_types(field_type)
136
+ union_types = union_types.sort_by { |klass| Crystalline.non_nilable_attr_count(klass) }
137
+ union_types.each do |union_type|
138
+ return Crystalline.unmarshal_json(value, union_type)
139
+ rescue TypeError, NoMethodError, KeyError
140
+ next
141
+ end
142
+ UNRESOLVED_UNION
135
143
  end
136
144
  end
137
145
 
@@ -150,9 +158,9 @@ module Crystalline
150
158
  end
151
159
 
152
160
  def field(field_name)
153
- fields.each do |f|
154
- return f if f.name == field_name
155
- end
161
+ # `|| fields` preserves the original each-loop behaviour of returning the
162
+ # full fields list when no field matches.
163
+ fields.find { |f| f.name == field_name } || fields
156
164
  end
157
165
 
158
166
  def marshal_single(field)
@@ -54,14 +54,14 @@ module Crystalline
54
54
  end
55
55
 
56
56
  module ClassMethods
57
- def enums(&blk)
57
+ def enums(&_blk)
58
58
  @mapping = {}
59
59
 
60
60
  yield
61
61
  constants(false).each do |const_name|
62
62
  instance = const_get(const_name, false)
63
63
  unless instance.is_a? self
64
- raise 'Enum constants must be instances of the Enum class (e.g. `Foo = new`)'
64
+ raise ArgumentError, 'Enum constants must be instances of the Enum class (e.g. `Foo = new`)'
65
65
  end
66
66
  @mapping[instance.serialize] = instance
67
67
  end
@@ -71,7 +71,7 @@ module Crystalline
71
71
  if @mapping.include? val
72
72
  @mapping[val]
73
73
  else
74
- raise "Invalid value for enum: #{val}"
74
+ raise ArgumentError, "Invalid value for enum: #{val}"
75
75
  end
76
76
  end
77
77
  end
data/lib/crystalline.rb CHANGED
@@ -3,11 +3,10 @@
3
3
  # typed: false
4
4
  # frozen_string_literal: true
5
5
 
6
- module Crystalline
7
- autoload :MetadataFields, 'crystalline/metadata_fields'
8
- end
9
-
10
-
11
6
  require_relative 'crystalline/utils'
12
7
  require_relative 'crystalline/module'
13
8
  require_relative 'crystalline/types'
9
+
10
+ module Crystalline
11
+ autoload :MetadataFields, 'crystalline/metadata_fields'
12
+ end
@@ -14,15 +14,48 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class Dimensions
16
16
  extend T::Sig
17
-
17
+
18
+ CONTENT_TYPE_JSON = 'application/json'
19
+ UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
20
+ API_ERROR_OCCURRED = 'API error occurred'
21
+
18
22
  # Operations involving dimensions
19
23
 
20
24
  sig { params(sdk_config: SDKConfiguration).void }
21
25
  def initialize(sdk_config)
22
26
  @sdk_configuration = sdk_config
23
-
27
+
24
28
  end
25
29
 
30
+ # Applies the SDK after-request hooks and ensures a usable response is present.
31
+ sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
32
+ def apply_after_request_hooks(http_response, error, hook_ctx)
33
+ if http_response.nil? || Utils.error_status?(http_response.status)
34
+ http_response = @sdk_configuration.hooks.after_error(
35
+ error: error,
36
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
37
+ hook_ctx: hook_ctx
38
+ ),
39
+ response: http_response
40
+ )
41
+ else
42
+ http_response = @sdk_configuration.hooks.after_success(
43
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
44
+ hook_ctx: hook_ctx
45
+ ),
46
+ response: http_response
47
+ )
48
+ end
49
+
50
+ if http_response.nil?
51
+ raise error unless error.nil?
52
+ raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
53
+ end
54
+
55
+ http_response
56
+ end
57
+ private :apply_after_request_hooks
58
+
26
59
  sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
27
60
  def get_url(base_url:, url_variables: nil)
28
61
  sd_base_url, sd_options = @sdk_configuration.get_server_details
@@ -44,16 +77,16 @@ module FastpixClient
44
77
  # list_dimensions - List the dimensions
45
78
  # Retrieves a list of dimensions that can be used as query parameters across various data endpoints. Each dimension has a unique id that can be used to filter data effectively.
46
79
  #
47
- # The dimensions retrieved from this endpoint can be used in conjunction with the <a href="https://docs.fastpix.io/reference/list_video_views">list video views</a> and <a href="https://docs.fastpix.io/reference/list_by_top_content">list by top content</a> endpoints to filter results based on specific criteria. For example, you can filter views by `browser_name`, `os_name`, `device_type`, and more.
80
+ # The dimensions retrieved from this endpoint can be used in conjunction with the <a href="https://fastpix.com/docs/video-data-api/views/list-video-views">list video views</a> and <a href="https://fastpix.com/docs/video-data-api/views/list-by-top-content">list by top content</a> endpoints to filter results based on specific criteria. For example, you can filter views by `browser_name`, `os_name`, `device_type`, and more.
48
81
  #
49
- # Related guides: <a href="https://docs.fastpix.io/page/what-video-data-do-we-capture#/">What Video Data do we capture?</a> , <a href="https://docs.fastpix.io/docs/user-passable-metadata-1">Use passable dimensions</a>
82
+ # Related guides: <a href="https://fastpix.com/docs/concepts/what-video-data-do-we-capture#/">What Video Data do we capture?</a> , <a href="https://fastpix.com/docs/working-with-video-data/pass-custom-metadata-to-metrics">Use passable dimensions</a>
50
83
  #
51
84
  url, params = @sdk_configuration.get_server_details
52
85
  base_url = Utils.template_url(url, params)
53
86
  url = "#{base_url}/data/dimensions"
54
87
  headers = {}
55
88
  headers = T.cast(headers, T::Hash[String, String])
56
- headers['Accept'] = 'application/json'
89
+ headers['Accept'] = CONTENT_TYPE_JSON
57
90
  headers['user-agent'] = @sdk_configuration.user_agent
58
91
 
59
92
  security = @sdk_configuration.security_source&.call
@@ -92,32 +125,12 @@ module FastpixClient
92
125
  rescue StandardError => e
93
126
  error = e
94
127
  ensure
95
- if http_response.nil? || Utils.error_status?(http_response.status)
96
- http_response = @sdk_configuration.hooks.after_error(
97
- error: error,
98
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
99
- hook_ctx: hook_ctx
100
- ),
101
- response: http_response
102
- )
103
- else
104
- http_response = @sdk_configuration.hooks.after_success(
105
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
106
- hook_ctx: hook_ctx
107
- ),
108
- response: http_response
109
- )
110
- end
111
-
112
- if http_response.nil?
113
- raise error if !error.nil?
114
- raise 'no response'
115
- end
128
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
116
129
  end
117
130
 
118
131
  content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
119
132
  if Utils.match_status_code(http_response.status, ['200'])
120
- if Utils.match_content_type(content_type, 'application/json')
133
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
121
134
  http_response = @sdk_configuration.hooks.after_success(
122
135
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
123
136
  hook_ctx: hook_ctx
@@ -135,14 +148,14 @@ module FastpixClient
135
148
 
136
149
  return response
137
150
  else
138
- 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'
151
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
139
152
  end
140
153
  elsif Utils.match_status_code(http_response.status, ['4XX'])
141
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
154
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
142
155
  elsif Utils.match_status_code(http_response.status, ['5XX'])
143
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
156
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
144
157
  else
145
- if Utils.match_content_type(content_type, 'application/json')
158
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
146
159
  http_response = @sdk_configuration.hooks.after_success(
147
160
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
148
161
  hook_ctx: hook_ctx
@@ -160,7 +173,7 @@ module FastpixClient
160
173
 
161
174
  return response
162
175
  else
163
- 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'
176
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
164
177
  end
165
178
  end
166
179
  end
@@ -172,14 +185,14 @@ module FastpixClient
172
185
  # This endpoint returns the filter values associated with a specific dimension, along with the total number of video views for each value. For example, it can list all `browser_name` (dimension) and show how many views occurred for all available browsers like Chrome, Safari (filter values).
173
186
  #
174
187
  #
175
- # In order to use the <a href="https://docs.fastpix.io/docs/custom-business-metadata">Custom Dimensions</a>, you must enable them in the dashboard under settings option based on the plan you have opted for.
188
+ # In order to use the <a href="https://fastpix.com/docs/working-with-video-data/use-custom-dimensions">Custom Dimensions</a>, you must enable them in the dashboard under settings option based on the plan you have opted for.
176
189
  #
177
190
  # #### Example
178
191
  #
179
192
  # A developer wants to know how their video content performs across different browsers. By calling this endpoint for the `device_type` dimension, they can retrieve a breakdown of video views by each device (for example, Desktop, Mobile, Tablet). This data helps the developer understand where optimizations or troubleshooting is necessary.
180
193
  #
181
194
  #
182
- # Related guide: <a href="https://docs.fastpix.io/docs/understand-dashboard-ui#filters-and-timeframes">Filters and timespan</a>
195
+ # Related guide: <a href="https://fastpix.com/docs/working-with-video-data/explore-the-dashboard#filters-and-timeframes">Filters and timespan</a>
183
196
  #
184
197
  request = Models::Operations::ListFilterValuesForDimensionRequest.new(
185
198
  dimensions_id: dimensions_id,
@@ -197,7 +210,7 @@ module FastpixClient
197
210
  headers = {}
198
211
  headers = T.cast(headers, T::Hash[String, String])
199
212
  query_params = Utils.get_query_params(Models::Operations::ListFilterValuesForDimensionRequest, request, nil)
200
- headers['Accept'] = 'application/json'
213
+ headers['Accept'] = CONTENT_TYPE_JSON
201
214
  headers['user-agent'] = @sdk_configuration.user_agent
202
215
 
203
216
  security = @sdk_configuration.security_source&.call
@@ -237,32 +250,12 @@ module FastpixClient
237
250
  rescue StandardError => e
238
251
  error = e
239
252
  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
253
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
261
254
  end
262
255
 
263
256
  content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
264
257
  if Utils.match_status_code(http_response.status, ['200'])
265
- if Utils.match_content_type(content_type, 'application/json')
258
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
266
259
  http_response = @sdk_configuration.hooks.after_success(
267
260
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
268
261
  hook_ctx: hook_ctx
@@ -280,14 +273,14 @@ module FastpixClient
280
273
 
281
274
  return response
282
275
  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'
276
+ 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
277
  end
285
278
  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'
279
+ 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
280
  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'
281
+ 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
282
  else
290
- if Utils.match_content_type(content_type, 'application/json')
283
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
291
284
  http_response = @sdk_configuration.hooks.after_success(
292
285
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
293
286
  hook_ctx: hook_ctx
@@ -305,7 +298,7 @@ module FastpixClient
305
298
 
306
299
  return response
307
300
  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'
301
+ 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
302
  end
310
303
  end
311
304
  end
@@ -14,6 +14,39 @@ module FastpixClient
14
14
  extend T::Sig
15
15
  class DRMConfigurations
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
17
50
 
18
51
  # Operations for DRM configuration management
19
52
 
@@ -53,7 +86,7 @@ module FastpixClient
53
86
  # **Example:**
54
87
  # A media service provider may retrieve DRM configuration for a workspace to create DRM content.
55
88
  #
56
- # Related guide: <a href="https://docs.fastpix.io/docs/secure-playback-with-drm">Manage DRM configuration</a>
89
+ # Related guide: <a href="https://fastpix.com/docs/video-security/set-up-drm-encryption">Manage DRM configuration</a>
57
90
  #
58
91
  request = Models::Operations::GetDrmConfigurationRequest.new(
59
92
  offset: offset,
@@ -65,7 +98,7 @@ module FastpixClient
65
98
  headers = {}
66
99
  headers = T.cast(headers, T::Hash[String, String])
67
100
  query_params = Utils.get_query_params(Models::Operations::GetDrmConfigurationRequest, request, nil)
68
- headers['Accept'] = 'application/json'
101
+ headers['Accept'] = CONTENT_TYPE_JSON
69
102
  headers['user-agent'] = @sdk_configuration.user_agent
70
103
 
71
104
  security = @sdk_configuration.security_source&.call
@@ -105,32 +138,12 @@ module FastpixClient
105
138
  rescue StandardError => e
106
139
  error = e
107
140
  ensure
108
- if http_response.nil? || Utils.error_status?(http_response.status)
109
- http_response = @sdk_configuration.hooks.after_error(
110
- error: error,
111
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
112
- hook_ctx: hook_ctx
113
- ),
114
- response: http_response
115
- )
116
- else
117
- http_response = @sdk_configuration.hooks.after_success(
118
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
119
- hook_ctx: hook_ctx
120
- ),
121
- response: http_response
122
- )
123
- end
124
-
125
- if http_response.nil?
126
- raise error if !error.nil?
127
- raise 'no response'
128
- end
141
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
129
142
  end
130
143
 
131
144
  content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
132
145
  if Utils.match_status_code(http_response.status, ['200'])
133
- if Utils.match_content_type(content_type, 'application/json')
146
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
134
147
  http_response = @sdk_configuration.hooks.after_success(
135
148
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
136
149
  hook_ctx: hook_ctx
@@ -148,14 +161,14 @@ module FastpixClient
148
161
 
149
162
  return response
150
163
  else
151
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
164
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
152
165
  end
153
166
  elsif Utils.match_status_code(http_response.status, ['4XX'])
154
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
167
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
155
168
  elsif Utils.match_status_code(http_response.status, ['5XX'])
156
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
169
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
157
170
  else
158
- if Utils.match_content_type(content_type, 'application/json')
171
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
159
172
  http_response = @sdk_configuration.hooks.after_success(
160
173
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
161
174
  hook_ctx: hook_ctx
@@ -173,7 +186,7 @@ module FastpixClient
173
186
 
174
187
  return response
175
188
  else
176
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
189
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
177
190
  end
178
191
  end
179
192
  end
@@ -189,7 +202,7 @@ module FastpixClient
189
202
  # 1. Make a GET request to this endpoint, replacing `{drmConfigurationId}` with the UUID of the DRM configuration.
190
203
  # 2. The response contains the associated DRM configuration ID.
191
204
  #
192
- # Related guide: <a href="https://docs.fastpix.io/docs/secure-playback-with-drm">Manage DRM configuration</a>
205
+ # Related guide: <a href="https://fastpix.com/docs/video-security/set-up-drm-encryption">Manage DRM configuration</a>
193
206
  #
194
207
  request = Models::Operations::GetDrmConfigurationByIdRequest.new(
195
208
  drm_configuration_id: drm_configuration_id
@@ -204,7 +217,7 @@ module FastpixClient
204
217
  )
205
218
  headers = {}
206
219
  headers = T.cast(headers, T::Hash[String, String])
207
- headers['Accept'] = 'application/json'
220
+ headers['Accept'] = CONTENT_TYPE_JSON
208
221
  headers['user-agent'] = @sdk_configuration.user_agent
209
222
 
210
223
  security = @sdk_configuration.security_source&.call
@@ -243,32 +256,12 @@ module FastpixClient
243
256
  rescue StandardError => e
244
257
  error = e
245
258
  ensure
246
- if http_response.nil? || Utils.error_status?(http_response.status)
247
- http_response = @sdk_configuration.hooks.after_error(
248
- error: error,
249
- hook_ctx: SDKHooks::AfterErrorHookContext.new(
250
- hook_ctx: hook_ctx
251
- ),
252
- response: http_response
253
- )
254
- else
255
- http_response = @sdk_configuration.hooks.after_success(
256
- hook_ctx: SDKHooks::AfterSuccessHookContext.new(
257
- hook_ctx: hook_ctx
258
- ),
259
- response: http_response
260
- )
261
- end
262
-
263
- if http_response.nil?
264
- raise error if !error.nil?
265
- raise 'no response'
266
- end
259
+ http_response = apply_after_request_hooks(http_response, error, hook_ctx)
267
260
  end
268
261
 
269
262
  content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
270
263
  if Utils.match_status_code(http_response.status, ['200'])
271
- if Utils.match_content_type(content_type, 'application/json')
264
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
272
265
  http_response = @sdk_configuration.hooks.after_success(
273
266
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
274
267
  hook_ctx: hook_ctx
@@ -286,14 +279,14 @@ module FastpixClient
286
279
 
287
280
  return response
288
281
  else
289
- 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'
282
+ 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
290
283
  end
291
284
  elsif Utils.match_status_code(http_response.status, ['4XX'])
292
- raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
285
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
293
286
  elsif Utils.match_status_code(http_response.status, ['5XX'])
294
- 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
+ raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
295
288
  else
296
- if Utils.match_content_type(content_type, 'application/json')
289
+ if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
297
290
  http_response = @sdk_configuration.hooks.after_success(
298
291
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
299
292
  hook_ctx: hook_ctx
@@ -311,7 +304,7 @@ module FastpixClient
311
304
 
312
305
  return response
313
306
  else
314
- 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'
307
+ 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
315
308
  end
316
309
  end
317
310
  end