tesser-api-sdk 1.0.0
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/LICENSE +28 -0
- data/README.md +148 -0
- data/bin/console +15 -0
- data/lib/tesser_apiv1/api_helper.rb +10 -0
- data/lib/tesser_apiv1/client.rb +118 -0
- data/lib/tesser_apiv1/configuration.rb +182 -0
- data/lib/tesser_apiv1/controllers/accounts_controller.rb +193 -0
- data/lib/tesser_apiv1/controllers/base_controller.rb +60 -0
- data/lib/tesser_apiv1/controllers/counterparties_controller.rb +171 -0
- data/lib/tesser_apiv1/controllers/currencies_controller.rb +39 -0
- data/lib/tesser_apiv1/controllers/experimental_controller.rb +49 -0
- data/lib/tesser_apiv1/controllers/health_controller.rb +24 -0
- data/lib/tesser_apiv1/controllers/networks_controller.rb +39 -0
- data/lib/tesser_apiv1/controllers/payments_controller.rb +202 -0
- data/lib/tesser_apiv1/controllers/tenants_controller.rb +156 -0
- data/lib/tesser_apiv1/controllers/treasury_controller.rb +77 -0
- data/lib/tesser_apiv1/exceptions/api_exception.rb +21 -0
- data/lib/tesser_apiv1/http/auth/o_auth2.rb +53 -0
- data/lib/tesser_apiv1/http/http_call_back.rb +10 -0
- data/lib/tesser_apiv1/http/http_method_enum.rb +10 -0
- data/lib/tesser_apiv1/http/http_request.rb +10 -0
- data/lib/tesser_apiv1/http/http_response.rb +10 -0
- data/lib/tesser_apiv1/http/proxy_settings.rb +22 -0
- data/lib/tesser_apiv1/models/account.rb +230 -0
- data/lib/tesser_apiv1/models/account_list_item.rb +230 -0
- data/lib/tesser_apiv1/models/account_list_response.rb +69 -0
- data/lib/tesser_apiv1/models/account_response.rb +60 -0
- data/lib/tesser_apiv1/models/account_safe.rb +218 -0
- data/lib/tesser_apiv1/models/balance_status1_enum.rb +40 -0
- data/lib/tesser_apiv1/models/balance_status_enum.rb +40 -0
- data/lib/tesser_apiv1/models/base_model.rb +110 -0
- data/lib/tesser_apiv1/models/classification7_enum.rb +36 -0
- data/lib/tesser_apiv1/models/classification_enum.rb +36 -0
- data/lib/tesser_apiv1/models/counterparty.rb +411 -0
- data/lib/tesser_apiv1/models/counterparty_list_response.rb +69 -0
- data/lib/tesser_apiv1/models/counterparty_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_bank_request.rb +122 -0
- data/lib/tesser_apiv1/models/create_bank_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_counterparty_request.rb +350 -0
- data/lib/tesser_apiv1/models/create_counterparty_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_deposit_request.rb +119 -0
- data/lib/tesser_apiv1/models/create_payment_request.rb +168 -0
- data/lib/tesser_apiv1/models/create_tenant_request.rb +183 -0
- data/lib/tesser_apiv1/models/create_tenant_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_wallet_request.rb +112 -0
- data/lib/tesser_apiv1/models/create_wallet_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_withdrawal_request.rb +130 -0
- data/lib/tesser_apiv1/models/currencies_response.rb +69 -0
- data/lib/tesser_apiv1/models/currency.rb +119 -0
- data/lib/tesser_apiv1/models/data.rb +221 -0
- data/lib/tesser_apiv1/models/data6.rb +242 -0
- data/lib/tesser_apiv1/models/data7.rb +419 -0
- data/lib/tesser_apiv1/models/data8.rb +200 -0
- data/lib/tesser_apiv1/models/direction1_enum.rb +40 -0
- data/lib/tesser_apiv1/models/direction_enum.rb +40 -0
- data/lib/tesser_apiv1/models/execute_payment_request_dto.rb +71 -0
- data/lib/tesser_apiv1/models/fee.rb +117 -0
- data/lib/tesser_apiv1/models/fee1.rb +117 -0
- data/lib/tesser_apiv1/models/network.rb +68 -0
- data/lib/tesser_apiv1/models/networks_response.rb +69 -0
- data/lib/tesser_apiv1/models/pagination.rb +104 -0
- data/lib/tesser_apiv1/models/payment.rb +421 -0
- data/lib/tesser_apiv1/models/payment_list_response.rb +79 -0
- data/lib/tesser_apiv1/models/payment_response.rb +60 -0
- data/lib/tesser_apiv1/models/payment_type3_enum.rb +52 -0
- data/lib/tesser_apiv1/models/payment_type_enum.rb +54 -0
- data/lib/tesser_apiv1/models/provider_key1_enum.rb +36 -0
- data/lib/tesser_apiv1/models/provider_key_enum.rb +36 -0
- data/lib/tesser_apiv1/models/response.rb +81 -0
- data/lib/tesser_apiv1/models/review_payment_request.rb +60 -0
- data/lib/tesser_apiv1/models/risk_status_enum.rb +44 -0
- data/lib/tesser_apiv1/models/status1_enum.rb +52 -0
- data/lib/tesser_apiv1/models/status_enum.rb +48 -0
- data/lib/tesser_apiv1/models/step.rb +421 -0
- data/lib/tesser_apiv1/models/step_type_enum.rb +44 -0
- data/lib/tesser_apiv1/models/tenant.rb +275 -0
- data/lib/tesser_apiv1/models/tenant_api_credentials.rb +88 -0
- data/lib/tesser_apiv1/models/tenant_list_response.rb +69 -0
- data/lib/tesser_apiv1/models/tenant_response.rb +60 -0
- data/lib/tesser_apiv1/models/transfer_step.rb +422 -0
- data/lib/tesser_apiv1/models/turnkey_stamp.rb +81 -0
- data/lib/tesser_apiv1/models/type3_enum.rb +40 -0
- data/lib/tesser_apiv1/models/type4_enum.rb +44 -0
- data/lib/tesser_apiv1/models/type_enum.rb +44 -0
- data/lib/tesser_apiv1/models/update_account_request.rb +62 -0
- data/lib/tesser_apiv1/models/update_account_response.rb +60 -0
- data/lib/tesser_apiv1/models/update_counterparty_request.rb +166 -0
- data/lib/tesser_apiv1/models/update_counterparty_response.rb +60 -0
- data/lib/tesser_apiv1/models/update_payment_request.rb +100 -0
- data/lib/tesser_apiv1/models/update_tenant_request.rb +111 -0
- data/lib/tesser_apiv1/models/update_tenant_response.rb +60 -0
- data/lib/tesser_apiv1/utilities/date_time_helper.rb +11 -0
- data/lib/tesser_apiv1/utilities/file_wrapper.rb +28 -0
- data/lib/tesser_apiv1/utilities/union_type_lookup.rb +1234 -0
- data/lib/tesser_apiv1.rb +116 -0
- data/test/controllers/controller_test_base.rb +23 -0
- data/test/controllers/test_health_controller.rb +31 -0
- data/test/controllers/test_tenants_controller.rb +133 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +212 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0bd3e5421a72b28fa7ef686008d89421a650b0dd581eaa0218139074921a6257
|
|
4
|
+
data.tar.gz: 58dc68d4d0a2d9d75378ecacddfa120f5fb1c88df07a2f3934f82421e704cb18
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b28672156d73a447570d848e04b11308f13c1dd55808557e57c399c63bb87e22cec745e5e46421a93b8c2dacbdf335c054fd7dec2e8e6eb9d57d26a3bfa7a0e7
|
|
7
|
+
data.tar.gz: 306173c6f47ad8c2b039edbd4c7036ce801e463752af87084e4b04d9216deb748c0cdf1f1f6b09587d32820144c11d82115af0707bd36eb62034b129d5fa1ca3
|
data/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
License:
|
|
2
|
+
========
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
http://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2014 - 2026 APIMATIC Limited
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
Trade Mark:
|
|
27
|
+
==========
|
|
28
|
+
APIMATIC is a trade mark for APIMATIC Limited
|
data/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
|
|
2
|
+
# Getting Started with Tesser API (v1)
|
|
3
|
+
|
|
4
|
+
## Introduction
|
|
5
|
+
|
|
6
|
+
The Tesser Payments Platform API documentation (v1)
|
|
7
|
+
|
|
8
|
+
## Install the Package
|
|
9
|
+
|
|
10
|
+
Install the gem from the command line:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
gem install tesser-api-sdk -v 1.0.0
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or add the gem to your Gemfile and run `bundle`:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'tesser-api-sdk', '1.0.0'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For additional gem details, see the [RubyGems page for the tesser-api-sdk gem](https://rubygems.org/gems/tesser-api-sdk/versions/1.0.0).
|
|
23
|
+
|
|
24
|
+
## IRB Console Usage
|
|
25
|
+
|
|
26
|
+
You can explore the SDK interactively using IRB in two ways
|
|
27
|
+
|
|
28
|
+
### 1. Use IRB with Installed Gem
|
|
29
|
+
|
|
30
|
+
Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
irb
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Now you can load the SDK in the IRB
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
require 'tesser_apiv1'
|
|
40
|
+
include TesserApiv1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Use IRB within SDK
|
|
44
|
+
|
|
45
|
+
Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
cd path/to/tesser_apiv1
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Now you can start the preconfigured irb console by running the following command
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
ruby bin/console
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**_Note:_** This automatically loads the SDK from lib/
|
|
58
|
+
|
|
59
|
+
## Test the SDK
|
|
60
|
+
|
|
61
|
+
To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
rake
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Initialize the API Client
|
|
68
|
+
|
|
69
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/client.md)
|
|
70
|
+
|
|
71
|
+
The following parameters are configurable for the API Client:
|
|
72
|
+
|
|
73
|
+
| Parameter | Type | Description |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
|
|
76
|
+
| adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
|
|
77
|
+
| timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
|
|
78
|
+
| max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
|
79
|
+
| retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
|
|
80
|
+
| backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
|
|
81
|
+
| retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
|
82
|
+
| retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
|
|
83
|
+
| http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
|
|
84
|
+
| proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
|
|
85
|
+
| bearer_auth_credentials | [`BearerAuthCredentials`](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-bearer-token.md) | The credential object for OAuth 2 Bearer token |
|
|
86
|
+
|
|
87
|
+
The API client can be initialized as follows:
|
|
88
|
+
|
|
89
|
+
### Code-Based Client Initialization
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
require 'tesser_apiv1'
|
|
93
|
+
include TesserApiv1
|
|
94
|
+
|
|
95
|
+
client = Client.new(
|
|
96
|
+
bearer_auth_credentials: BearerAuthCredentials.new(
|
|
97
|
+
access_token: 'AccessToken'
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Environment-Based Client Initialization
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
require 'tesser_apiv1'
|
|
106
|
+
include TesserApiv1
|
|
107
|
+
|
|
108
|
+
# Create client from environment
|
|
109
|
+
client = Client.from_env
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
|
|
113
|
+
|
|
114
|
+
## Authorization
|
|
115
|
+
|
|
116
|
+
This API uses the following authentication schemes.
|
|
117
|
+
|
|
118
|
+
* [`bearer (OAuth 2 Bearer token)`](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-bearer-token.md)
|
|
119
|
+
|
|
120
|
+
## List of APIs
|
|
121
|
+
|
|
122
|
+
* [Payments](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/payments.md)
|
|
123
|
+
* [Health](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/health.md)
|
|
124
|
+
* [Accounts](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/accounts.md)
|
|
125
|
+
* [Currencies](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/currencies.md)
|
|
126
|
+
* [Counterparties](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/counterparties.md)
|
|
127
|
+
* [Tenants](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/tenants.md)
|
|
128
|
+
* [Networks](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/networks.md)
|
|
129
|
+
* [Experimental](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/experimental.md)
|
|
130
|
+
* [Treasury](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/controllers/treasury.md)
|
|
131
|
+
|
|
132
|
+
## SDK Infrastructure
|
|
133
|
+
|
|
134
|
+
### Configuration
|
|
135
|
+
|
|
136
|
+
* [ProxySettings](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
|
|
137
|
+
* [Environment-Based Client Initialization](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
|
|
138
|
+
|
|
139
|
+
### HTTP
|
|
140
|
+
|
|
141
|
+
* [HttpResponse](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/http-response.md)
|
|
142
|
+
* [HttpRequest](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/http-request.md)
|
|
143
|
+
|
|
144
|
+
### Utilities
|
|
145
|
+
|
|
146
|
+
* [ApiHelper](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/api-helper.md)
|
|
147
|
+
* [DateTimeHelper](https://www.github.com/sdks-io/tesser-api-ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
|
|
148
|
+
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Load the lib folder into Ruby's load path
|
|
4
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
|
5
|
+
|
|
6
|
+
# Require the gem
|
|
7
|
+
require 'tesser_apiv1'
|
|
8
|
+
|
|
9
|
+
puts 'TesserApiv1 SDK loaded!'
|
|
10
|
+
puts 'You can now create a client with: client = TesserApiv1::Client.new'
|
|
11
|
+
puts 'Or use from_env: client = TesserApiv1::Client.from_env'
|
|
12
|
+
|
|
13
|
+
# Start an interactive IRB session
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# tesser_apiv1 client class.
|
|
8
|
+
class Client
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
attr_reader :config, :auth_managers
|
|
11
|
+
|
|
12
|
+
def user_agent_detail
|
|
13
|
+
config.user_agent_detail
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Access to payments controller.
|
|
17
|
+
# @return [PaymentsController] Returns the controller instance.
|
|
18
|
+
def payments
|
|
19
|
+
@payments ||= PaymentsController.new @global_configuration
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Access to health controller.
|
|
23
|
+
# @return [HealthController] Returns the controller instance.
|
|
24
|
+
def health
|
|
25
|
+
@health ||= HealthController.new @global_configuration
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Access to accounts controller.
|
|
29
|
+
# @return [AccountsController] Returns the controller instance.
|
|
30
|
+
def accounts
|
|
31
|
+
@accounts ||= AccountsController.new @global_configuration
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Access to currencies controller.
|
|
35
|
+
# @return [CurrenciesController] Returns the controller instance.
|
|
36
|
+
def currencies
|
|
37
|
+
@currencies ||= CurrenciesController.new @global_configuration
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Access to counterparties controller.
|
|
41
|
+
# @return [CounterpartiesController] Returns the controller instance.
|
|
42
|
+
def counterparties
|
|
43
|
+
@counterparties ||= CounterpartiesController.new @global_configuration
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Access to tenants controller.
|
|
47
|
+
# @return [TenantsController] Returns the controller instance.
|
|
48
|
+
def tenants
|
|
49
|
+
@tenants ||= TenantsController.new @global_configuration
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Access to networks controller.
|
|
53
|
+
# @return [NetworksController] Returns the controller instance.
|
|
54
|
+
def networks
|
|
55
|
+
@networks ||= NetworksController.new @global_configuration
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Access to experimental controller.
|
|
59
|
+
# @return [ExperimentalController] Returns the controller instance.
|
|
60
|
+
def experimental
|
|
61
|
+
@experimental ||= ExperimentalController.new @global_configuration
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Access to treasury controller.
|
|
65
|
+
# @return [TreasuryController] Returns the controller instance.
|
|
66
|
+
def treasury
|
|
67
|
+
@treasury ||= TreasuryController.new @global_configuration
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def initialize(
|
|
71
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
|
72
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
73
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
74
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
75
|
+
environment: Environment::PRODUCTION, access_token: nil,
|
|
76
|
+
bearer_auth_credentials: nil, config: nil
|
|
77
|
+
)
|
|
78
|
+
@config = if config.nil?
|
|
79
|
+
Configuration.new(
|
|
80
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
|
81
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
82
|
+
backoff_factor: backoff_factor,
|
|
83
|
+
retry_statuses: retry_statuses,
|
|
84
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
85
|
+
proxy_settings: proxy_settings, environment: environment,
|
|
86
|
+
access_token: access_token,
|
|
87
|
+
bearer_auth_credentials: bearer_auth_credentials
|
|
88
|
+
)
|
|
89
|
+
else
|
|
90
|
+
config
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
|
94
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
|
95
|
+
.global_errors(BaseController::GLOBAL_ERRORS)
|
|
96
|
+
.user_agent(BaseController.user_agent)
|
|
97
|
+
|
|
98
|
+
initialize_auth_managers(@global_configuration)
|
|
99
|
+
@global_configuration = @global_configuration.auth_managers(@auth_managers)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Initializes the auth managers hash used for authenticating API calls.
|
|
103
|
+
# @param [GlobalConfiguration] global_config The global configuration of the SDK)
|
|
104
|
+
def initialize_auth_managers(global_config)
|
|
105
|
+
@auth_managers = {}
|
|
106
|
+
http_client_config = global_config.client_configuration
|
|
107
|
+
%w[bearer].each { |auth| @auth_managers[auth] = nil }
|
|
108
|
+
@auth_managers['bearer'] = OAuth2.new(http_client_config.bearer_auth_credentials)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Creates a client directly from environment variables.
|
|
112
|
+
def self.from_env(**overrides)
|
|
113
|
+
default_config = Configuration.build_default_config_from_env
|
|
114
|
+
new_config = default_config.clone_with(**overrides)
|
|
115
|
+
new(config: new_config)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# An enum for SDK environments.
|
|
8
|
+
class Environment
|
|
9
|
+
# PRODUCTION: Sandbox Environment
|
|
10
|
+
ENVIRONMENT = [
|
|
11
|
+
PRODUCTION = 'production'.freeze
|
|
12
|
+
].freeze
|
|
13
|
+
|
|
14
|
+
# Converts a string or symbol into a valid Environment constant.
|
|
15
|
+
def self.from_value(value, default_value = PRODUCTION)
|
|
16
|
+
return default_value if value.nil?
|
|
17
|
+
|
|
18
|
+
default_value
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# An enum for API servers.
|
|
23
|
+
class Server
|
|
24
|
+
SERVER = [
|
|
25
|
+
DEFAULT = 'default'.freeze
|
|
26
|
+
].freeze
|
|
27
|
+
|
|
28
|
+
# Converts a string or symbol into a valid Server constant.
|
|
29
|
+
def self.from_value(value, default_value = DEFAULT)
|
|
30
|
+
return default_value if value.nil?
|
|
31
|
+
|
|
32
|
+
default_value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# All configuration including auth info and base URI for the API access
|
|
37
|
+
# are configured in this class.
|
|
38
|
+
class Configuration < CoreLibrary::HttpClientConfiguration
|
|
39
|
+
def access_token
|
|
40
|
+
@bearer_auth_credentials.access_token
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# The attribute readers for properties.
|
|
44
|
+
attr_reader :environment, :bearer_auth_credentials
|
|
45
|
+
|
|
46
|
+
class << self
|
|
47
|
+
attr_reader :environments
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def initialize(
|
|
51
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
|
52
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
53
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
54
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
55
|
+
environment: Environment::PRODUCTION, access_token: nil,
|
|
56
|
+
bearer_auth_credentials: nil
|
|
57
|
+
)
|
|
58
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
|
59
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
60
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
|
61
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
62
|
+
proxy_settings: proxy_settings
|
|
63
|
+
|
|
64
|
+
# Current API environment
|
|
65
|
+
@environment = String(environment)
|
|
66
|
+
|
|
67
|
+
# The OAuth 2.0 Access Token to use for API requests.
|
|
68
|
+
@access_token = access_token
|
|
69
|
+
|
|
70
|
+
# Initializing OAuth 2 Bearer token credentials with the provided auth parameters
|
|
71
|
+
@bearer_auth_credentials = create_auth_credentials_object(
|
|
72
|
+
access_token, bearer_auth_credentials
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# The Http Client to use for making requests.
|
|
76
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
|
80
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
|
81
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
|
82
|
+
proxy_settings: nil, environment: nil, access_token: nil,
|
|
83
|
+
bearer_auth_credentials: nil)
|
|
84
|
+
connection ||= self.connection
|
|
85
|
+
adapter ||= self.adapter
|
|
86
|
+
timeout ||= self.timeout
|
|
87
|
+
max_retries ||= self.max_retries
|
|
88
|
+
retry_interval ||= self.retry_interval
|
|
89
|
+
backoff_factor ||= self.backoff_factor
|
|
90
|
+
retry_statuses ||= self.retry_statuses
|
|
91
|
+
retry_methods ||= self.retry_methods
|
|
92
|
+
http_callback ||= self.http_callback
|
|
93
|
+
proxy_settings ||= self.proxy_settings
|
|
94
|
+
environment ||= self.environment
|
|
95
|
+
bearer_auth_credentials = create_auth_credentials_object(
|
|
96
|
+
access_token, bearer_auth_credentials || self.bearer_auth_credentials
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
Configuration.new(connection: connection, adapter: adapter,
|
|
100
|
+
timeout: timeout, max_retries: max_retries,
|
|
101
|
+
retry_interval: retry_interval,
|
|
102
|
+
backoff_factor: backoff_factor,
|
|
103
|
+
retry_statuses: retry_statuses,
|
|
104
|
+
retry_methods: retry_methods,
|
|
105
|
+
http_callback: http_callback,
|
|
106
|
+
proxy_settings: proxy_settings,
|
|
107
|
+
environment: environment,
|
|
108
|
+
bearer_auth_credentials: bearer_auth_credentials)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def create_auth_credentials_object(access_token, bearer_auth_credentials)
|
|
112
|
+
return bearer_auth_credentials if access_token.nil?
|
|
113
|
+
|
|
114
|
+
warn('The \'access_token\' params are deprecated. Use \'bearer_auth_cred'\
|
|
115
|
+
'entials\' param instead.')
|
|
116
|
+
|
|
117
|
+
unless bearer_auth_credentials.nil?
|
|
118
|
+
return bearer_auth_credentials.clone_with(
|
|
119
|
+
access_token: access_token
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
BearerAuthCredentials.new(access_token: access_token)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# All the environments the SDK can run in.
|
|
127
|
+
ENVIRONMENTS = {
|
|
128
|
+
Environment::PRODUCTION => {
|
|
129
|
+
Server::DEFAULT => 'https://tesser-platform-v1-pull-51-me-98e48a7.zuplo.app'
|
|
130
|
+
}
|
|
131
|
+
}.freeze
|
|
132
|
+
|
|
133
|
+
# Generates the appropriate base URI for the environment and the server.
|
|
134
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
|
135
|
+
# required.
|
|
136
|
+
# @return [String] The base URI.
|
|
137
|
+
def get_base_uri(server = Server::DEFAULT)
|
|
138
|
+
ENVIRONMENTS[environment][server].clone
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Builds a Configuration instance using environment variables.
|
|
142
|
+
def self.build_default_config_from_env
|
|
143
|
+
# === Core environment ===
|
|
144
|
+
environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
|
|
145
|
+
timeout = (ENV['TIMEOUT'] || 60).to_f
|
|
146
|
+
max_retries = (ENV['MAX_RETRIES'] || 0).to_i
|
|
147
|
+
retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
|
|
148
|
+
backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
|
|
149
|
+
retry_statuses = ENV.fetch('RETRY_STATUSES',
|
|
150
|
+
'[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
|
|
151
|
+
.split(',')
|
|
152
|
+
.map(&:strip)
|
|
153
|
+
.map do |item|
|
|
154
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
155
|
+
end
|
|
156
|
+
retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
|
|
157
|
+
.split(',')
|
|
158
|
+
.map(&:strip)
|
|
159
|
+
.map do |item|
|
|
160
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# === Authentication credentials ===
|
|
164
|
+
bearer_auth_credentials = BearerAuthCredentials.from_env
|
|
165
|
+
|
|
166
|
+
# === Proxy settings ===
|
|
167
|
+
proxy_settings = ProxySettings.from_env
|
|
168
|
+
|
|
169
|
+
Configuration.new(
|
|
170
|
+
environment: environment,
|
|
171
|
+
timeout: timeout,
|
|
172
|
+
max_retries: max_retries,
|
|
173
|
+
retry_interval: retry_interval,
|
|
174
|
+
backoff_factor: backoff_factor,
|
|
175
|
+
retry_statuses: retry_statuses,
|
|
176
|
+
retry_methods: retry_methods,
|
|
177
|
+
bearer_auth_credentials: bearer_auth_credentials,
|
|
178
|
+
proxy_settings: proxy_settings
|
|
179
|
+
)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|