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
|
@@ -21,70 +21,93 @@ module FastpixClient
|
|
|
21
21
|
|
|
22
22
|
f_name = param_metadata.fetch(:field_name, f.name)
|
|
23
23
|
serialization = param_metadata.fetch(:serialization, '')
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
path = _substitute_path_param(path, param_metadata, f, f_name, serialization, param)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
server_url.delete_suffix('/') + path
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Substitutes a single path param into the path, returning the updated path.
|
|
31
|
+
def self._substitute_path_param(path, param_metadata, f, f_name, serialization, param)
|
|
32
|
+
if serialization != ''
|
|
33
|
+
serialized_params = _get_serialized_params(param_metadata, f_name, param)
|
|
34
|
+
serialized_params.each do |k, v|
|
|
35
|
+
path = path.sub("{#{k}}", v.join(', '))
|
|
36
|
+
end
|
|
37
|
+
return path
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
placeholder = "{#{param_metadata.fetch(:field_name, f.name)}}"
|
|
41
|
+
if param.is_a? Array
|
|
42
|
+
path.sub(placeholder, _path_param_from_array(param))
|
|
43
|
+
elsif param.is_a? Hash
|
|
44
|
+
path.sub(placeholder, _path_param_from_hash(param_metadata, param))
|
|
45
|
+
elsif param.class.include?(::Crystalline::MetadataFields)
|
|
46
|
+
path.sub(placeholder, _path_param_from_object(param_metadata, f, param))
|
|
47
|
+
else
|
|
48
|
+
path.sub(placeholder, _path_param_scalar(param))
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self._path_param_from_array(param)
|
|
53
|
+
pp_vals = []
|
|
54
|
+
param.each do |pp_val|
|
|
55
|
+
pp_vals.append(pp_val.to_s)
|
|
56
|
+
end
|
|
57
|
+
pp_vals.join(',')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self._path_param_from_hash(param_metadata, param)
|
|
61
|
+
pp_vals = []
|
|
62
|
+
param.each do |pp_key, pp_val|
|
|
63
|
+
value = val_to_string(pp_val)
|
|
64
|
+
|
|
65
|
+
if param_metadata.fetch(:explode, false)
|
|
66
|
+
pp_vals.append("#{pp_key}=#{value}")
|
|
29
67
|
else
|
|
30
|
-
|
|
31
|
-
pp_vals = []
|
|
32
|
-
param.each do |pp_val|
|
|
33
|
-
pp_vals.append(pp_val.to_s)
|
|
34
|
-
end
|
|
35
|
-
path = path.sub("{#{param_metadata.fetch(:field_name, f.name)}}", pp_vals.join(','))
|
|
36
|
-
elsif param.is_a? Hash
|
|
37
|
-
pp_vals = []
|
|
38
|
-
param.each do |pp_key, pp_val|
|
|
39
|
-
value = val_to_string(pp_val)
|
|
40
|
-
|
|
41
|
-
if param_metadata.fetch(:explode, false)
|
|
42
|
-
pp_vals.append("#{pp_key}=#{value}")
|
|
43
|
-
else
|
|
44
|
-
pp_vals.append("#{pp_key},#{value}")
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
path = path.sub("{#{param_metadata.fetch(:field_name, f.name)}}", pp_vals.join(','))
|
|
48
|
-
elsif param.class.include?(::Crystalline::MetadataFields)
|
|
49
|
-
pp_vals = []
|
|
50
|
-
attrs = T.unsafe(param).fields.filter { |field| field.name && param.respond_to?(field.name.to_sym) }.map(&:name)
|
|
51
|
-
attrs.each do |attr|
|
|
52
|
-
field = T.unsafe(param).field(attr)
|
|
53
|
-
|
|
54
|
-
param_value_metadata = field.metadata[:path_param]
|
|
55
|
-
|
|
56
|
-
next if param_value_metadata.nil?
|
|
57
|
-
|
|
58
|
-
parm_name = param_value_metadata.fetch(:field_name, f.name)
|
|
59
|
-
|
|
60
|
-
param_field_val = param.send(attr)
|
|
61
|
-
|
|
62
|
-
if param_field_val.class.respond_to?(:enums)
|
|
63
|
-
param_field_val = param_field_val.serialize
|
|
64
|
-
elsif param_field_val.is_a? DateTime
|
|
65
|
-
param_field_val = param_field_val.strftime('%Y-%m-%dT%H:%M:%S.%NZ')
|
|
66
|
-
end
|
|
67
|
-
if !field.nil? && ::Crystalline::Utils.nilable?(field.type) && param_field_val.nil?
|
|
68
|
-
next
|
|
69
|
-
elsif param_metadata.fetch(:explode, false)
|
|
70
|
-
pp_vals.append("#{parm_name}=#{param_field_val}")
|
|
71
|
-
else
|
|
72
|
-
pp_vals.append("#{parm_name},#{param_field_val}")
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
path = path.sub("{#{param_metadata.fetch(:field_name, f.name)}}", pp_vals.join(','))
|
|
76
|
-
else
|
|
77
|
-
if param.class.respond_to?(:enums)
|
|
78
|
-
param = T.cast(param, T::Enum).serialize
|
|
79
|
-
elsif param.is_a? DateTime
|
|
80
|
-
param = param.strftime('%Y-%m-%dT%H:%M:%S.%NZ')
|
|
81
|
-
end
|
|
82
|
-
path = path.sub("{#{param_metadata.fetch(:field_name, f.name)}}", param.to_s)
|
|
83
|
-
end
|
|
68
|
+
pp_vals.append("#{pp_key},#{value}")
|
|
84
69
|
end
|
|
85
70
|
end
|
|
71
|
+
pp_vals.join(',')
|
|
72
|
+
end
|
|
86
73
|
|
|
87
|
-
|
|
74
|
+
def self._path_param_from_object(param_metadata, f, param)
|
|
75
|
+
pp_vals = []
|
|
76
|
+
attrs = T.unsafe(param).fields.filter { |field| field.name && param.respond_to?(field.name.to_sym) }.map(&:name)
|
|
77
|
+
attrs.each do |attr|
|
|
78
|
+
field = T.unsafe(param).field(attr)
|
|
79
|
+
|
|
80
|
+
param_value_metadata = field.metadata[:path_param]
|
|
81
|
+
|
|
82
|
+
next if param_value_metadata.nil?
|
|
83
|
+
|
|
84
|
+
parm_name = param_value_metadata.fetch(:field_name, f.name)
|
|
85
|
+
|
|
86
|
+
param_field_val = param.send(attr)
|
|
87
|
+
|
|
88
|
+
if param_field_val.class.respond_to?(:enums)
|
|
89
|
+
param_field_val = param_field_val.serialize
|
|
90
|
+
elsif param_field_val.is_a? DateTime
|
|
91
|
+
param_field_val = param_field_val.strftime('%Y-%m-%dT%H:%M:%S.%NZ')
|
|
92
|
+
end
|
|
93
|
+
if !field.nil? && ::Crystalline::Utils.nilable?(field.type) && param_field_val.nil?
|
|
94
|
+
next
|
|
95
|
+
elsif param_metadata.fetch(:explode, false)
|
|
96
|
+
pp_vals.append("#{parm_name}=#{param_field_val}")
|
|
97
|
+
else
|
|
98
|
+
pp_vals.append("#{parm_name},#{param_field_val}")
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
pp_vals.join(',')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def self._path_param_scalar(param)
|
|
105
|
+
if param.class.respond_to?(:enums)
|
|
106
|
+
param = T.cast(param, T::Enum).serialize
|
|
107
|
+
elsif param.is_a? DateTime
|
|
108
|
+
param = param.strftime('%Y-%m-%dT%H:%M:%S.%NZ')
|
|
109
|
+
end
|
|
110
|
+
param.to_s
|
|
88
111
|
end
|
|
89
112
|
|
|
90
113
|
sig { params(url_with_params: String, params: T::Hash[Symbol, T.any(String, T::Enum)]).returns(String) }
|
|
@@ -53,23 +53,17 @@ module FastpixClient
|
|
|
53
53
|
def self.match_content_type(content_type, pattern)
|
|
54
54
|
return true if content_type == pattern || ['*', '*/*'].include?(pattern)
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
pieces.each do |piece|
|
|
58
|
-
return true if pattern == piece.strip
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
false
|
|
56
|
+
content_type.split(';').any? { |piece| pattern == piece.strip }
|
|
62
57
|
end
|
|
63
58
|
|
|
64
59
|
sig { params(status_code: Integer, status_codes: T::Array[String]).returns(T::Boolean) }
|
|
65
60
|
def self.match_status_code(status_code, status_codes)
|
|
66
61
|
return true if status_codes.include? 'default'
|
|
62
|
+
|
|
67
63
|
status_code = status_code.to_s
|
|
68
|
-
status_codes.
|
|
69
|
-
|
|
70
|
-
return true if code.downcase.end_with?('xx') && status_code[0] == code[0]
|
|
64
|
+
status_codes.any? do |code|
|
|
65
|
+
code == status_code || (code.downcase.end_with?('xx') && status_code[0] == code[0])
|
|
71
66
|
end
|
|
72
|
-
false
|
|
73
67
|
end
|
|
74
68
|
|
|
75
69
|
sig { params(optional: T::Boolean).returns(T.proc.params(s: String).returns(T.nilable(DateTime))) }
|
|
@@ -130,15 +124,7 @@ module FastpixClient
|
|
|
130
124
|
if field.length == 2
|
|
131
125
|
if field[0].nil?
|
|
132
126
|
# Handle multiple values for the same field name (arrays)
|
|
133
|
-
|
|
134
|
-
# Convert to array if not already
|
|
135
|
-
unless payload[field_name].is_a?(Array)
|
|
136
|
-
payload[field_name] = [payload[field_name]]
|
|
137
|
-
end
|
|
138
|
-
payload[field_name] << field[1]
|
|
139
|
-
else
|
|
140
|
-
payload[field_name] = field[1]
|
|
141
|
-
end
|
|
127
|
+
_add_form_payload_value(payload, field_name, field[1])
|
|
142
128
|
else
|
|
143
129
|
# Handle file uploads
|
|
144
130
|
file_part = Faraday::Multipart::FilePart.new(
|
|
@@ -146,34 +132,30 @@ module FastpixClient
|
|
|
146
132
|
'application/octet-stream',
|
|
147
133
|
field[0]
|
|
148
134
|
)
|
|
149
|
-
|
|
135
|
+
|
|
150
136
|
# Handle multiple files for the same field name (arrays)
|
|
151
|
-
|
|
152
|
-
unless payload[field_name].is_a?(Array)
|
|
153
|
-
payload[field_name] = [payload[field_name]]
|
|
154
|
-
end
|
|
155
|
-
payload[field_name] << file_part
|
|
156
|
-
else
|
|
157
|
-
payload[field_name] = file_part
|
|
158
|
-
end
|
|
137
|
+
_add_form_payload_value(payload, field_name, file_part)
|
|
159
138
|
end
|
|
160
139
|
elsif field.length == 3
|
|
161
140
|
param_part = Faraday::Multipart::ParamPart.new(field[1].to_json, field[2])
|
|
162
|
-
|
|
141
|
+
|
|
163
142
|
# Handle multiple values for the same field name (arrays)
|
|
164
|
-
|
|
165
|
-
unless payload[field_name].is_a?(Array)
|
|
166
|
-
payload[field_name] = [payload[field_name]]
|
|
167
|
-
end
|
|
168
|
-
payload[field_name] << param_part
|
|
169
|
-
else
|
|
170
|
-
payload[field_name] = param_part
|
|
171
|
-
end
|
|
143
|
+
_add_form_payload_value(payload, field_name, param_part)
|
|
172
144
|
end
|
|
173
145
|
end
|
|
174
146
|
payload
|
|
175
147
|
end
|
|
176
148
|
|
|
149
|
+
# Stores a form value, converting to an array when the field name repeats.
|
|
150
|
+
def self._add_form_payload_value(payload, field_name, value)
|
|
151
|
+
if payload.key?(field_name)
|
|
152
|
+
payload[field_name] = [payload[field_name]] unless payload[field_name].is_a?(Array)
|
|
153
|
+
payload[field_name] << value
|
|
154
|
+
else
|
|
155
|
+
payload[field_name] = value
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
177
159
|
sig { params(param_name: Symbol, value: Object, param_type: String, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(Object) }
|
|
178
160
|
def self._populate_from_globals(param_name, value, param_type, gbls)
|
|
179
161
|
if value.nil? && !gbls.nil?
|
data/lib/fastpix_client/views.rb
CHANGED
|
@@ -14,6 +14,42 @@ module FastpixClient
|
|
|
14
14
|
extend T::Sig
|
|
15
15
|
class Views
|
|
16
16
|
extend T::Sig
|
|
17
|
+
|
|
18
|
+
API_ERROR_OCCURRED = 'API error occurred'
|
|
19
|
+
CONTENT_TYPE_HEADER = 'Content-Type'
|
|
20
|
+
CONTENT_TYPE_JSON = 'application/json'
|
|
21
|
+
DEFAULT_CONTENT_TYPE = 'application/octet-stream'
|
|
22
|
+
UNKNOWN_CONTENT_TYPE_ERROR = 'Unknown content type received'
|
|
23
|
+
USER_AGENT_HEADER = 'user-agent'
|
|
24
|
+
|
|
25
|
+
# Applies the SDK after-request hooks and ensures a usable response is present.
|
|
26
|
+
sig { params(http_response: T.nilable(Faraday::Response), error: T.nilable(StandardError), hook_ctx: SDKHooks::HookContext).returns(Faraday::Response) }
|
|
27
|
+
def apply_after_request_hooks(http_response, error, hook_ctx)
|
|
28
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
29
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
30
|
+
error: error,
|
|
31
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
32
|
+
hook_ctx: hook_ctx
|
|
33
|
+
),
|
|
34
|
+
response: http_response
|
|
35
|
+
)
|
|
36
|
+
else
|
|
37
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
38
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
39
|
+
hook_ctx: hook_ctx
|
|
40
|
+
),
|
|
41
|
+
response: http_response
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if http_response.nil?
|
|
46
|
+
raise error unless error.nil?
|
|
47
|
+
raise ::FastpixClient::Models::Errors::EmptyResponseError, 'no response'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
http_response
|
|
51
|
+
end
|
|
52
|
+
private :apply_after_request_hooks
|
|
17
53
|
|
|
18
54
|
# Operations involving views
|
|
19
55
|
|
|
@@ -74,8 +110,8 @@ module FastpixClient
|
|
|
74
110
|
headers = {}
|
|
75
111
|
headers = T.cast(headers, T::Hash[String, String])
|
|
76
112
|
query_params = Utils.get_query_params(Models::Operations::ListVideoViewsRequest, request, nil)
|
|
77
|
-
headers['Accept'] =
|
|
78
|
-
headers[
|
|
113
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
114
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
79
115
|
|
|
80
116
|
security = @sdk_configuration.security_source&.call
|
|
81
117
|
|
|
@@ -114,32 +150,12 @@ module FastpixClient
|
|
|
114
150
|
rescue StandardError => e
|
|
115
151
|
error = e
|
|
116
152
|
ensure
|
|
117
|
-
|
|
118
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
119
|
-
error: error,
|
|
120
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
121
|
-
hook_ctx: hook_ctx
|
|
122
|
-
),
|
|
123
|
-
response: http_response
|
|
124
|
-
)
|
|
125
|
-
else
|
|
126
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
127
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
128
|
-
hook_ctx: hook_ctx
|
|
129
|
-
),
|
|
130
|
-
response: http_response
|
|
131
|
-
)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
if http_response.nil?
|
|
135
|
-
raise error if !error.nil?
|
|
136
|
-
raise 'no response'
|
|
137
|
-
end
|
|
153
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
138
154
|
end
|
|
139
155
|
|
|
140
|
-
content_type = http_response.headers.fetch(
|
|
156
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
141
157
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
142
|
-
if Utils.match_content_type(content_type,
|
|
158
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
143
159
|
http_response = @sdk_configuration.hooks.after_success(
|
|
144
160
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
145
161
|
hook_ctx: hook_ctx
|
|
@@ -157,14 +173,14 @@ module FastpixClient
|
|
|
157
173
|
|
|
158
174
|
return response
|
|
159
175
|
else
|
|
160
|
-
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
|
|
161
177
|
end
|
|
162
178
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
163
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
179
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
164
180
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
165
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
181
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
166
182
|
else
|
|
167
|
-
if Utils.match_content_type(content_type,
|
|
183
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
168
184
|
http_response = @sdk_configuration.hooks.after_success(
|
|
169
185
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
170
186
|
hook_ctx: hook_ctx
|
|
@@ -182,7 +198,7 @@ module FastpixClient
|
|
|
182
198
|
|
|
183
199
|
return response
|
|
184
200
|
else
|
|
185
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
201
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), UNKNOWN_CONTENT_TYPE_ERROR
|
|
186
202
|
end
|
|
187
203
|
end
|
|
188
204
|
end
|
|
@@ -215,8 +231,8 @@ module FastpixClient
|
|
|
215
231
|
)
|
|
216
232
|
headers = {}
|
|
217
233
|
headers = T.cast(headers, T::Hash[String, String])
|
|
218
|
-
headers['Accept'] =
|
|
219
|
-
headers[
|
|
234
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
235
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
220
236
|
|
|
221
237
|
security = @sdk_configuration.security_source&.call
|
|
222
238
|
|
|
@@ -254,32 +270,12 @@ module FastpixClient
|
|
|
254
270
|
rescue StandardError => e
|
|
255
271
|
error = e
|
|
256
272
|
ensure
|
|
257
|
-
|
|
258
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
259
|
-
error: error,
|
|
260
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
261
|
-
hook_ctx: hook_ctx
|
|
262
|
-
),
|
|
263
|
-
response: http_response
|
|
264
|
-
)
|
|
265
|
-
else
|
|
266
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
267
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
268
|
-
hook_ctx: hook_ctx
|
|
269
|
-
),
|
|
270
|
-
response: http_response
|
|
271
|
-
)
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
if http_response.nil?
|
|
275
|
-
raise error if !error.nil?
|
|
276
|
-
raise 'no response'
|
|
277
|
-
end
|
|
273
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
278
274
|
end
|
|
279
275
|
|
|
280
|
-
content_type = http_response.headers.fetch(
|
|
276
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
281
277
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
282
|
-
if Utils.match_content_type(content_type,
|
|
278
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
283
279
|
http_response = @sdk_configuration.hooks.after_success(
|
|
284
280
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
285
281
|
hook_ctx: hook_ctx
|
|
@@ -297,14 +293,14 @@ module FastpixClient
|
|
|
297
293
|
|
|
298
294
|
return response
|
|
299
295
|
else
|
|
300
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
296
|
+
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
|
|
301
297
|
end
|
|
302
298
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
303
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
299
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
304
300
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
305
|
-
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), API_ERROR_OCCURRED
|
|
306
302
|
else
|
|
307
|
-
if Utils.match_content_type(content_type,
|
|
303
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
308
304
|
http_response = @sdk_configuration.hooks.after_success(
|
|
309
305
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
310
306
|
hook_ctx: hook_ctx
|
|
@@ -322,7 +318,7 @@ module FastpixClient
|
|
|
322
318
|
|
|
323
319
|
return response
|
|
324
320
|
else
|
|
325
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
321
|
+
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
|
|
326
322
|
end
|
|
327
323
|
end
|
|
328
324
|
end
|
|
@@ -359,8 +355,8 @@ module FastpixClient
|
|
|
359
355
|
headers = {}
|
|
360
356
|
headers = T.cast(headers, T::Hash[String, String])
|
|
361
357
|
query_params = Utils.get_query_params(Models::Operations::ListByTopContentRequest, request, nil)
|
|
362
|
-
headers['Accept'] =
|
|
363
|
-
headers[
|
|
358
|
+
headers['Accept'] = CONTENT_TYPE_JSON
|
|
359
|
+
headers[USER_AGENT_HEADER] = @sdk_configuration.user_agent
|
|
364
360
|
|
|
365
361
|
security = @sdk_configuration.security_source&.call
|
|
366
362
|
|
|
@@ -399,32 +395,12 @@ module FastpixClient
|
|
|
399
395
|
rescue StandardError => e
|
|
400
396
|
error = e
|
|
401
397
|
ensure
|
|
402
|
-
|
|
403
|
-
http_response = @sdk_configuration.hooks.after_error(
|
|
404
|
-
error: error,
|
|
405
|
-
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
406
|
-
hook_ctx: hook_ctx
|
|
407
|
-
),
|
|
408
|
-
response: http_response
|
|
409
|
-
)
|
|
410
|
-
else
|
|
411
|
-
http_response = @sdk_configuration.hooks.after_success(
|
|
412
|
-
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
413
|
-
hook_ctx: hook_ctx
|
|
414
|
-
),
|
|
415
|
-
response: http_response
|
|
416
|
-
)
|
|
417
|
-
end
|
|
418
|
-
|
|
419
|
-
if http_response.nil?
|
|
420
|
-
raise error if !error.nil?
|
|
421
|
-
raise 'no response'
|
|
422
|
-
end
|
|
398
|
+
http_response = apply_after_request_hooks(http_response, error, hook_ctx)
|
|
423
399
|
end
|
|
424
400
|
|
|
425
|
-
content_type = http_response.headers.fetch(
|
|
401
|
+
content_type = http_response.headers.fetch(CONTENT_TYPE_HEADER, DEFAULT_CONTENT_TYPE)
|
|
426
402
|
if Utils.match_status_code(http_response.status, ['200'])
|
|
427
|
-
if Utils.match_content_type(content_type,
|
|
403
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
428
404
|
http_response = @sdk_configuration.hooks.after_success(
|
|
429
405
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
430
406
|
hook_ctx: hook_ctx
|
|
@@ -442,14 +418,14 @@ module FastpixClient
|
|
|
442
418
|
|
|
443
419
|
return response
|
|
444
420
|
else
|
|
445
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
421
|
+
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
|
|
446
422
|
end
|
|
447
423
|
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
|
448
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
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
|
|
449
425
|
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
|
450
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
426
|
+
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), API_ERROR_OCCURRED
|
|
451
427
|
else
|
|
452
|
-
if Utils.match_content_type(content_type,
|
|
428
|
+
if Utils.match_content_type(content_type, CONTENT_TYPE_JSON)
|
|
453
429
|
http_response = @sdk_configuration.hooks.after_success(
|
|
454
430
|
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
455
431
|
hook_ctx: hook_ctx
|
|
@@ -467,7 +443,7 @@ module FastpixClient
|
|
|
467
443
|
|
|
468
444
|
return response
|
|
469
445
|
else
|
|
470
|
-
raise ::FastpixClient::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response),
|
|
446
|
+
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
|
|
471
447
|
end
|
|
472
448
|
end
|
|
473
449
|
end
|
data/lib/fastpixapi.rb
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
# typed: true
|
|
4
4
|
# frozen_string_literal: true
|
|
5
5
|
|
|
6
|
+
require_relative 'fastpix_client/utils/utils'
|
|
7
|
+
require_relative 'fastpix_client/utils/request_bodies'
|
|
8
|
+
require_relative 'fastpix_client/utils/query_params'
|
|
9
|
+
require_relative 'fastpix_client/utils/forms'
|
|
10
|
+
require_relative 'fastpix_client/utils/headers'
|
|
11
|
+
require_relative 'fastpix_client/utils/url'
|
|
12
|
+
require_relative 'fastpix_client/utils/security'
|
|
13
|
+
require_relative 'crystalline'
|
|
14
|
+
require_relative 'fastpix_client/sdkconfiguration'
|
|
15
|
+
|
|
6
16
|
module FastpixClient
|
|
7
17
|
autoload :Fastpixapi, 'fastpix_client/fastpixapi'
|
|
8
18
|
autoload :InputVideo, 'fastpix_client/input_video'
|
|
@@ -27,13 +37,3 @@ module FastpixClient
|
|
|
27
37
|
autoload :Callbacks, 'fastpix_client/models/callbacks'
|
|
28
38
|
end
|
|
29
39
|
end
|
|
30
|
-
|
|
31
|
-
require_relative 'fastpix_client/utils/utils'
|
|
32
|
-
require_relative 'fastpix_client/utils/request_bodies'
|
|
33
|
-
require_relative 'fastpix_client/utils/query_params'
|
|
34
|
-
require_relative 'fastpix_client/utils/forms'
|
|
35
|
-
require_relative 'fastpix_client/utils/headers'
|
|
36
|
-
require_relative 'fastpix_client/utils/url'
|
|
37
|
-
require_relative 'fastpix_client/utils/security'
|
|
38
|
-
require_relative 'crystalline'
|
|
39
|
-
require_relative 'fastpix_client/sdkconfiguration'
|
data/lib/openssl_patch.rb
CHANGED
|
@@ -2,27 +2,29 @@
|
|
|
2
2
|
# This file should be required before any SSL connections are made
|
|
3
3
|
|
|
4
4
|
require 'openssl'
|
|
5
|
+
require 'net/http'
|
|
5
6
|
|
|
6
|
-
# Find certificate file
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
# Find certificate file (guarded so re-loading this file does not warn about a
|
|
8
|
+
# redefined constant).
|
|
9
|
+
unless defined?(CERT_FILE)
|
|
10
|
+
CERT_FILE = if File.exist?('/opt/homebrew/etc/openssl@3/cert.pem')
|
|
11
|
+
'/opt/homebrew/etc/openssl@3/cert.pem'
|
|
12
|
+
elsif File.exist?('/usr/local/etc/openssl@3/cert.pem')
|
|
13
|
+
'/usr/local/etc/openssl@3/cert.pem'
|
|
14
|
+
elsif File.exist?('/etc/ssl/certs/ca-certificates.crt')
|
|
15
|
+
'/etc/ssl/certs/ca-certificates.crt'
|
|
16
|
+
elsif File.exist?('/etc/ssl/cert.pem')
|
|
17
|
+
'/etc/ssl/cert.pem'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
18
20
|
|
|
19
21
|
if CERT_FILE && File.exist?(CERT_FILE)
|
|
20
22
|
# Patch OpenSSL::X509::Store to always include our certificate file
|
|
21
23
|
module OpenSSL
|
|
22
24
|
module X509
|
|
23
25
|
class Store
|
|
24
|
-
alias_method :original_set_default_paths, :set_default_paths
|
|
25
|
-
|
|
26
|
+
alias_method :original_set_default_paths, :set_default_paths unless method_defined?(:original_set_default_paths)
|
|
27
|
+
|
|
26
28
|
def set_default_paths
|
|
27
29
|
original_set_default_paths
|
|
28
30
|
add_file(CERT_FILE) if CERT_FILE && File.exist?(CERT_FILE)
|
|
@@ -37,19 +39,19 @@ if CERT_FILE && File.exist?(CERT_FILE)
|
|
|
37
39
|
ENV['CURL_CA_BUNDLE'] = CERT_FILE
|
|
38
40
|
ENV['RUBY_OPENSSL_CA_CERT_FILE'] = CERT_FILE
|
|
39
41
|
|
|
40
|
-
# Also patch the default certificate file constant
|
|
41
|
-
|
|
42
|
+
# Also patch the default certificate file constant when it is mutable. On
|
|
43
|
+
# newer Ruby versions this constant is frozen, so skip it there (the
|
|
44
|
+
# SSL_CERT_FILE env var above already covers that case) to avoid FrozenError.
|
|
45
|
+
if defined?(OpenSSL::X509::DEFAULT_CERT_FILE) && !OpenSSL::X509::DEFAULT_CERT_FILE.frozen?
|
|
42
46
|
OpenSSL::X509::DEFAULT_CERT_FILE.replace(CERT_FILE)
|
|
43
47
|
end
|
|
44
48
|
|
|
45
|
-
# Patch Net::HTTP to use our certificate store
|
|
46
|
-
|
|
47
|
-
require 'net/http' unless defined?(Net::HTTP)
|
|
48
|
-
|
|
49
|
+
# Patch Net::HTTP to use our certificate store (skipped if Net::HTTP is unavailable)
|
|
50
|
+
if defined?(Net::HTTP)
|
|
49
51
|
module Net
|
|
50
52
|
class HTTP
|
|
51
|
-
alias_method :original_connect, :connect
|
|
52
|
-
|
|
53
|
+
alias_method :original_connect, :connect unless method_defined?(:original_connect)
|
|
54
|
+
|
|
53
55
|
def connect
|
|
54
56
|
original_connect
|
|
55
57
|
# Ensure SSL context uses our certificate file (skip if context is frozen, e.g. Bundler)
|
|
@@ -62,8 +64,6 @@ if CERT_FILE && File.exist?(CERT_FILE)
|
|
|
62
64
|
end
|
|
63
65
|
end
|
|
64
66
|
end
|
|
65
|
-
rescue LoadError
|
|
66
|
-
# Net::HTTP not available, skip
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
puts "[OpenSSL Patch] Configured SSL certificate: #{CERT_FILE}" if ENV['DEBUG']
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fastpixapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- FastPix
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -722,6 +722,7 @@ files:
|
|
|
722
722
|
- lib/fastpix_client/models/errors.rb
|
|
723
723
|
- lib/fastpix_client/models/errors/apierror.rb
|
|
724
724
|
- lib/fastpix_client/models/errors/apierror.rbi
|
|
725
|
+
- lib/fastpix_client/models/errors/empty_response_error.rb
|
|
725
726
|
- lib/fastpix_client/models/operations.rb
|
|
726
727
|
- lib/fastpix_client/models/operations/add_media_to_playlist_request.rb
|
|
727
728
|
- lib/fastpix_client/models/operations/add_media_to_playlist_request.rbi
|