maytes-api-client-rb 0.1.1
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 +7 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +47 -0
- data/Rakefile +10 -0
- data/docs/CancelCheckout409Response.md +24 -0
- data/docs/CancelCheckoutRequest.md +18 -0
- data/docs/CancelCheckoutResponse.md +18 -0
- data/docs/CaptureCheckout409Response.md +24 -0
- data/docs/CaptureCheckout422Response.md +24 -0
- data/docs/CaptureCheckoutRequest.md +24 -0
- data/docs/CaptureCheckoutResponse.md +18 -0
- data/docs/Checkout.md +48 -0
- data/docs/CheckoutCancelled.md +22 -0
- data/docs/CheckoutCaptured.md +28 -0
- data/docs/CheckoutCreated.md +24 -0
- data/docs/CheckoutDiscount.md +30 -0
- data/docs/CheckoutFee.md +32 -0
- data/docs/CreateCheckout401Response.md +24 -0
- data/docs/CreateCheckout409Response.md +24 -0
- data/docs/CreateCheckout422Response.md +24 -0
- data/docs/CreateCheckoutRequest.md +44 -0
- data/docs/CreateCheckoutResponse.md +18 -0
- data/docs/CreateRefundRequest.md +20 -0
- data/docs/CustomerData.md +22 -0
- data/docs/DefaultApi.md +633 -0
- data/docs/DigitalGoodsCustomData.md +18 -0
- data/docs/DigitalGoodsLineItem.md +38 -0
- data/docs/DonationLineItem.md +36 -0
- data/docs/ErrorResponseDto.md +24 -0
- data/docs/Fee.md +24 -0
- data/docs/FeeBreakdownLine.md +24 -0
- data/docs/FoodBeverageLineItem.md +36 -0
- data/docs/GetCheckout404Response.md +24 -0
- data/docs/GetCheckout422Response.md +24 -0
- data/docs/GetCheckoutResponse.md +18 -0
- data/docs/GetSettlementResponse.md +18 -0
- data/docs/HealthResponse.md +18 -0
- data/docs/LineItem.md +94 -0
- data/docs/ListSettlementsResponse.md +18 -0
- data/docs/OAuthTokenRequest.md +30 -0
- data/docs/OAuthTokenResponse.md +26 -0
- data/docs/OtherLineItem.md +36 -0
- data/docs/PhysicalGoodsCustomData.md +20 -0
- data/docs/PhysicalGoodsLineItem.md +38 -0
- data/docs/RefundCheckout402Response.md +24 -0
- data/docs/RefundCheckout409Response.md +24 -0
- data/docs/ServiceCustomData.md +18 -0
- data/docs/ServiceLineItem.md +38 -0
- data/docs/Settlement.md +52 -0
- data/docs/Tax.md +22 -0
- data/docs/TicketCustomData.md +40 -0
- data/docs/TicketLineItem.md +38 -0
- data/docs/TicketSeating.md +24 -0
- data/lib/maytes_api_client/api/default_api.rb +642 -0
- data/lib/maytes_api_client/api_client.rb +397 -0
- data/lib/maytes_api_client/api_error.rb +58 -0
- data/lib/maytes_api_client/api_model_base.rb +88 -0
- data/lib/maytes_api_client/configuration.rb +316 -0
- data/lib/maytes_api_client/managed_client.rb +140 -0
- data/lib/maytes_api_client/models/cancel_checkout409_response.rb +258 -0
- data/lib/maytes_api_client/models/cancel_checkout_request.rb +147 -0
- data/lib/maytes_api_client/models/cancel_checkout_response.rb +164 -0
- data/lib/maytes_api_client/models/capture_checkout409_response.rb +258 -0
- data/lib/maytes_api_client/models/capture_checkout422_response.rb +258 -0
- data/lib/maytes_api_client/models/capture_checkout_request.rb +218 -0
- data/lib/maytes_api_client/models/capture_checkout_response.rb +164 -0
- data/lib/maytes_api_client/models/checkout.rb +483 -0
- data/lib/maytes_api_client/models/checkout_cancelled.rb +202 -0
- data/lib/maytes_api_client/models/checkout_captured.rb +266 -0
- data/lib/maytes_api_client/models/checkout_created.rb +242 -0
- data/lib/maytes_api_client/models/checkout_discount.rb +329 -0
- data/lib/maytes_api_client/models/checkout_fee.rb +351 -0
- data/lib/maytes_api_client/models/create_checkout401_response.rb +258 -0
- data/lib/maytes_api_client/models/create_checkout409_response.rb +258 -0
- data/lib/maytes_api_client/models/create_checkout422_response.rb +258 -0
- data/lib/maytes_api_client/models/create_checkout_request.rb +444 -0
- data/lib/maytes_api_client/models/create_checkout_response.rb +164 -0
- data/lib/maytes_api_client/models/create_refund_request.rb +212 -0
- data/lib/maytes_api_client/models/customer_data.rb +168 -0
- data/lib/maytes_api_client/models/digital_goods_custom_data.rb +148 -0
- data/lib/maytes_api_client/models/digital_goods_line_item.rb +414 -0
- data/lib/maytes_api_client/models/donation_line_item.rb +405 -0
- data/lib/maytes_api_client/models/error_response_dto.rb +227 -0
- data/lib/maytes_api_client/models/fee.rb +271 -0
- data/lib/maytes_api_client/models/fee_breakdown_line.rb +266 -0
- data/lib/maytes_api_client/models/food_beverage_line_item.rb +405 -0
- data/lib/maytes_api_client/models/get_checkout404_response.rb +258 -0
- data/lib/maytes_api_client/models/get_checkout422_response.rb +258 -0
- data/lib/maytes_api_client/models/get_checkout_response.rb +164 -0
- data/lib/maytes_api_client/models/get_settlement_response.rb +164 -0
- data/lib/maytes_api_client/models/health_response.rb +164 -0
- data/lib/maytes_api_client/models/line_item.rb +65 -0
- data/lib/maytes_api_client/models/list_settlements_response.rb +166 -0
- data/lib/maytes_api_client/models/o_auth_token_request.rb +244 -0
- data/lib/maytes_api_client/models/o_auth_token_response.rb +251 -0
- data/lib/maytes_api_client/models/other_line_item.rb +405 -0
- data/lib/maytes_api_client/models/physical_goods_custom_data.rb +173 -0
- data/lib/maytes_api_client/models/physical_goods_line_item.rb +431 -0
- data/lib/maytes_api_client/models/refund_checkout402_response.rb +258 -0
- data/lib/maytes_api_client/models/refund_checkout409_response.rb +258 -0
- data/lib/maytes_api_client/models/service_custom_data.rb +148 -0
- data/lib/maytes_api_client/models/service_line_item.rb +414 -0
- data/lib/maytes_api_client/models/settlement.rb +526 -0
- data/lib/maytes_api_client/models/tax.rb +202 -0
- data/lib/maytes_api_client/models/ticket_custom_data.rb +333 -0
- data/lib/maytes_api_client/models/ticket_line_item.rb +431 -0
- data/lib/maytes_api_client/models/ticket_seating.rb +176 -0
- data/lib/maytes_api_client/version.rb +15 -0
- data/lib/maytes_api_client/webhook_verifier.rb +212 -0
- data/lib/maytes_api_client.rb +95 -0
- data/maytes_api_client.gemspec +39 -0
- data/spec/api/default_api_spec.rb +145 -0
- data/spec/models/cancel_checkout409_response_spec.rb +58 -0
- data/spec/models/cancel_checkout_request_spec.rb +36 -0
- data/spec/models/cancel_checkout_response_spec.rb +36 -0
- data/spec/models/capture_checkout409_response_spec.rb +58 -0
- data/spec/models/capture_checkout422_response_spec.rb +58 -0
- data/spec/models/capture_checkout_request_spec.rb +54 -0
- data/spec/models/capture_checkout_response_spec.rb +36 -0
- data/spec/models/checkout_cancelled_spec.rb +48 -0
- data/spec/models/checkout_captured_spec.rb +66 -0
- data/spec/models/checkout_created_spec.rb +54 -0
- data/spec/models/checkout_discount_spec.rb +76 -0
- data/spec/models/checkout_fee_spec.rb +86 -0
- data/spec/models/checkout_spec.rb +126 -0
- data/spec/models/create_checkout401_response_spec.rb +58 -0
- data/spec/models/create_checkout409_response_spec.rb +58 -0
- data/spec/models/create_checkout422_response_spec.rb +58 -0
- data/spec/models/create_checkout_request_spec.rb +118 -0
- data/spec/models/create_checkout_response_spec.rb +36 -0
- data/spec/models/create_refund_request_spec.rb +42 -0
- data/spec/models/customer_data_spec.rb +48 -0
- data/spec/models/digital_goods_custom_data_spec.rb +36 -0
- data/spec/models/digital_goods_line_item_spec.rb +100 -0
- data/spec/models/donation_line_item_spec.rb +94 -0
- data/spec/models/error_response_dto_spec.rb +54 -0
- data/spec/models/fee_breakdown_line_spec.rb +58 -0
- data/spec/models/fee_spec.rb +54 -0
- data/spec/models/food_beverage_line_item_spec.rb +94 -0
- data/spec/models/get_checkout404_response_spec.rb +58 -0
- data/spec/models/get_checkout422_response_spec.rb +58 -0
- data/spec/models/get_checkout_response_spec.rb +36 -0
- data/spec/models/get_settlement_response_spec.rb +36 -0
- data/spec/models/health_response_spec.rb +36 -0
- data/spec/models/line_item_spec.rb +44 -0
- data/spec/models/list_settlements_response_spec.rb +36 -0
- data/spec/models/o_auth_token_request_spec.rb +72 -0
- data/spec/models/o_auth_token_response_spec.rb +60 -0
- data/spec/models/other_line_item_spec.rb +94 -0
- data/spec/models/physical_goods_custom_data_spec.rb +42 -0
- data/spec/models/physical_goods_line_item_spec.rb +100 -0
- data/spec/models/refund_checkout402_response_spec.rb +58 -0
- data/spec/models/refund_checkout409_response_spec.rb +58 -0
- data/spec/models/service_custom_data_spec.rb +36 -0
- data/spec/models/service_line_item_spec.rb +100 -0
- data/spec/models/settlement_spec.rb +138 -0
- data/spec/models/tax_spec.rb +48 -0
- data/spec/models/ticket_custom_data_spec.rb +106 -0
- data/spec/models/ticket_line_item_spec.rb +100 -0
- data/spec/models/ticket_seating_spec.rb +54 -0
- data/spec/spec_helper.rb +111 -0
- metadata +295 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Maytes API
|
|
3
|
+
|
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
module MaytesApiClient
|
|
14
|
+
class Configuration
|
|
15
|
+
# Defines url scheme
|
|
16
|
+
attr_accessor :scheme
|
|
17
|
+
|
|
18
|
+
# Defines url host
|
|
19
|
+
attr_accessor :host
|
|
20
|
+
|
|
21
|
+
# Defines url base path
|
|
22
|
+
attr_accessor :base_path
|
|
23
|
+
|
|
24
|
+
# Define server configuration index
|
|
25
|
+
attr_accessor :server_index
|
|
26
|
+
|
|
27
|
+
# Define server operation configuration index
|
|
28
|
+
attr_accessor :server_operation_index
|
|
29
|
+
|
|
30
|
+
# Default server variables
|
|
31
|
+
attr_accessor :server_variables
|
|
32
|
+
|
|
33
|
+
# Default server operation variables
|
|
34
|
+
attr_accessor :server_operation_variables
|
|
35
|
+
|
|
36
|
+
# Defines API keys used with API Key authentications.
|
|
37
|
+
#
|
|
38
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
|
39
|
+
#
|
|
40
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
|
41
|
+
# config.api_key['api_key'] = 'xxx'
|
|
42
|
+
attr_accessor :api_key
|
|
43
|
+
|
|
44
|
+
# Defines API key prefixes used with API Key authentications.
|
|
45
|
+
#
|
|
46
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
|
47
|
+
#
|
|
48
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
|
49
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
|
50
|
+
attr_accessor :api_key_prefix
|
|
51
|
+
|
|
52
|
+
# Defines the username used with HTTP basic authentication.
|
|
53
|
+
#
|
|
54
|
+
# @return [String]
|
|
55
|
+
attr_accessor :username
|
|
56
|
+
|
|
57
|
+
# Defines the password used with HTTP basic authentication.
|
|
58
|
+
#
|
|
59
|
+
# @return [String]
|
|
60
|
+
attr_accessor :password
|
|
61
|
+
|
|
62
|
+
# Defines the access token (Bearer) used with OAuth2.
|
|
63
|
+
attr_accessor :access_token
|
|
64
|
+
|
|
65
|
+
# Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
|
|
66
|
+
# Overrides the access_token if set
|
|
67
|
+
# @return [Proc]
|
|
68
|
+
attr_accessor :access_token_getter
|
|
69
|
+
|
|
70
|
+
# Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
|
|
71
|
+
# HTTP responses with return type `File` will be returned as a stream of binary data.
|
|
72
|
+
# Default to false.
|
|
73
|
+
attr_accessor :return_binary_data
|
|
74
|
+
|
|
75
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
|
76
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
|
77
|
+
# Default to false.
|
|
78
|
+
#
|
|
79
|
+
# @return [true, false]
|
|
80
|
+
attr_accessor :debugging
|
|
81
|
+
|
|
82
|
+
# Set this to ignore operation servers for the API client. This is useful when you need to
|
|
83
|
+
# send requests to a different server than the one specified in the OpenAPI document.
|
|
84
|
+
# Will default to the base url defined in the spec but can be overridden by setting
|
|
85
|
+
# `scheme`, `host`, `base_path` directly.
|
|
86
|
+
# Default to false.
|
|
87
|
+
# @return [true, false]
|
|
88
|
+
attr_accessor :ignore_operation_servers
|
|
89
|
+
|
|
90
|
+
# Defines the logger used for debugging.
|
|
91
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
|
92
|
+
#
|
|
93
|
+
# @return [#debug]
|
|
94
|
+
attr_accessor :logger
|
|
95
|
+
|
|
96
|
+
# Defines the temporary folder to store downloaded files
|
|
97
|
+
# (for API endpoints that have file response).
|
|
98
|
+
# Default to use `Tempfile`.
|
|
99
|
+
#
|
|
100
|
+
# @return [String]
|
|
101
|
+
attr_accessor :temp_folder_path
|
|
102
|
+
|
|
103
|
+
# The time limit for HTTP request in seconds.
|
|
104
|
+
# Default to 0 (never times out).
|
|
105
|
+
attr_accessor :timeout
|
|
106
|
+
|
|
107
|
+
# Set this to false to skip client side validation in the operation.
|
|
108
|
+
# Default to true.
|
|
109
|
+
# @return [true, false]
|
|
110
|
+
attr_accessor :client_side_validation
|
|
111
|
+
|
|
112
|
+
### TLS/SSL setting
|
|
113
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
|
114
|
+
# Default to true.
|
|
115
|
+
#
|
|
116
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
|
117
|
+
#
|
|
118
|
+
# @return [true, false]
|
|
119
|
+
attr_accessor :verify_ssl
|
|
120
|
+
|
|
121
|
+
### TLS/SSL setting
|
|
122
|
+
# Set this to false to skip verifying SSL host name
|
|
123
|
+
# Default to true.
|
|
124
|
+
#
|
|
125
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
|
126
|
+
#
|
|
127
|
+
# @return [true, false]
|
|
128
|
+
attr_accessor :verify_ssl_host
|
|
129
|
+
|
|
130
|
+
### TLS/SSL setting
|
|
131
|
+
# Set this to customize the certificate file to verify the peer.
|
|
132
|
+
#
|
|
133
|
+
# @return [String] the path to the certificate file
|
|
134
|
+
#
|
|
135
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
|
136
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
|
137
|
+
attr_accessor :ssl_ca_cert
|
|
138
|
+
|
|
139
|
+
### TLS/SSL setting
|
|
140
|
+
# Client certificate file (for client certificate)
|
|
141
|
+
attr_accessor :cert_file
|
|
142
|
+
|
|
143
|
+
### TLS/SSL setting
|
|
144
|
+
# Client private key file (for client certificate)
|
|
145
|
+
attr_accessor :key_file
|
|
146
|
+
|
|
147
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
|
148
|
+
# Default to nil.
|
|
149
|
+
#
|
|
150
|
+
# @see The params_encoding option of Ethon. Related source code:
|
|
151
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
|
152
|
+
attr_accessor :params_encoding
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
attr_accessor :inject_format
|
|
156
|
+
|
|
157
|
+
attr_accessor :force_ending_format
|
|
158
|
+
|
|
159
|
+
def initialize
|
|
160
|
+
@scheme = 'http'
|
|
161
|
+
@host = 'localhost'
|
|
162
|
+
@base_path = ''
|
|
163
|
+
@server_index = nil
|
|
164
|
+
@server_operation_index = {}
|
|
165
|
+
@server_variables = {}
|
|
166
|
+
@server_operation_variables = {}
|
|
167
|
+
@api_key = {}
|
|
168
|
+
@api_key_prefix = {}
|
|
169
|
+
@client_side_validation = true
|
|
170
|
+
@verify_ssl = true
|
|
171
|
+
@verify_ssl_host = true
|
|
172
|
+
@cert_file = nil
|
|
173
|
+
@key_file = nil
|
|
174
|
+
@timeout = 0
|
|
175
|
+
@params_encoding = nil
|
|
176
|
+
@debugging = false
|
|
177
|
+
@ignore_operation_servers = false
|
|
178
|
+
@inject_format = false
|
|
179
|
+
@force_ending_format = false
|
|
180
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
|
181
|
+
|
|
182
|
+
yield(self) if block_given?
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# The default Configuration object.
|
|
186
|
+
def self.default
|
|
187
|
+
@@default ||= Configuration.new
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def configure
|
|
191
|
+
yield(self) if block_given?
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def scheme=(scheme)
|
|
195
|
+
# remove :// from scheme
|
|
196
|
+
@scheme = scheme.sub(/:\/\//, '')
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def host=(host)
|
|
200
|
+
# remove http(s):// and anything after a slash
|
|
201
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def base_path=(base_path)
|
|
205
|
+
# Add leading and trailing slashes to base_path
|
|
206
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
|
207
|
+
@base_path = '' if @base_path == '/'
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Returns base URL for specified operation based on server settings
|
|
211
|
+
def base_url(operation = nil)
|
|
212
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
|
213
|
+
if operation_server_settings.key?(operation) then
|
|
214
|
+
index = server_operation_index.fetch(operation, server_index)
|
|
215
|
+
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
|
216
|
+
else
|
|
217
|
+
server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Gets API key (with prefix if set).
|
|
222
|
+
# @param [String] param_name the parameter name of API key auth
|
|
223
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
|
224
|
+
key = @api_key[param_name]
|
|
225
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
|
226
|
+
if @api_key_prefix[param_name]
|
|
227
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
|
228
|
+
else
|
|
229
|
+
key
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Gets access_token using access_token_getter or uses the static access_token
|
|
234
|
+
def access_token_with_refresh
|
|
235
|
+
return access_token if access_token_getter.nil?
|
|
236
|
+
access_token_getter.call
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Gets Basic Auth token string
|
|
240
|
+
def basic_auth_token
|
|
241
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# Returns Auth Settings hash for api client.
|
|
245
|
+
def auth_settings
|
|
246
|
+
{
|
|
247
|
+
'bearer' =>
|
|
248
|
+
{
|
|
249
|
+
type: 'bearer',
|
|
250
|
+
in: 'header',
|
|
251
|
+
format: 'JWT',
|
|
252
|
+
key: 'Authorization',
|
|
253
|
+
value: "Bearer #{access_token_with_refresh}"
|
|
254
|
+
},
|
|
255
|
+
'basic' =>
|
|
256
|
+
{
|
|
257
|
+
type: 'basic',
|
|
258
|
+
in: 'header',
|
|
259
|
+
key: 'Authorization',
|
|
260
|
+
value: basic_auth_token
|
|
261
|
+
},
|
|
262
|
+
}
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Returns an array of Server setting
|
|
266
|
+
def server_settings
|
|
267
|
+
[
|
|
268
|
+
{
|
|
269
|
+
url: "",
|
|
270
|
+
description: "No description provided",
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def operation_server_settings
|
|
276
|
+
{
|
|
277
|
+
}
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Returns URL based on server settings
|
|
281
|
+
#
|
|
282
|
+
# @param index array index of the server settings
|
|
283
|
+
# @param variables hash of variable and the corresponding value
|
|
284
|
+
def server_url(index, variables = {}, servers = nil)
|
|
285
|
+
servers = server_settings if servers == nil
|
|
286
|
+
|
|
287
|
+
# check array index out of bound
|
|
288
|
+
if (index.nil? || index < 0 || index >= servers.size)
|
|
289
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
server = servers[index]
|
|
293
|
+
url = server[:url]
|
|
294
|
+
|
|
295
|
+
return url unless server.key? :variables
|
|
296
|
+
|
|
297
|
+
# go through variable and assign a value
|
|
298
|
+
server[:variables].each do |name, variable|
|
|
299
|
+
if variables.key?(name)
|
|
300
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
|
301
|
+
url.gsub! "{" + name.to_s + "}", variables[name]
|
|
302
|
+
else
|
|
303
|
+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
|
304
|
+
end
|
|
305
|
+
else
|
|
306
|
+
# use default value
|
|
307
|
+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
url
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
end
|
|
316
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# Bundled with the generated SDK via bin/postprocess-ruby.sh.
|
|
4
|
+
#
|
|
5
|
+
# Lives at build/ruby-client/lib/maytes_api_client/managed_client.rb after
|
|
6
|
+
# `make generate-ruby`. Required from the gem's root file so consumers do:
|
|
7
|
+
#
|
|
8
|
+
# require 'maytes_api_client'
|
|
9
|
+
# api = MaytesApiClient.create_maytes_api_client(
|
|
10
|
+
# endpoint: 'https://api.maytes.co',
|
|
11
|
+
# client_id: '...',
|
|
12
|
+
# client_secret: '...',
|
|
13
|
+
# )
|
|
14
|
+
#
|
|
15
|
+
# Adds OAuth2 client_credentials credential management on top of the raw
|
|
16
|
+
# DefaultApi using a **reactive 401-retry** pattern:
|
|
17
|
+
#
|
|
18
|
+
# 1. First authed call mints a token via GetOAuthToken (a @auth([]) op) and
|
|
19
|
+
# caches it.
|
|
20
|
+
# 2. Subsequent calls send the cached token as-is — no client-side expiry
|
|
21
|
+
# math, no proactive refresh.
|
|
22
|
+
# 3. If the server returns 401, ManagedApiClient catches the ApiError,
|
|
23
|
+
# refreshes the token, and retries the call once. The retried request
|
|
24
|
+
# reads the freshly-cached token via ManagedConfiguration#access_token.
|
|
25
|
+
#
|
|
26
|
+
# Concurrent 401s deduplicate via refresh_if_stale(stale_token): only the first
|
|
27
|
+
# thread to acquire the Mutex mints; others see the cache already updated and
|
|
28
|
+
# use that token.
|
|
29
|
+
|
|
30
|
+
require 'uri'
|
|
31
|
+
|
|
32
|
+
module MaytesApiClient
|
|
33
|
+
class OAuthTokenProvider
|
|
34
|
+
attr_reader :token
|
|
35
|
+
|
|
36
|
+
def initialize(endpoint, client_id, client_secret, initial_token = nil)
|
|
37
|
+
@endpoint = endpoint
|
|
38
|
+
@client_id = client_id
|
|
39
|
+
@client_secret = client_secret
|
|
40
|
+
@token = initial_token
|
|
41
|
+
@mutex = Mutex.new
|
|
42
|
+
|
|
43
|
+
unauthed_config = Configuration.new
|
|
44
|
+
# Configuration#host= strips the scheme and any trailing path, so passing
|
|
45
|
+
# the full endpoint correctly gives "host:port". Using URI(endpoint).host
|
|
46
|
+
# would drop the port and silently route to :80.
|
|
47
|
+
unauthed_config.host = endpoint
|
|
48
|
+
unauthed_config.scheme = URI(endpoint).scheme
|
|
49
|
+
@unauthed_api = DefaultApi.new(ApiClient.new(unauthed_config))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get
|
|
53
|
+
return @token if @token
|
|
54
|
+
|
|
55
|
+
@mutex.synchronize do
|
|
56
|
+
return @token if @token
|
|
57
|
+
|
|
58
|
+
mint_locked
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Refresh only if the cache still holds the stale token observed by the
|
|
63
|
+
# caller. If another thread refreshed first, returns that newer token —
|
|
64
|
+
# no second mint.
|
|
65
|
+
def refresh_if_stale(stale_token)
|
|
66
|
+
@mutex.synchronize do
|
|
67
|
+
return @token if @token && @token != stale_token
|
|
68
|
+
|
|
69
|
+
mint_locked
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def mint_locked
|
|
76
|
+
payload = OAuthTokenRequest.new(
|
|
77
|
+
grant_type: 'client_credentials',
|
|
78
|
+
client_id: @client_id,
|
|
79
|
+
client_secret: @client_secret,
|
|
80
|
+
)
|
|
81
|
+
response = @unauthed_api.get_o_auth_token(payload)
|
|
82
|
+
@token = response.access_token
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Configuration whose access_token always delegates to the provider.
|
|
87
|
+
# Internal — merchants should use MaytesApiClient.create_maytes_api_client.
|
|
88
|
+
class ManagedConfiguration < Configuration
|
|
89
|
+
def initialize(provider, endpoint)
|
|
90
|
+
super()
|
|
91
|
+
# See OAuthTokenProvider#initialize for why host=endpoint (not uri.host).
|
|
92
|
+
self.host = endpoint
|
|
93
|
+
self.scheme = URI(endpoint).scheme
|
|
94
|
+
@provider = provider
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def access_token
|
|
98
|
+
@provider.get
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# ApiClient that intercepts 401 responses (raised as ApiError), refreshes the
|
|
103
|
+
# token, and retries the request once. If the retry also 401s, the second
|
|
104
|
+
# ApiError propagates.
|
|
105
|
+
class ManagedApiClient < ApiClient
|
|
106
|
+
def initialize(config, provider)
|
|
107
|
+
super(config)
|
|
108
|
+
@provider = provider
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def call_api(http_method, path, opts = {})
|
|
112
|
+
stale_token = @provider.token
|
|
113
|
+
super
|
|
114
|
+
rescue ApiError => e
|
|
115
|
+
raise unless e.code == 401
|
|
116
|
+
|
|
117
|
+
@provider.refresh_if_stale(stale_token)
|
|
118
|
+
super
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Factory for fully managed Maytes API clients.
|
|
123
|
+
#
|
|
124
|
+
# api = MaytesApiClient.create_maytes_api_client(
|
|
125
|
+
# endpoint: 'https://api.maytes.co',
|
|
126
|
+
# client_id: '...',
|
|
127
|
+
# client_secret: '...',
|
|
128
|
+
# )
|
|
129
|
+
# result = api.create_checkout(body)
|
|
130
|
+
#
|
|
131
|
+
# `initial_token` is an SDK-test-only escape hatch — seeds the cache with a
|
|
132
|
+
# pre-minted JWT. Used by the E2E test path to verify the wrapper's reactive
|
|
133
|
+
# 401-retry refreshes when the seeded token expires. Production callers omit
|
|
134
|
+
# it; the first authed call mints normally via /oauth/token.
|
|
135
|
+
def self.create_maytes_api_client(endpoint:, client_id:, client_secret:, initial_token: nil)
|
|
136
|
+
provider = OAuthTokenProvider.new(endpoint, client_id, client_secret, initial_token)
|
|
137
|
+
config = ManagedConfiguration.new(provider, endpoint)
|
|
138
|
+
DefaultApi.new(ManagedApiClient.new(config, provider))
|
|
139
|
+
end
|
|
140
|
+
end
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Maytes API
|
|
3
|
+
|
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module MaytesApiClient
|
|
17
|
+
class CancelCheckout409Response < ApiModelBase
|
|
18
|
+
attr_accessor :message
|
|
19
|
+
|
|
20
|
+
attr_accessor :error
|
|
21
|
+
|
|
22
|
+
attr_accessor :code
|
|
23
|
+
|
|
24
|
+
attr_accessor :metadata
|
|
25
|
+
|
|
26
|
+
class EnumAttributeValidator
|
|
27
|
+
attr_reader :datatype
|
|
28
|
+
attr_reader :allowable_values
|
|
29
|
+
|
|
30
|
+
def initialize(datatype, allowable_values)
|
|
31
|
+
@allowable_values = allowable_values.map do |value|
|
|
32
|
+
case datatype.to_s
|
|
33
|
+
when /Integer/i
|
|
34
|
+
value.to_i
|
|
35
|
+
when /Float/i
|
|
36
|
+
value.to_f
|
|
37
|
+
else
|
|
38
|
+
value
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def valid?(value)
|
|
44
|
+
!value || allowable_values.include?(value)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
49
|
+
def self.attribute_map
|
|
50
|
+
{
|
|
51
|
+
:'message' => :'message',
|
|
52
|
+
:'error' => :'error',
|
|
53
|
+
:'code' => :'code',
|
|
54
|
+
:'metadata' => :'metadata'
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns attribute mapping this model knows about
|
|
59
|
+
def self.acceptable_attribute_map
|
|
60
|
+
attribute_map
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns all the JSON keys this model knows about
|
|
64
|
+
def self.acceptable_attributes
|
|
65
|
+
acceptable_attribute_map.values
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Attribute type mapping.
|
|
69
|
+
def self.openapi_types
|
|
70
|
+
{
|
|
71
|
+
:'message' => :'String',
|
|
72
|
+
:'error' => :'String',
|
|
73
|
+
:'code' => :'String',
|
|
74
|
+
:'metadata' => :'Hash<String, Object>'
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# List of attributes with nullable: true
|
|
79
|
+
def self.openapi_nullable
|
|
80
|
+
Set.new([
|
|
81
|
+
])
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# List of class defined in allOf (OpenAPI v3)
|
|
85
|
+
def self.openapi_all_of
|
|
86
|
+
[
|
|
87
|
+
:'ErrorResponseDto'
|
|
88
|
+
]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Initializes the object
|
|
92
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
93
|
+
def initialize(attributes = {})
|
|
94
|
+
if (!attributes.is_a?(Hash))
|
|
95
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MaytesApiClient::CancelCheckout409Response` initialize method"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
99
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
100
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
101
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
102
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MaytesApiClient::CancelCheckout409Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
103
|
+
end
|
|
104
|
+
h[k.to_sym] = v
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if attributes.key?(:'message')
|
|
108
|
+
self.message = attributes[:'message']
|
|
109
|
+
else
|
|
110
|
+
self.message = nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'error')
|
|
114
|
+
self.error = attributes[:'error']
|
|
115
|
+
else
|
|
116
|
+
self.error = nil
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if attributes.key?(:'code')
|
|
120
|
+
self.code = attributes[:'code']
|
|
121
|
+
else
|
|
122
|
+
self.code = nil
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if attributes.key?(:'metadata')
|
|
126
|
+
if (value = attributes[:'metadata']).is_a?(Hash)
|
|
127
|
+
self.metadata = value
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
133
|
+
# @return Array for valid properties with the reasons
|
|
134
|
+
def list_invalid_properties
|
|
135
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
136
|
+
invalid_properties = Array.new
|
|
137
|
+
if @message.nil?
|
|
138
|
+
invalid_properties.push('invalid value for "message", message cannot be nil.')
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
if @error.nil?
|
|
142
|
+
invalid_properties.push('invalid value for "error", error cannot be nil.')
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
if @code.nil?
|
|
146
|
+
invalid_properties.push('invalid value for "code", code cannot be nil.')
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
invalid_properties
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Check to see if the all the properties in the model are valid
|
|
153
|
+
# @return true if the model is valid
|
|
154
|
+
def valid?
|
|
155
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
156
|
+
return false if @message.nil?
|
|
157
|
+
return false if @error.nil?
|
|
158
|
+
return false if @code.nil?
|
|
159
|
+
code_validator = EnumAttributeValidator.new('String', ["session_not_voidable"])
|
|
160
|
+
return false unless code_validator.valid?(@code)
|
|
161
|
+
true
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Custom attribute writer method with validation
|
|
165
|
+
# @param [Object] message Value to be assigned
|
|
166
|
+
def message=(message)
|
|
167
|
+
if message.nil?
|
|
168
|
+
fail ArgumentError, 'message cannot be nil'
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
@message = message
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Custom attribute writer method with validation
|
|
175
|
+
# @param [Object] error Value to be assigned
|
|
176
|
+
def error=(error)
|
|
177
|
+
if error.nil?
|
|
178
|
+
fail ArgumentError, 'error cannot be nil'
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
@error = error
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
185
|
+
# @param [Object] code Object to be assigned
|
|
186
|
+
def code=(code)
|
|
187
|
+
validator = EnumAttributeValidator.new('String', ["session_not_voidable"])
|
|
188
|
+
unless validator.valid?(code)
|
|
189
|
+
fail ArgumentError, "invalid value for \"code\", must be one of #{validator.allowable_values}."
|
|
190
|
+
end
|
|
191
|
+
@code = code
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Checks equality by comparing each attribute.
|
|
195
|
+
# @param [Object] Object to be compared
|
|
196
|
+
def ==(o)
|
|
197
|
+
return true if self.equal?(o)
|
|
198
|
+
self.class == o.class &&
|
|
199
|
+
message == o.message &&
|
|
200
|
+
error == o.error &&
|
|
201
|
+
code == o.code &&
|
|
202
|
+
metadata == o.metadata
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# @see the `==` method
|
|
206
|
+
# @param [Object] Object to be compared
|
|
207
|
+
def eql?(o)
|
|
208
|
+
self == o
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Calculates hash code according to all attributes.
|
|
212
|
+
# @return [Integer] Hash code
|
|
213
|
+
def hash
|
|
214
|
+
[message, error, code, metadata].hash
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Builds the object from hash
|
|
218
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
219
|
+
# @return [Object] Returns the model itself
|
|
220
|
+
def self.build_from_hash(attributes)
|
|
221
|
+
return nil unless attributes.is_a?(Hash)
|
|
222
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
223
|
+
transformed_hash = {}
|
|
224
|
+
openapi_types.each_pair do |key, type|
|
|
225
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
226
|
+
transformed_hash["#{key}"] = nil
|
|
227
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
228
|
+
# check to ensure the input is an array given that the attribute
|
|
229
|
+
# is documented as an array but the input is not
|
|
230
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
231
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
232
|
+
end
|
|
233
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
234
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
new(transformed_hash)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Returns the object in the form of hash
|
|
241
|
+
# @return [Hash] Returns the object in the form of hash
|
|
242
|
+
def to_hash
|
|
243
|
+
hash = {}
|
|
244
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
245
|
+
value = self.send(attr)
|
|
246
|
+
if value.nil?
|
|
247
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
248
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
hash[param] = _to_hash(value)
|
|
252
|
+
end
|
|
253
|
+
hash
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
end
|