moov_ruby 0.1.23 → 0.1.25
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/moov/client.rb +2 -1
- data/lib/moov/images.rb +567 -0
- data/lib/moov/models/components/imagemetadata.rb +50 -0
- data/lib/moov/models/components/imagemetadata.rbi +21 -0
- data/lib/moov/models/components/paymentmethodswallet.rb +12 -2
- data/lib/moov/models/components/paymentmethodswallet.rbi +4 -0
- data/lib/moov/models/components/security.rb +4 -4
- data/lib/moov/models/components.rb +1 -0
- data/lib/moov/models/operations/deleteimage_request.rb +49 -0
- data/lib/moov/models/operations/deleteimage_request.rbi +17 -0
- data/lib/moov/models/operations/deleteimage_response.rb +45 -0
- data/lib/moov/models/operations/deleteimage_response.rbi +19 -0
- data/lib/moov/models/operations/getimagemetadata_request.rb +49 -0
- data/lib/moov/models/operations/getimagemetadata_request.rbi +17 -0
- data/lib/moov/models/operations/getimagemetadata_response.rb +49 -0
- data/lib/moov/models/operations/getimagemetadata_response.rbi +21 -0
- data/lib/moov/models/operations/getpublicimage_request.rb +45 -0
- data/lib/moov/models/operations/getpublicimage_request.rbi +17 -0
- data/lib/moov/models/operations/getpublicimage_response.rb +57 -0
- data/lib/moov/models/operations/getpublicimage_response.rbi +25 -0
- data/lib/moov/models/operations/listimagemetadata_request.rb +45 -0
- data/lib/moov/models/operations/listimagemetadata_request.rbi +15 -0
- data/lib/moov/models/operations/listimagemetadata_response.rb +49 -0
- data/lib/moov/models/operations/listimagemetadata_response.rbi +21 -0
- data/lib/moov/models/operations.rb +8 -0
- data/lib/moov/sdkconfiguration.rb +3 -3
- data/lib/moov_ruby.rb +1 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 481b230c41ab215bbca2503dbe9a71653c06c0284bfbfd6b0aee8d25308803f1
|
4
|
+
data.tar.gz: d6260df7aaaa388ae1d54ca84cc4dea0517be04c4b2fc987407695de3229ce42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62983f37211d945b9c63034518807389df5cce1ca157618327cef50c6ead364935bbffb8da98181d815da03fc7fa7a04f6062ada1f112c4be5b09032cb9dc002
|
7
|
+
data.tar.gz: f8a2246216c8e1461cd09effb7688e5f21e974767e819fbf2b5d9e9c6bb42e8117837310806d15a46756e61b4c2c8317d90465b52ecd5d26fc5d1deee89cc374
|
data/lib/moov/client.rb
CHANGED
@@ -16,7 +16,7 @@ module Moov
|
|
16
16
|
class Client
|
17
17
|
extend T::Sig
|
18
18
|
|
19
|
-
attr_accessor :accounts, :adjustments, :apple_pay, :bank_accounts, :branding, :capabilities, :cards, :disputes, :fee_plans, :files, :payment_links, :payment_methods, :representatives, :scheduling, :statements, :sweeps, :account_terminal_applications, :support, :transfers, :underwriting, :wallets, :wallet_transactions, :avatars, :end_to_end_encryption, :enriched_address, :enriched_profile, :industries, :institutions, :issuing_transactions, :card_issuing, :authentication, :onboarding, :ping, :receipts, :terminal_applications
|
19
|
+
attr_accessor :accounts, :adjustments, :apple_pay, :bank_accounts, :branding, :capabilities, :cards, :disputes, :fee_plans, :files, :images, :payment_links, :payment_methods, :representatives, :scheduling, :statements, :sweeps, :account_terminal_applications, :support, :transfers, :underwriting, :wallets, :wallet_transactions, :avatars, :end_to_end_encryption, :enriched_address, :enriched_profile, :industries, :institutions, :issuing_transactions, :card_issuing, :authentication, :onboarding, :ping, :receipts, :terminal_applications
|
20
20
|
|
21
21
|
sig do
|
22
22
|
params(
|
@@ -102,6 +102,7 @@ module Moov
|
|
102
102
|
@disputes = Disputes.new(@sdk_configuration)
|
103
103
|
@fee_plans = FeePlans.new(@sdk_configuration)
|
104
104
|
@files = Files.new(@sdk_configuration)
|
105
|
+
@images = Images.new(@sdk_configuration)
|
105
106
|
@payment_links = PaymentLinks.new(@sdk_configuration)
|
106
107
|
@payment_methods = PaymentMethods.new(@sdk_configuration)
|
107
108
|
@representatives = Representatives.new(@sdk_configuration)
|
data/lib/moov/images.rb
ADDED
@@ -0,0 +1,567 @@
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
2
|
+
|
3
|
+
# typed: true
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require 'faraday'
|
7
|
+
require 'faraday/multipart'
|
8
|
+
require 'faraday/retry'
|
9
|
+
require 'sorbet-runtime'
|
10
|
+
require_relative 'sdk_hooks/hooks'
|
11
|
+
require_relative 'utils/retries'
|
12
|
+
|
13
|
+
module Moov
|
14
|
+
extend T::Sig
|
15
|
+
class Images
|
16
|
+
extend T::Sig
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
sig { params(sdk_config: SDKConfiguration).void }
|
21
|
+
def initialize(sdk_config)
|
22
|
+
@sdk_configuration = sdk_config
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
|
27
|
+
def get_url(base_url:, url_variables: nil)
|
28
|
+
sd_base_url, sd_options = @sdk_configuration.get_server_details
|
29
|
+
|
30
|
+
if base_url.nil?
|
31
|
+
base_url = sd_base_url
|
32
|
+
end
|
33
|
+
|
34
|
+
if url_variables.nil?
|
35
|
+
url_variables = sd_options
|
36
|
+
end
|
37
|
+
|
38
|
+
return Utils.template_url base_url, url_variables
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
sig { params(account_id: ::String, x_moov_version: T.nilable(::String), timeout_ms: T.nilable(Integer)).returns(Models::Operations::ListImageMetadataResponse) }
|
43
|
+
def list(account_id:, x_moov_version: nil, timeout_ms: nil)
|
44
|
+
# list - List metadata for all images in the specified account.
|
45
|
+
request = Models::Operations::ListImageMetadataRequest.new(
|
46
|
+
account_id: account_id,
|
47
|
+
x_moov_version: x_moov_version
|
48
|
+
)
|
49
|
+
url, params = @sdk_configuration.get_server_details
|
50
|
+
base_url = Utils.template_url(url, params)
|
51
|
+
url = Utils.generate_url(
|
52
|
+
Models::Operations::ListImageMetadataRequest,
|
53
|
+
base_url,
|
54
|
+
'/accounts/{accountID}/images',
|
55
|
+
request,
|
56
|
+
@sdk_configuration.globals
|
57
|
+
)
|
58
|
+
headers = Utils.get_headers(request, @sdk_configuration.globals)
|
59
|
+
headers = T.cast(headers, T::Hash[String, String])
|
60
|
+
headers['Accept'] = 'application/json'
|
61
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
62
|
+
|
63
|
+
security = @sdk_configuration.security_source&.call
|
64
|
+
|
65
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
66
|
+
timeout ||= @sdk_configuration.timeout
|
67
|
+
|
68
|
+
|
69
|
+
connection = @sdk_configuration.client
|
70
|
+
|
71
|
+
hook_ctx = SDKHooks::HookContext.new(
|
72
|
+
config: @sdk_configuration,
|
73
|
+
base_url: base_url,
|
74
|
+
oauth2_scopes: [],
|
75
|
+
operation_id: 'listImageMetadata',
|
76
|
+
security_source: @sdk_configuration.security_source
|
77
|
+
)
|
78
|
+
|
79
|
+
error = T.let(nil, T.nilable(StandardError))
|
80
|
+
http_response = T.let(nil, T.nilable(Faraday::Response))
|
81
|
+
|
82
|
+
|
83
|
+
begin
|
84
|
+
http_response = T.must(connection).get(url) do |req|
|
85
|
+
req.headers.merge!(headers)
|
86
|
+
req.options.timeout = timeout unless timeout.nil?
|
87
|
+
Utils.configure_request_security(req, security)
|
88
|
+
|
89
|
+
@sdk_configuration.hooks.before_request(
|
90
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
91
|
+
hook_ctx: hook_ctx
|
92
|
+
),
|
93
|
+
request: req
|
94
|
+
)
|
95
|
+
end
|
96
|
+
rescue StandardError => e
|
97
|
+
error = e
|
98
|
+
ensure
|
99
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
100
|
+
http_response = @sdk_configuration.hooks.after_error(
|
101
|
+
error: error,
|
102
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
103
|
+
hook_ctx: hook_ctx
|
104
|
+
),
|
105
|
+
response: http_response
|
106
|
+
)
|
107
|
+
else
|
108
|
+
http_response = @sdk_configuration.hooks.after_success(
|
109
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
110
|
+
hook_ctx: hook_ctx
|
111
|
+
),
|
112
|
+
response: http_response
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
if http_response.nil?
|
117
|
+
raise error if !error.nil?
|
118
|
+
raise 'no response'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
123
|
+
if Utils.match_status_code(http_response.status, ['200'])
|
124
|
+
if Utils.match_content_type(content_type, 'application/json')
|
125
|
+
http_response = @sdk_configuration.hooks.after_success(
|
126
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
127
|
+
hook_ctx: hook_ctx
|
128
|
+
),
|
129
|
+
response: http_response
|
130
|
+
)
|
131
|
+
response_data = http_response.env.response_body
|
132
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Crystalline::Array.new(Models::Components::ImageMetadata))
|
133
|
+
response = Models::Operations::ListImageMetadataResponse.new(
|
134
|
+
status_code: http_response.status,
|
135
|
+
content_type: content_type,
|
136
|
+
raw_response: http_response,
|
137
|
+
headers: http_response.headers,
|
138
|
+
image_metadata: T.unsafe(obj)
|
139
|
+
)
|
140
|
+
|
141
|
+
return response
|
142
|
+
else
|
143
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
144
|
+
end
|
145
|
+
elsif Utils.match_status_code(http_response.status, ['401', '403', '429'])
|
146
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
147
|
+
elsif Utils.match_status_code(http_response.status, ['500', '504'])
|
148
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
149
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
150
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
151
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
152
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
153
|
+
else
|
154
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
sig { params(account_id: ::String, image_id: ::String, x_moov_version: T.nilable(::String), timeout_ms: T.nilable(Integer)).returns(Models::Operations::GetImageMetadataResponse) }
|
161
|
+
def get_metadata(account_id:, image_id:, x_moov_version: nil, timeout_ms: nil)
|
162
|
+
# get_metadata - Retrieve metadata for a specific image by its ID.
|
163
|
+
request = Models::Operations::GetImageMetadataRequest.new(
|
164
|
+
account_id: account_id,
|
165
|
+
image_id: image_id,
|
166
|
+
x_moov_version: x_moov_version
|
167
|
+
)
|
168
|
+
url, params = @sdk_configuration.get_server_details
|
169
|
+
base_url = Utils.template_url(url, params)
|
170
|
+
url = Utils.generate_url(
|
171
|
+
Models::Operations::GetImageMetadataRequest,
|
172
|
+
base_url,
|
173
|
+
'/accounts/{accountID}/images/{imageID}',
|
174
|
+
request,
|
175
|
+
@sdk_configuration.globals
|
176
|
+
)
|
177
|
+
headers = Utils.get_headers(request, @sdk_configuration.globals)
|
178
|
+
headers = T.cast(headers, T::Hash[String, String])
|
179
|
+
headers['Accept'] = 'application/json'
|
180
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
181
|
+
|
182
|
+
security = @sdk_configuration.security_source&.call
|
183
|
+
|
184
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
185
|
+
timeout ||= @sdk_configuration.timeout
|
186
|
+
|
187
|
+
|
188
|
+
connection = @sdk_configuration.client
|
189
|
+
|
190
|
+
hook_ctx = SDKHooks::HookContext.new(
|
191
|
+
config: @sdk_configuration,
|
192
|
+
base_url: base_url,
|
193
|
+
oauth2_scopes: [],
|
194
|
+
operation_id: 'getImageMetadata',
|
195
|
+
security_source: @sdk_configuration.security_source
|
196
|
+
)
|
197
|
+
|
198
|
+
error = T.let(nil, T.nilable(StandardError))
|
199
|
+
http_response = T.let(nil, T.nilable(Faraday::Response))
|
200
|
+
|
201
|
+
|
202
|
+
begin
|
203
|
+
http_response = T.must(connection).get(url) do |req|
|
204
|
+
req.headers.merge!(headers)
|
205
|
+
req.options.timeout = timeout unless timeout.nil?
|
206
|
+
Utils.configure_request_security(req, security)
|
207
|
+
|
208
|
+
@sdk_configuration.hooks.before_request(
|
209
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
210
|
+
hook_ctx: hook_ctx
|
211
|
+
),
|
212
|
+
request: req
|
213
|
+
)
|
214
|
+
end
|
215
|
+
rescue StandardError => e
|
216
|
+
error = e
|
217
|
+
ensure
|
218
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
219
|
+
http_response = @sdk_configuration.hooks.after_error(
|
220
|
+
error: error,
|
221
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
222
|
+
hook_ctx: hook_ctx
|
223
|
+
),
|
224
|
+
response: http_response
|
225
|
+
)
|
226
|
+
else
|
227
|
+
http_response = @sdk_configuration.hooks.after_success(
|
228
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
229
|
+
hook_ctx: hook_ctx
|
230
|
+
),
|
231
|
+
response: http_response
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
if http_response.nil?
|
236
|
+
raise error if !error.nil?
|
237
|
+
raise 'no response'
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
242
|
+
if Utils.match_status_code(http_response.status, ['200'])
|
243
|
+
if Utils.match_content_type(content_type, 'application/json')
|
244
|
+
http_response = @sdk_configuration.hooks.after_success(
|
245
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
246
|
+
hook_ctx: hook_ctx
|
247
|
+
),
|
248
|
+
response: http_response
|
249
|
+
)
|
250
|
+
response_data = http_response.env.response_body
|
251
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::ImageMetadata)
|
252
|
+
response = Models::Operations::GetImageMetadataResponse.new(
|
253
|
+
status_code: http_response.status,
|
254
|
+
content_type: content_type,
|
255
|
+
raw_response: http_response,
|
256
|
+
headers: http_response.headers,
|
257
|
+
image_metadata: T.unsafe(obj)
|
258
|
+
)
|
259
|
+
|
260
|
+
return response
|
261
|
+
else
|
262
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
263
|
+
end
|
264
|
+
elsif Utils.match_status_code(http_response.status, ['401', '403', '404', '429'])
|
265
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
266
|
+
elsif Utils.match_status_code(http_response.status, ['500', '504'])
|
267
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
268
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
269
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
270
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
271
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
272
|
+
else
|
273
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
274
|
+
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
|
279
|
+
sig { params(account_id: ::String, image_id: ::String, x_moov_version: T.nilable(::String), timeout_ms: T.nilable(Integer)).returns(Models::Operations::DeleteImageResponse) }
|
280
|
+
def delete(account_id:, image_id:, x_moov_version: nil, timeout_ms: nil)
|
281
|
+
# delete - Permanently delete an image by its ID.
|
282
|
+
request = Models::Operations::DeleteImageRequest.new(
|
283
|
+
account_id: account_id,
|
284
|
+
image_id: image_id,
|
285
|
+
x_moov_version: x_moov_version
|
286
|
+
)
|
287
|
+
url, params = @sdk_configuration.get_server_details
|
288
|
+
base_url = Utils.template_url(url, params)
|
289
|
+
url = Utils.generate_url(
|
290
|
+
Models::Operations::DeleteImageRequest,
|
291
|
+
base_url,
|
292
|
+
'/accounts/{accountID}/images/{imageID}',
|
293
|
+
request,
|
294
|
+
@sdk_configuration.globals
|
295
|
+
)
|
296
|
+
headers = Utils.get_headers(request, @sdk_configuration.globals)
|
297
|
+
headers = T.cast(headers, T::Hash[String, String])
|
298
|
+
headers['Accept'] = 'application/json'
|
299
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
300
|
+
|
301
|
+
security = @sdk_configuration.security_source&.call
|
302
|
+
|
303
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
304
|
+
timeout ||= @sdk_configuration.timeout
|
305
|
+
|
306
|
+
|
307
|
+
connection = @sdk_configuration.client
|
308
|
+
|
309
|
+
hook_ctx = SDKHooks::HookContext.new(
|
310
|
+
config: @sdk_configuration,
|
311
|
+
base_url: base_url,
|
312
|
+
oauth2_scopes: [],
|
313
|
+
operation_id: 'deleteImage',
|
314
|
+
security_source: @sdk_configuration.security_source
|
315
|
+
)
|
316
|
+
|
317
|
+
error = T.let(nil, T.nilable(StandardError))
|
318
|
+
http_response = T.let(nil, T.nilable(Faraday::Response))
|
319
|
+
|
320
|
+
|
321
|
+
begin
|
322
|
+
http_response = T.must(connection).delete(url) do |req|
|
323
|
+
req.headers.merge!(headers)
|
324
|
+
req.options.timeout = timeout unless timeout.nil?
|
325
|
+
Utils.configure_request_security(req, security)
|
326
|
+
|
327
|
+
@sdk_configuration.hooks.before_request(
|
328
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
329
|
+
hook_ctx: hook_ctx
|
330
|
+
),
|
331
|
+
request: req
|
332
|
+
)
|
333
|
+
end
|
334
|
+
rescue StandardError => e
|
335
|
+
error = e
|
336
|
+
ensure
|
337
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
338
|
+
http_response = @sdk_configuration.hooks.after_error(
|
339
|
+
error: error,
|
340
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
341
|
+
hook_ctx: hook_ctx
|
342
|
+
),
|
343
|
+
response: http_response
|
344
|
+
)
|
345
|
+
else
|
346
|
+
http_response = @sdk_configuration.hooks.after_success(
|
347
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
348
|
+
hook_ctx: hook_ctx
|
349
|
+
),
|
350
|
+
response: http_response
|
351
|
+
)
|
352
|
+
end
|
353
|
+
|
354
|
+
if http_response.nil?
|
355
|
+
raise error if !error.nil?
|
356
|
+
raise 'no response'
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
361
|
+
if Utils.match_status_code(http_response.status, ['204'])
|
362
|
+
http_response = @sdk_configuration.hooks.after_success(
|
363
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
364
|
+
hook_ctx: hook_ctx
|
365
|
+
),
|
366
|
+
response: http_response
|
367
|
+
)
|
368
|
+
return Models::Operations::DeleteImageResponse.new(
|
369
|
+
status_code: http_response.status,
|
370
|
+
content_type: content_type,
|
371
|
+
raw_response: http_response,
|
372
|
+
headers: {}
|
373
|
+
)
|
374
|
+
elsif Utils.match_status_code(http_response.status, ['400', '409'])
|
375
|
+
if Utils.match_content_type(content_type, 'application/json')
|
376
|
+
http_response = @sdk_configuration.hooks.after_success(
|
377
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
378
|
+
hook_ctx: hook_ctx
|
379
|
+
),
|
380
|
+
response: http_response
|
381
|
+
)
|
382
|
+
response_data = http_response.env.response_body
|
383
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::GenericError)
|
384
|
+
obj.raw_response = http_response
|
385
|
+
raise obj
|
386
|
+
else
|
387
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
388
|
+
end
|
389
|
+
elsif Utils.match_status_code(http_response.status, ['401', '403', '404', '429'])
|
390
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
391
|
+
elsif Utils.match_status_code(http_response.status, ['500', '504'])
|
392
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
393
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
394
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
395
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
396
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
397
|
+
else
|
398
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
399
|
+
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
|
404
|
+
sig { params(public_id: ::String, if_none_match: T.nilable(::String), size: T.nilable(::String), timeout_ms: T.nilable(Integer)).returns(Models::Operations::GetPublicImageResponse) }
|
405
|
+
def get_public(public_id:, if_none_match: nil, size: nil, timeout_ms: nil)
|
406
|
+
# get_public - Get an image by its public ID.
|
407
|
+
request = Models::Operations::GetPublicImageRequest.new(
|
408
|
+
public_id: public_id,
|
409
|
+
if_none_match: if_none_match,
|
410
|
+
size: size
|
411
|
+
)
|
412
|
+
url, params = @sdk_configuration.get_server_details
|
413
|
+
base_url = Utils.template_url(url, params)
|
414
|
+
url = Utils.generate_url(
|
415
|
+
Models::Operations::GetPublicImageRequest,
|
416
|
+
base_url,
|
417
|
+
'/images/{publicID}',
|
418
|
+
request,
|
419
|
+
@sdk_configuration.globals
|
420
|
+
)
|
421
|
+
headers = Utils.get_headers(request, @sdk_configuration.globals)
|
422
|
+
headers = T.cast(headers, T::Hash[String, String])
|
423
|
+
query_params = Utils.get_query_params(Models::Operations::GetPublicImageRequest, request, nil, @sdk_configuration.globals)
|
424
|
+
headers['Accept'] = 'image/jpeg;q=1, image/png;q=0.7, image/webp;q=0'
|
425
|
+
headers['user-agent'] = @sdk_configuration.user_agent
|
426
|
+
|
427
|
+
security = @sdk_configuration.security_source&.call
|
428
|
+
|
429
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
430
|
+
timeout ||= @sdk_configuration.timeout
|
431
|
+
|
432
|
+
|
433
|
+
connection = @sdk_configuration.client
|
434
|
+
|
435
|
+
hook_ctx = SDKHooks::HookContext.new(
|
436
|
+
config: @sdk_configuration,
|
437
|
+
base_url: base_url,
|
438
|
+
oauth2_scopes: [],
|
439
|
+
operation_id: 'getPublicImage',
|
440
|
+
security_source: @sdk_configuration.security_source
|
441
|
+
)
|
442
|
+
|
443
|
+
error = T.let(nil, T.nilable(StandardError))
|
444
|
+
http_response = T.let(nil, T.nilable(Faraday::Response))
|
445
|
+
|
446
|
+
|
447
|
+
begin
|
448
|
+
http_response = T.must(connection).get(url) do |req|
|
449
|
+
req.headers.merge!(headers)
|
450
|
+
req.options.timeout = timeout unless timeout.nil?
|
451
|
+
req.params = query_params
|
452
|
+
Utils.configure_request_security(req, security)
|
453
|
+
|
454
|
+
@sdk_configuration.hooks.before_request(
|
455
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
456
|
+
hook_ctx: hook_ctx
|
457
|
+
),
|
458
|
+
request: req
|
459
|
+
)
|
460
|
+
end
|
461
|
+
rescue StandardError => e
|
462
|
+
error = e
|
463
|
+
ensure
|
464
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
465
|
+
http_response = @sdk_configuration.hooks.after_error(
|
466
|
+
error: error,
|
467
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
468
|
+
hook_ctx: hook_ctx
|
469
|
+
),
|
470
|
+
response: http_response
|
471
|
+
)
|
472
|
+
else
|
473
|
+
http_response = @sdk_configuration.hooks.after_success(
|
474
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
475
|
+
hook_ctx: hook_ctx
|
476
|
+
),
|
477
|
+
response: http_response
|
478
|
+
)
|
479
|
+
end
|
480
|
+
|
481
|
+
if http_response.nil?
|
482
|
+
raise error if !error.nil?
|
483
|
+
raise 'no response'
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
|
488
|
+
if Utils.match_status_code(http_response.status, ['200'])
|
489
|
+
if Utils.match_content_type(content_type, 'image/webp')
|
490
|
+
http_response = @sdk_configuration.hooks.after_success(
|
491
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
492
|
+
hook_ctx: hook_ctx
|
493
|
+
),
|
494
|
+
response: http_response
|
495
|
+
)
|
496
|
+
obj = http_response.env.body
|
497
|
+
|
498
|
+
return Models::Operations::GetPublicImageResponse.new(
|
499
|
+
status_code: http_response.status,
|
500
|
+
content_type: content_type,
|
501
|
+
raw_response: http_response,
|
502
|
+
headers: http_response.headers,
|
503
|
+
two_hundred_image_webp_bytes: T.unsafe(obj)
|
504
|
+
)
|
505
|
+
elsif Utils.match_content_type(content_type, 'image/png')
|
506
|
+
http_response = @sdk_configuration.hooks.after_success(
|
507
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
508
|
+
hook_ctx: hook_ctx
|
509
|
+
),
|
510
|
+
response: http_response
|
511
|
+
)
|
512
|
+
obj = http_response.env.body
|
513
|
+
|
514
|
+
return Models::Operations::GetPublicImageResponse.new(
|
515
|
+
status_code: http_response.status,
|
516
|
+
content_type: content_type,
|
517
|
+
raw_response: http_response,
|
518
|
+
headers: http_response.headers,
|
519
|
+
two_hundred_image_png_bytes: T.unsafe(obj)
|
520
|
+
)
|
521
|
+
elsif Utils.match_content_type(content_type, 'image/jpeg')
|
522
|
+
http_response = @sdk_configuration.hooks.after_success(
|
523
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
524
|
+
hook_ctx: hook_ctx
|
525
|
+
),
|
526
|
+
response: http_response
|
527
|
+
)
|
528
|
+
obj = http_response.env.body
|
529
|
+
|
530
|
+
return Models::Operations::GetPublicImageResponse.new(
|
531
|
+
status_code: http_response.status,
|
532
|
+
content_type: content_type,
|
533
|
+
raw_response: http_response,
|
534
|
+
headers: http_response.headers,
|
535
|
+
two_hundred_image_jpeg_bytes: T.unsafe(obj)
|
536
|
+
)
|
537
|
+
else
|
538
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown content type received'
|
539
|
+
end
|
540
|
+
elsif Utils.match_status_code(http_response.status, ['304'])
|
541
|
+
http_response = @sdk_configuration.hooks.after_success(
|
542
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
543
|
+
hook_ctx: hook_ctx
|
544
|
+
),
|
545
|
+
response: http_response
|
546
|
+
)
|
547
|
+
return Models::Operations::GetPublicImageResponse.new(
|
548
|
+
status_code: http_response.status,
|
549
|
+
content_type: content_type,
|
550
|
+
raw_response: http_response,
|
551
|
+
headers: {}
|
552
|
+
)
|
553
|
+
elsif Utils.match_status_code(http_response.status, ['404', '429'])
|
554
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
555
|
+
elsif Utils.match_status_code(http_response.status, ['500', '502', '504'])
|
556
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
557
|
+
elsif Utils.match_status_code(http_response.status, ['4XX'])
|
558
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
559
|
+
elsif Utils.match_status_code(http_response.status, ['5XX'])
|
560
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'API error occurred'
|
561
|
+
else
|
562
|
+
raise ::Moov::Models::Errors::APIError.new(status_code: http_response.status, body: http_response.env.response_body, raw_response: http_response), 'Unknown status code received'
|
563
|
+
|
564
|
+
end
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
2
|
+
|
3
|
+
# typed: true
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
|
7
|
+
module Moov
|
8
|
+
module Models
|
9
|
+
module Components
|
10
|
+
|
11
|
+
# Metadata about an uploaded image.
|
12
|
+
class ImageMetadata
|
13
|
+
extend T::Sig
|
14
|
+
include Crystalline::MetadataFields
|
15
|
+
|
16
|
+
|
17
|
+
field :image_id, ::String, { 'format_json': { 'letter_case': ::Moov::Utils.field_name('imageID'), required: true } }
|
18
|
+
# A public URL to access the image. An optional `size={width}x{height}`
|
19
|
+
# query parameter can be provided to resize the image.
|
20
|
+
field :link, ::String, { 'format_json': { 'letter_case': ::Moov::Utils.field_name('link'), required: true } }
|
21
|
+
|
22
|
+
field :created_on, ::DateTime, { 'format_json': { 'letter_case': ::Moov::Utils.field_name('createdOn'), required: true, 'decoder': Utils.datetime_from_iso_format(false) } }
|
23
|
+
|
24
|
+
field :updated_on, ::DateTime, { 'format_json': { 'letter_case': ::Moov::Utils.field_name('updatedOn'), required: true, 'decoder': Utils.datetime_from_iso_format(false) } }
|
25
|
+
# Alternative text for the image.
|
26
|
+
field :alt_text, Crystalline::Nilable.new(::String), { 'format_json': { 'letter_case': ::Moov::Utils.field_name('altText') } }
|
27
|
+
|
28
|
+
sig { params(image_id: ::String, link: ::String, created_on: ::DateTime, updated_on: ::DateTime, alt_text: T.nilable(::String)).void }
|
29
|
+
def initialize(image_id:, link:, created_on:, updated_on:, alt_text: nil)
|
30
|
+
@image_id = image_id
|
31
|
+
@link = link
|
32
|
+
@created_on = created_on
|
33
|
+
@updated_on = updated_on
|
34
|
+
@alt_text = alt_text
|
35
|
+
end
|
36
|
+
|
37
|
+
sig { params(other: T.untyped).returns(T::Boolean) }
|
38
|
+
def ==(other)
|
39
|
+
return false unless other.is_a? self.class
|
40
|
+
return false unless @image_id == other.image_id
|
41
|
+
return false unless @link == other.link
|
42
|
+
return false unless @created_on == other.created_on
|
43
|
+
return false unless @updated_on == other.updated_on
|
44
|
+
return false unless @alt_text == other.alt_text
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
|
5
|
+
class Moov::Models::Components::ImageMetadata
|
6
|
+
extend ::Crystalline::MetadataFields::ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
class Moov::Models::Components::ImageMetadata
|
11
|
+
def image_id(); end
|
12
|
+
def image_id=(str_); end
|
13
|
+
def link(); end
|
14
|
+
def link=(str_); end
|
15
|
+
def created_on(); end
|
16
|
+
def created_on=(str_); end
|
17
|
+
def updated_on(); end
|
18
|
+
def updated_on=(str_); end
|
19
|
+
def alt_text(); end
|
20
|
+
def alt_text=(str_); end
|
21
|
+
end
|