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.
- 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 +51 -58
- data/lib/fastpix_client/drm_configurations.rb +49 -56
- data/lib/fastpix_client/errors.rb +35 -24
- data/lib/fastpix_client/fastpixapi.rb +2 -4
- data/lib/fastpix_client/in_video_ai_features.rb +100 -160
- data/lib/fastpix_client/input_video.rb +66 -74
- data/lib/fastpix_client/live_playback.rb +82 -99
- data/lib/fastpix_client/manage_live_stream.rb +136 -252
- data/lib/fastpix_client/manage_videos.rb +228 -543
- data/lib/fastpix_client/metrics.rb +76 -120
- data/lib/fastpix_client/models/components/createlivestreamresponsedto.rb +10 -18
- data/lib/fastpix_client/models/components/createmediarequest.rb +9 -18
- 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/sourceaccessmedia.rb +11 -26
- data/lib/fastpix_client/models/components/update_media.rb +11 -26
- data/lib/fastpix_client/models/components/views.rb +51 -124
- 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/push_media_settings.rb +9 -20
- data/lib/fastpix_client/playback.rb +122 -213
- data/lib/fastpix_client/playlist.rb +150 -296
- 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 +3 -3
- data/lib/fastpix_client/signing_keys.rb +76 -120
- data/lib/fastpix_client/simulcast_stream.rb +97 -141
- data/lib/fastpix_client/start_live_stream.rb +51 -33
- 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 -60
- data/lib/fastpix_client/utils/utils.rb +19 -37
- data/lib/fastpix_client/views.rb +66 -90
- data/lib/fastpixapi.rb +10 -10
- data/lib/openssl_patch.rb +24 -24
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6ae3027c5f37f777cf9a979ddd36123a1bb1e93e0ff5f2a9b70a4d27928e73c
|
|
4
|
+
data.tar.gz: c097e0cfb9dc6c84144740416b8a7bdc7e476ca55dab42714ca19db73d7d91bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
154
|
-
|
|
155
|
-
|
|
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)
|
data/lib/crystalline/types.rb
CHANGED
|
@@ -54,14 +54,14 @@ module Crystalline
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
module ClassMethods
|
|
57
|
-
def enums(&
|
|
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
|
|
@@ -53,7 +86,7 @@ module FastpixClient
|
|
|
53
86
|
url = "#{base_url}/data/dimensions"
|
|
54
87
|
headers = {}
|
|
55
88
|
headers = T.cast(headers, T::Hash[String, String])
|
|
56
|
-
headers['Accept'] =
|
|
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
|
-
|
|
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,
|
|
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),
|
|
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),
|
|
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),
|
|
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,
|
|
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),
|
|
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
|
|
@@ -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'] =
|
|
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
|
-
|
|
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,
|
|
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),
|
|
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),
|
|
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),
|
|
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,
|
|
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),
|
|
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
|
|
|
@@ -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'] =
|
|
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
|
-
|
|
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,
|
|
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),
|
|
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),
|
|
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),
|
|
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,
|
|
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),
|
|
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
|
|
@@ -204,7 +217,7 @@ module FastpixClient
|
|
|
204
217
|
)
|
|
205
218
|
headers = {}
|
|
206
219
|
headers = T.cast(headers, T::Hash[String, String])
|
|
207
|
-
headers['Accept'] =
|
|
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
|
-
|
|
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,
|
|
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),
|
|
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),
|
|
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),
|
|
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,
|
|
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),
|
|
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
|
|
@@ -14,6 +14,37 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class Errors
|
|
16
16
|
extend T::Sig
|
|
17
|
+
|
|
18
|
+
CONTENT_TYPE_JSON = 'application/json'
|
|
19
|
+
|
|
20
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
21
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
22
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
23
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
24
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
25
|
+
error: error,
|
|
26
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
27
|
+
hook_ctx: hook_ctx
|
|
28
|
+
),
|
|
29
|
+
response: http_response
|
|
30
|
+
)
|
|
31
|
+
else
|
|
32
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
33
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
34
|
+
hook_ctx: hook_ctx
|
|
35
|
+
),
|
|
36
|
+
response: http_response
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if http_response.nil?
|
|
41
|
+
raise error unless error.nil?
|
|
42
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
http_response
|
|
46
|
+
end
|
|
47
|
+
private :apply_after_request_hooks
|
|
17
48
|
|
|
18
49
|
# Operations involving errors
|
|
19
50
|
|
|
@@ -71,7 +102,7 @@ module FastpixClient
|
|
|
71
102
|
headers = {}
|
|
72
103
|
headers = T.cast(headers, T::Hash[String, String])
|
|
73
104
|
query_params = Utils.get_query_params(Models::Operations::ListErrorsRequest, request, nil)
|
|
74
|
-
headers['Accept'] =
|
|
105
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
75
106
|
headers['user-agent'] = @sdk_configuration.user_agent
|
|
76
107
|
|
|
77
108
|
security = @sdk_configuration.security_source&.call
|
|
@@ -111,32 +142,12 @@ module FastpixClient
|
|
|
111
142
|
rescue StandardError => e
|
|
112
143
|
error = e
|
|
113
144
|
ensure
|
|
114
|
-
|
|
115
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
116
|
-
error: error,
|
|
117
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
118
|
-
hook_ctx: hook_ctx
|
|
119
|
-
),
|
|
120
|
-
response: http_response
|
|
121
|
-
)
|
|
122
|
-
else
|
|
123
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
124
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
125
|
-
hook_ctx: hook_ctx
|
|
126
|
-
),
|
|
127
|
-
response: http_response
|
|
128
|
-
)
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
if http_response.nil?
|
|
132
|
-
raise error if !error.nil?
|
|
133
|
-
raise 'no response'
|
|
134
|
-
end
|
|
145
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
135
146
|
end
|
|
136
147
|
|
|
137
148
|
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
|
138
149
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
139
|
-
if Utils.match_content_type(content_type,
|
|
150
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
140
151
|
http_response = @sdk_configuration.hooks.after_success(
|
|
141
152
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
142
153
|
hook_ctx: hook_ctx
|
|
@@ -161,7 +172,7 @@ module FastpixClient
|
|
|
161
172
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
162
173
|
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
|
163
174
|
else
|
|
164
|
-
if Utils.match_content_type(content_type,
|
|
175
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
165
176
|
http_response = @sdk_configuration.hooks.after_success(
|
|
166
177
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
167
178
|
hook_ctx: hook_ctx
|
|
@@ -54,10 +54,8 @@ module FastpixClient
|
|
|
54
54
|
# f.response :logger, nil, { headers: true, bodies: true, errors: true }
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
if !server_url.nil?
|
|
58
|
-
|
|
59
|
-
server_url = Utils.template_url(server_url, url_params)
|
|
60
|
-
end
|
|
57
|
+
if !server_url.nil? && !url_params.nil?
|
|
58
|
+
server_url = Utils.template_url(server_url, url_params)
|
|
61
59
|
end
|
|
62
60
|
|
|
63
61
|
server_idx = 0 if server_idx.nil?
|