splitit-apimatic-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.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +154 -0
  4. data/bin/console +15 -0
  5. data/lib/splitit_web_api_v4/api_helper.rb +10 -0
  6. data/lib/splitit_web_api_v4/client.rb +83 -0
  7. data/lib/splitit_web_api_v4/configuration.rb +188 -0
  8. data/lib/splitit_web_api_v4/controllers/base_controller.rb +60 -0
  9. data/lib/splitit_web_api_v4/controllers/installment_plan_controller.rb +242 -0
  10. data/lib/splitit_web_api_v4/controllers/o_auth_authorization_controller.rb +42 -0
  11. data/lib/splitit_web_api_v4/exceptions/api_error_response_exception.rb +51 -0
  12. data/lib/splitit_web_api_v4/exceptions/api_exception.rb +21 -0
  13. data/lib/splitit_web_api_v4/exceptions/o_auth_provider_exception.rb +64 -0
  14. data/lib/splitit_web_api_v4/http/auth/api_key.rb +52 -0
  15. data/lib/splitit_web_api_v4/http/auth/o_auth2.rb +156 -0
  16. data/lib/splitit_web_api_v4/http/http_call_back.rb +10 -0
  17. data/lib/splitit_web_api_v4/http/http_method_enum.rb +10 -0
  18. data/lib/splitit_web_api_v4/http/http_request.rb +10 -0
  19. data/lib/splitit_web_api_v4/http/http_response.rb +10 -0
  20. data/lib/splitit_web_api_v4/http/proxy_settings.rb +22 -0
  21. data/lib/splitit_web_api_v4/models/amount_data.rb +70 -0
  22. data/lib/splitit_web_api_v4/models/api_error_model.rb +93 -0
  23. data/lib/splitit_web_api_v4/models/apr_data.rb +70 -0
  24. data/lib/splitit_web_api_v4/models/authorization_status_enum.rb +40 -0
  25. data/lib/splitit_web_api_v4/models/authorize_authorization_data.rb +154 -0
  26. data/lib/splitit_web_api_v4/models/authorize_request.rb +115 -0
  27. data/lib/splitit_web_api_v4/models/authorize_response.rb +221 -0
  28. data/lib/splitit_web_api_v4/models/base_model.rb +110 -0
  29. data/lib/splitit_web_api_v4/models/billing_address_data.rb +111 -0
  30. data/lib/splitit_web_api_v4/models/card_details.rb +108 -0
  31. data/lib/splitit_web_api_v4/models/card_validity_request.rb +62 -0
  32. data/lib/splitit_web_api_v4/models/card_validity_response.rb +80 -0
  33. data/lib/splitit_web_api_v4/models/checkout_url_data.rb +80 -0
  34. data/lib/splitit_web_api_v4/models/content_segment.rb +90 -0
  35. data/lib/splitit_web_api_v4/models/external_provider_types_enum.rb +48 -0
  36. data/lib/splitit_web_api_v4/models/inline_content.rb +71 -0
  37. data/lib/splitit_web_api_v4/models/installment_item.rb +101 -0
  38. data/lib/splitit_web_api_v4/models/installment_plan_details_response.rb +280 -0
  39. data/lib/splitit_web_api_v4/models/installment_plan_search_details_response.rb +71 -0
  40. data/lib/splitit_web_api_v4/models/installment_plan_search_request.rb +79 -0
  41. data/lib/splitit_web_api_v4/models/installment_plan_status_enum.rb +72 -0
  42. data/lib/splitit_web_api_v4/models/installment_status_enum.rb +60 -0
  43. data/lib/splitit_web_api_v4/models/masked_card_details.rb +82 -0
  44. data/lib/splitit_web_api_v4/models/metadata_item.rb +71 -0
  45. data/lib/splitit_web_api_v4/models/o_auth_provider_error_enum.rb +62 -0
  46. data/lib/splitit_web_api_v4/models/o_auth_scope_o_auth2_enum.rb +26 -0
  47. data/lib/splitit_web_api_v4/models/o_auth_token.rb +96 -0
  48. data/lib/splitit_web_api_v4/models/offer_item.rb +164 -0
  49. data/lib/splitit_web_api_v4/models/offers_billing_address.rb +108 -0
  50. data/lib/splitit_web_api_v4/models/offers_card_details.rb +108 -0
  51. data/lib/splitit_web_api_v4/models/offers_merchant_details.rb +82 -0
  52. data/lib/splitit_web_api_v4/models/offers_payment_method.rb +66 -0
  53. data/lib/splitit_web_api_v4/models/offers_payment_method_response.rb +88 -0
  54. data/lib/splitit_web_api_v4/models/offers_request.rb +145 -0
  55. data/lib/splitit_web_api_v4/models/offers_response.rb +156 -0
  56. data/lib/splitit_web_api_v4/models/offers_shopper_details.rb +112 -0
  57. data/lib/splitit_web_api_v4/models/offers_store_location.rb +108 -0
  58. data/lib/splitit_web_api_v4/models/payment_link_request.rb +195 -0
  59. data/lib/splitit_web_api_v4/models/payment_link_response.rb +107 -0
  60. data/lib/splitit_web_api_v4/models/payment_method.rb +66 -0
  61. data/lib/splitit_web_api_v4/models/payment_method_data.rb +78 -0
  62. data/lib/splitit_web_api_v4/models/payment_method_type_enum.rb +26 -0
  63. data/lib/splitit_web_api_v4/models/pis_error_codes_enum.rb +1021 -0
  64. data/lib/splitit_web_api_v4/models/plan_authorization_data.rb +172 -0
  65. data/lib/splitit_web_api_v4/models/plan_links_data.rb +91 -0
  66. data/lib/splitit_web_api_v4/models/plan_status_enum.rb +48 -0
  67. data/lib/splitit_web_api_v4/models/processing_data.rb +63 -0
  68. data/lib/splitit_web_api_v4/models/purchase_method_enum.rb +52 -0
  69. data/lib/splitit_web_api_v4/models/redirect_urls.rb +81 -0
  70. data/lib/splitit_web_api_v4/models/refund_item.rb +136 -0
  71. data/lib/splitit_web_api_v4/models/refund_request.rb +70 -0
  72. data/lib/splitit_web_api_v4/models/refund_response.rb +105 -0
  73. data/lib/splitit_web_api_v4/models/shipping_status_enum.rb +40 -0
  74. data/lib/splitit_web_api_v4/models/shopper_details_data.rb +113 -0
  75. data/lib/splitit_web_api_v4/models/three_ds_authentication_data.rb +90 -0
  76. data/lib/splitit_web_api_v4/models/three_ds_execute.rb +62 -0
  77. data/lib/splitit_web_api_v4/models/three_ds_redirect_data.rb +93 -0
  78. data/lib/splitit_web_api_v4/models/three_ds_request_data.rb +84 -0
  79. data/lib/splitit_web_api_v4/models/update_offers_payment_method.rb +66 -0
  80. data/lib/splitit_web_api_v4/models/update_offers_request.rb +105 -0
  81. data/lib/splitit_web_api_v4/models/update_order_request.rb +104 -0
  82. data/lib/splitit_web_api_v4/models/update_order_response.rb +126 -0
  83. data/lib/splitit_web_api_v4/models/validation_error.rb +71 -0
  84. data/lib/splitit_web_api_v4/utilities/date_time_helper.rb +11 -0
  85. data/lib/splitit_web_api_v4/utilities/file_wrapper.rb +28 -0
  86. data/lib/splitit_web_api_v4.rb +108 -0
  87. metadata +170 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac04d43312fd0cd38ea01736c8d1b2ebf13a95c07c9f3b95dbc2757a935dfbf5
4
+ data.tar.gz: e75a823afabd968f7c070ac15e9b558084e1a7f3441c2a4537067c299c112144
5
+ SHA512:
6
+ metadata.gz: 2e5fc13544cc8ed97e4a86cd1abfe4c58e1576c136557c912704dd24bfa10093b9e7d0bc3fea7f0694d9b964fb1c013c20f26db50e67bb1e0b1b848e33fe578f
7
+ data.tar.gz: 8e5f15aca554fd628717fe792b7358c4dc39776ce534e59834199f538deb7b4b0b7b9d26fc85b5b257c1707f85e5a720905acab749138131765b22a8dbf8b0b9
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,154 @@
1
+
2
+ # Getting Started with splitit-web-api-v4
3
+
4
+ ## Introduction
5
+
6
+ Splitit Orchestration API for managing installment plans.
7
+
8
+ ## Install the Package
9
+
10
+ Install the gem from the command line:
11
+
12
+ ```bash
13
+ gem install splitit-apimatic-sdk -v 1.0.0
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'splitit-apimatic-sdk', '1.0.0'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the splitit-apimatic-sdk gem](https://rubygems.org/gems/splitit-apimatic-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 'splitit_web_api_v4'
40
+ include SplititWebApiV4
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/splitit_web_api_v4
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
+ ## Initialize the API Client
60
+
61
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/client.md)
62
+
63
+ The following parameters are configurable for the API Client:
64
+
65
+ | Parameter | Type | Description |
66
+ | --- | --- | --- |
67
+ | environment | [`Environment`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/README.md#environments) | The API environment. <br> **Default: `Environment.SANDBOX`** |
68
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
69
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
70
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
71
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
72
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
73
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
74
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
75
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
76
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
77
+ | proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
78
+ | o_auth_2_credentials | [`OAuth2Credentials`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |
79
+ | api_key_credentials | [`ApiKeyCredentials`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/auth/custom-header-signature.md) | The credential object for Custom Header Signature |
80
+
81
+ The API client can be initialized as follows:
82
+
83
+ ### Code-Based Client Initialization
84
+
85
+ ```ruby
86
+ require 'splitit_web_api_v4'
87
+ include SplititWebApiV4
88
+
89
+ client = Client.new(
90
+ o_auth2_credentials: OAuth2Credentials.new(
91
+ o_auth_client_id: 'OAuthClientId',
92
+ o_auth_client_secret: 'OAuthClientSecret',
93
+ o_auth_scopes: [
94
+ OAuthScopeOAuth2Enum::API_V4
95
+ ]
96
+ ),
97
+ api_key_credentials: ApiKeyCredentials.new(
98
+ x_splitit_api_key: 'X-Splitit-Api-Key'
99
+ ),
100
+ environment: Environment::SANDBOX
101
+ )
102
+ ```
103
+
104
+ ### Environment-Based Client Initialization
105
+
106
+ ```ruby
107
+ require 'splitit_web_api_v4'
108
+ include SplititWebApiV4
109
+
110
+ # Create client from environment
111
+ client = Client.from_env
112
+ ```
113
+
114
+ See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
115
+
116
+ ## Environments
117
+
118
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
119
+
120
+ ### Fields
121
+
122
+ | Name | Description |
123
+ | --- | --- |
124
+ | SANDBOX | **Default** Sandbox Environment (Transactional API) |
125
+ | PRODUCTION | Production Environment (Transactional API) |
126
+
127
+ ## Authorization
128
+
129
+ This API uses the following authentication schemes.
130
+
131
+ * [`OAuth2 (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-client-credentials-grant.md)
132
+ * [`ApiKey (Custom Header Signature)`](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/auth/custom-header-signature.md)
133
+
134
+ ## List of APIs
135
+
136
+ * [Installment Plan](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/installment-plan.md)
137
+
138
+ ## SDK Infrastructure
139
+
140
+ ### Configuration
141
+
142
+ * [ProxySettings](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
143
+ * [Environment-Based Client Initialization](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
144
+
145
+ ### HTTP
146
+
147
+ * [HttpResponse](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/http-response.md)
148
+ * [HttpRequest](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/http-request.md)
149
+
150
+ ### Utilities
151
+
152
+ * [ApiHelper](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/api-helper.md)
153
+ * [DateTimeHelper](https://www.github.com/sdks-io/splitit-apimatic-ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
154
+
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 'splitit_web_api_v4'
8
+
9
+ puts 'SplititWebApiV4 SDK loaded!'
10
+ puts 'You can now create a client with: client = SplititWebApiV4::Client.new'
11
+ puts 'Or use from_env: client = SplititWebApiV4::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,10 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,83 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # splitit_web_api_v4 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
+ # Returns the configured authentication OAuth2 instance.
17
+ def o_auth2
18
+ @auth_managers['OAuth2']
19
+ end
20
+
21
+ # Access to installment_plan controller.
22
+ # @return [InstallmentPlanController] Returns the controller instance.
23
+ def installment_plan
24
+ @installment_plan ||= InstallmentPlanController.new @global_configuration
25
+ end
26
+
27
+ # Access to o_auth_authorization controller.
28
+ # @return [OAuthAuthorizationController] Returns the controller instance.
29
+ def o_auth_authorization
30
+ @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration
31
+ end
32
+
33
+ def initialize(
34
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
35
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
36
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
37
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
38
+ environment: Environment::SANDBOX, o_auth2_credentials: nil,
39
+ api_key_credentials: nil, config: nil
40
+ )
41
+ @config = if config.nil?
42
+ Configuration.new(connection: connection, adapter: adapter,
43
+ timeout: timeout, max_retries: max_retries,
44
+ retry_interval: retry_interval,
45
+ backoff_factor: backoff_factor,
46
+ retry_statuses: retry_statuses,
47
+ retry_methods: retry_methods,
48
+ http_callback: http_callback,
49
+ proxy_settings: proxy_settings,
50
+ environment: environment,
51
+ o_auth2_credentials: o_auth2_credentials,
52
+ api_key_credentials: api_key_credentials)
53
+ else
54
+ config
55
+ end
56
+
57
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
58
+ .base_uri_executor(@config.method(:get_base_uri))
59
+ .global_errors(BaseController::GLOBAL_ERRORS)
60
+ .user_agent(BaseController.user_agent)
61
+
62
+ initialize_auth_managers(@global_configuration)
63
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
64
+ end
65
+
66
+ # Initializes the auth managers hash used for authenticating API calls.
67
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
68
+ def initialize_auth_managers(global_config)
69
+ @auth_managers = {}
70
+ http_client_config = global_config.client_configuration
71
+ %w[OAuth2 ApiKey].each { |auth| @auth_managers[auth] = nil }
72
+ @auth_managers['OAuth2'] = OAuth2.new(http_client_config.o_auth2_credentials, global_config)
73
+ @auth_managers['ApiKey'] = ApiKey.new(http_client_config.api_key_credentials)
74
+ end
75
+
76
+ # Creates a client directly from environment variables.
77
+ def self.from_env(**overrides)
78
+ default_config = Configuration.build_default_config_from_env
79
+ new_config = default_config.clone_with(**overrides)
80
+ new(config: new_config)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,188 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ # SANDBOX: Sandbox Environment (Transactional API)
10
+ # PRODUCTION: Production Environment (Transactional API)
11
+ ENVIRONMENT = [
12
+ SANDBOX = 'Sandbox'.freeze,
13
+ PRODUCTION = 'Production'.freeze
14
+ ].freeze
15
+
16
+ # Converts a string or symbol into a valid Environment constant.
17
+ def self.from_value(value, default_value = SANDBOX)
18
+ return default_value if value.nil?
19
+
20
+ str = value.to_s.strip.downcase
21
+ case str
22
+ when 'sandbox' then SANDBOX
23
+ when 'production' then PRODUCTION
24
+
25
+ else
26
+ warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} "
27
+ default_value
28
+ end
29
+ end
30
+ end
31
+
32
+ # An enum for API servers.
33
+ class Server
34
+ SERVER = [
35
+ DEFAULT = 'default'.freeze,
36
+ ACCESS_TOKEN_SERVER = 'access token server'.freeze
37
+ ].freeze
38
+
39
+ # Converts a string or symbol into a valid Server constant.
40
+ def self.from_value(value, default_value = DEFAULT)
41
+ return default_value if value.nil?
42
+
43
+ str = value.to_s.strip.downcase
44
+ case str
45
+ when 'default' then DEFAULT
46
+ when 'access_token_server' then ACCESS_TOKEN_SERVER
47
+
48
+ else
49
+ warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
50
+ default_value
51
+ end
52
+ end
53
+ end
54
+
55
+ # All configuration including auth info and base URI for the API access
56
+ # are configured in this class.
57
+ class Configuration < CoreLibrary::HttpClientConfiguration
58
+ # The attribute readers for properties.
59
+ attr_reader :environment, :o_auth2_credentials, :api_key_credentials
60
+
61
+ class << self
62
+ attr_reader :environments
63
+ end
64
+
65
+ def initialize(
66
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
67
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
68
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
69
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
70
+ environment: Environment::SANDBOX, o_auth2_credentials: nil,
71
+ api_key_credentials: nil
72
+ )
73
+ super connection: connection, adapter: adapter, timeout: timeout,
74
+ max_retries: max_retries, retry_interval: retry_interval,
75
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
76
+ retry_methods: retry_methods, http_callback: http_callback,
77
+ proxy_settings: proxy_settings
78
+
79
+ # Current API environment
80
+ @environment = String(environment)
81
+
82
+ # The object holding OAuth 2 Client Credentials Grant credentials
83
+ @o_auth2_credentials = o_auth2_credentials
84
+
85
+ # The object holding Custom Header Signature credentials
86
+ @api_key_credentials = api_key_credentials
87
+
88
+ # The Http Client to use for making requests.
89
+ set_http_client CoreLibrary::FaradayClient.new(self)
90
+ end
91
+
92
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
93
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
94
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
95
+ proxy_settings: nil, environment: nil,
96
+ o_auth2_credentials: nil, api_key_credentials: nil)
97
+ connection ||= self.connection
98
+ adapter ||= self.adapter
99
+ timeout ||= self.timeout
100
+ max_retries ||= self.max_retries
101
+ retry_interval ||= self.retry_interval
102
+ backoff_factor ||= self.backoff_factor
103
+ retry_statuses ||= self.retry_statuses
104
+ retry_methods ||= self.retry_methods
105
+ http_callback ||= self.http_callback
106
+ proxy_settings ||= self.proxy_settings
107
+ environment ||= self.environment
108
+ o_auth2_credentials ||= self.o_auth2_credentials
109
+ api_key_credentials ||= self.api_key_credentials
110
+
111
+ Configuration.new(connection: connection, adapter: adapter,
112
+ timeout: timeout, max_retries: max_retries,
113
+ retry_interval: retry_interval,
114
+ backoff_factor: backoff_factor,
115
+ retry_statuses: retry_statuses,
116
+ retry_methods: retry_methods,
117
+ http_callback: http_callback,
118
+ proxy_settings: proxy_settings,
119
+ environment: environment,
120
+ o_auth2_credentials: o_auth2_credentials,
121
+ api_key_credentials: api_key_credentials)
122
+ end
123
+
124
+
125
+ # All the environments the SDK can run in.
126
+ ENVIRONMENTS = {
127
+ Environment::SANDBOX => {
128
+ Server::DEFAULT => 'https://orch-api.sandbox.splitit.com',
129
+ Server::ACCESS_TOKEN_SERVER => 'https://id.sandbox.splitit.com/connect'
130
+ },
131
+ Environment::PRODUCTION => {
132
+ Server::DEFAULT => 'https://orch-api.splitit.com',
133
+ Server::ACCESS_TOKEN_SERVER => 'https://id.sandbox.splitit.com/connect'
134
+ }
135
+ }.freeze
136
+
137
+ # Generates the appropriate base URI for the environment and the server.
138
+ # @param [Configuration::Server] server The server enum for which the base URI is
139
+ # required.
140
+ # @return [String] The base URI.
141
+ def get_base_uri(server = Server::DEFAULT)
142
+ ENVIRONMENTS[environment][server].clone
143
+ end
144
+
145
+ # Builds a Configuration instance using environment variables.
146
+ def self.build_default_config_from_env
147
+ # === Core environment ===
148
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'sandbox'))
149
+ timeout = (ENV['TIMEOUT'] || 60).to_f
150
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
151
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
152
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
153
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
154
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
155
+ .split(',')
156
+ .map(&:strip)
157
+ .map do |item|
158
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
159
+ end
160
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
161
+ .split(',')
162
+ .map(&:strip)
163
+ .map do |item|
164
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
165
+ end
166
+
167
+ # === Authentication credentials ===
168
+ o_auth2_credentials = OAuth2Credentials.from_env
169
+ api_key_credentials = ApiKeyCredentials.from_env
170
+
171
+ # === Proxy settings ===
172
+ proxy_settings = ProxySettings.from_env
173
+
174
+ Configuration.new(
175
+ environment: environment,
176
+ timeout: timeout,
177
+ max_retries: max_retries,
178
+ retry_interval: retry_interval,
179
+ backoff_factor: backoff_factor,
180
+ retry_statuses: retry_statuses,
181
+ retry_methods: retry_methods,
182
+ o_auth2_credentials: o_auth2_credentials,
183
+ api_key_credentials: api_key_credentials,
184
+ proxy_settings: proxy_settings
185
+ )
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,60 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # BaseController.
8
+ class BaseController
9
+ include CoreLibrary
10
+ attr_accessor :config, :http_call_back
11
+
12
+ def self.user_agent
13
+ 'APIMATIC 3.0'
14
+ end
15
+
16
+
17
+ GLOBAL_ERRORS = {
18
+ 'default' => ErrorCase.new
19
+ .error_message('HTTP response not OK.')
20
+ .exception_type(APIException)
21
+ }.freeze
22
+
23
+ # Initialization constructor.
24
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
25
+ def initialize(global_configuration)
26
+ @global_configuration = global_configuration
27
+ @config = @global_configuration.client_configuration
28
+ @http_call_back = @config.http_callback
29
+ @api_call = ApiCall.new(@global_configuration)
30
+ end
31
+
32
+ # Creates a new instance of the request builder.
33
+ # @param [String] http_method The HTTP method to use in the request.
34
+ # @param [String] path The endpoint path to use in the request.
35
+ # @param [String] server The server to extract the base uri for the request.
36
+ # @return [RequestBuilder] The instance of RequestBuilder.
37
+ def new_request_builder(http_method, path, server)
38
+ RequestBuilder.new
39
+ .http_method(http_method)
40
+ .path(path)
41
+ .server(server)
42
+ end
43
+
44
+ # Creates a new instance of the response handler.
45
+ # @return [ResponseHandler] The instance of ResponseHandler.
46
+ def new_response_handler
47
+ ResponseHandler.new
48
+ end
49
+
50
+ # Creates a new instance of the parameter.
51
+ # @param [String|optional] key The key of the parameter.
52
+ # @param [Object] value The value of the parameter.
53
+ # @return [Parameter] The instance of Parameter.
54
+ def new_parameter(value, key: nil)
55
+ Parameter.new
56
+ .key(key)
57
+ .value(value)
58
+ end
59
+ end
60
+ end