paze-apimatic-sdk-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 (74) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +147 -0
  4. data/bin/console +15 -0
  5. data/lib/paze_checkout_api/api_helper.rb +10 -0
  6. data/lib/paze_checkout_api/client.rb +97 -0
  7. data/lib/paze_checkout_api/configuration.rb +221 -0
  8. data/lib/paze_checkout_api/controllers/base_controller.rb +60 -0
  9. data/lib/paze_checkout_api/controllers/checkout_session_controller.rb +108 -0
  10. data/lib/paze_checkout_api/controllers/identity_controller.rb +43 -0
  11. data/lib/paze_checkout_api/controllers/merchant_onboarding_controller.rb +39 -0
  12. data/lib/paze_checkout_api/controllers/o_auth_authorization_controller.rb +42 -0
  13. data/lib/paze_checkout_api/exceptions/api_error_response_exception.rb +67 -0
  14. data/lib/paze_checkout_api/exceptions/api_exception.rb +21 -0
  15. data/lib/paze_checkout_api/exceptions/base_response_exception.rb +75 -0
  16. data/lib/paze_checkout_api/exceptions/o_auth_provider_exception.rb +64 -0
  17. data/lib/paze_checkout_api/exceptions/simple_error_exception.rb +46 -0
  18. data/lib/paze_checkout_api/http/auth/o_auth2.rb +149 -0
  19. data/lib/paze_checkout_api/http/http_call_back.rb +10 -0
  20. data/lib/paze_checkout_api/http/http_method_enum.rb +10 -0
  21. data/lib/paze_checkout_api/http/http_request.rb +10 -0
  22. data/lib/paze_checkout_api/http/http_response.rb +10 -0
  23. data/lib/paze_checkout_api/http/proxy_settings.rb +22 -0
  24. data/lib/paze_checkout_api/models/api_response_metadata.rb +87 -0
  25. data/lib/paze_checkout_api/models/base_model.rb +110 -0
  26. data/lib/paze_checkout_api/models/billing_preference_enum.rb +36 -0
  27. data/lib/paze_checkout_api/models/checkout_session_complete_request.rb +70 -0
  28. data/lib/paze_checkout_api/models/checkout_session_complete_response.rb +97 -0
  29. data/lib/paze_checkout_api/models/checkout_session_create_request.rb +70 -0
  30. data/lib/paze_checkout_api/models/checkout_session_create_response.rb +97 -0
  31. data/lib/paze_checkout_api/models/checkout_session_review_request.rb +70 -0
  32. data/lib/paze_checkout_api/models/checkout_session_review_response.rb +97 -0
  33. data/lib/paze_checkout_api/models/client.rb +80 -0
  34. data/lib/paze_checkout_api/models/client_assertion_type_enum.rb +27 -0
  35. data/lib/paze_checkout_api/models/complete_session_data.rb +131 -0
  36. data/lib/paze_checkout_api/models/complete_session_response_data.rb +71 -0
  37. data/lib/paze_checkout_api/models/consumer.rb +100 -0
  38. data/lib/paze_checkout_api/models/create_session_data.rb +134 -0
  39. data/lib/paze_checkout_api/models/create_session_response_data.rb +71 -0
  40. data/lib/paze_checkout_api/models/data.rb +62 -0
  41. data/lib/paze_checkout_api/models/ecommerce_data.rb +109 -0
  42. data/lib/paze_checkout_api/models/enhanced_transaction_data.rb +71 -0
  43. data/lib/paze_checkout_api/models/error_detail.rb +81 -0
  44. data/lib/paze_checkout_api/models/error_message.rb +88 -0
  45. data/lib/paze_checkout_api/models/grant_type_enum.rb +26 -0
  46. data/lib/paze_checkout_api/models/intent_enum.rb +40 -0
  47. data/lib/paze_checkout_api/models/links.rb +74 -0
  48. data/lib/paze_checkout_api/models/masked_card.rb +107 -0
  49. data/lib/paze_checkout_api/models/merchant_address.rb +97 -0
  50. data/lib/paze_checkout_api/models/merchant_onboard_data.rb +115 -0
  51. data/lib/paze_checkout_api/models/merchant_onboard_request.rb +70 -0
  52. data/lib/paze_checkout_api/models/merchant_profile.rb +83 -0
  53. data/lib/paze_checkout_api/models/merchant_response.rb +122 -0
  54. data/lib/paze_checkout_api/models/o_auth_provider_error_enum.rb +62 -0
  55. data/lib/paze_checkout_api/models/o_auth_token.rb +96 -0
  56. data/lib/paze_checkout_api/models/o_auth_token_request.rb +75 -0
  57. data/lib/paze_checkout_api/models/o_auth_token_response.rb +78 -0
  58. data/lib/paze_checkout_api/models/onboard_merchant_key.rb +112 -0
  59. data/lib/paze_checkout_api/models/payload_type_indicator_enum.rb +36 -0
  60. data/lib/paze_checkout_api/models/payment_card_brand_enum.rb +40 -0
  61. data/lib/paze_checkout_api/models/payment_card_type_enum.rb +36 -0
  62. data/lib/paze_checkout_api/models/phone.rb +72 -0
  63. data/lib/paze_checkout_api/models/processing_network_enum.rb +40 -0
  64. data/lib/paze_checkout_api/models/review_session_data.rb +68 -0
  65. data/lib/paze_checkout_api/models/review_session_response_data.rb +100 -0
  66. data/lib/paze_checkout_api/models/shipping_address.rb +101 -0
  67. data/lib/paze_checkout_api/models/transaction_options.rb +87 -0
  68. data/lib/paze_checkout_api/models/transaction_type_enum.rb +36 -0
  69. data/lib/paze_checkout_api/models/transaction_value.rb +72 -0
  70. data/lib/paze_checkout_api/models/travel_data.rb +110 -0
  71. data/lib/paze_checkout_api/utilities/date_time_helper.rb +11 -0
  72. data/lib/paze_checkout_api/utilities/file_wrapper.rb +28 -0
  73. data/lib/paze_checkout_api.rb +93 -0
  74. metadata +157 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 796edf0185cc045d6ae0f42ba7d8455bcf655f17203c6c6969f32f44a6176c58
4
+ data.tar.gz: 26050411ba4ffb8a5fecce035d76e97ace6ca6f9b2df429997656d9dc246610d
5
+ SHA512:
6
+ metadata.gz: 7ad484e3ac1398e5a46fba99795f97d7cac8f37d908f1e65da45c4fb255574b75cd40547beddf8715515250f191549a602cc06e5bd35afd6ff5a6ec938a5d71b
7
+ data.tar.gz: 986644931533be0d5f28adf64c7ceaf28f3b013b664557c1341c4ea7e08e8dd8c38c3a3edf6973d10e638181171378908b17eafa2697a8db8a192c14d14989af
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,147 @@
1
+
2
+ # Getting Started with Paze Checkout API
3
+
4
+ ## Introduction
5
+
6
+ Paze Checkout API for Merchants
7
+
8
+ ## Install the Package
9
+
10
+ Install the gem from the command line:
11
+
12
+ ```bash
13
+ gem install paze-apimatic-sdk-sdk -v 1.0.0
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'paze-apimatic-sdk-sdk', '1.0.0'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the paze-apimatic-sdk-sdk gem](https://rubygems.org/gems/paze-apimatic-sdk-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 'paze_checkout_api'
40
+ include PazeCheckoutApi
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/paze_checkout_api
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/paze-apimatic-sdk-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/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/README.md#environments) | The API environment. <br> **Default: `Environment.PRODUCTION`** |
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/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
78
+ | client_credentials_auth_credentials | [`ClientCredentialsAuthCredentials`](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |
79
+
80
+ The API client can be initialized as follows:
81
+
82
+ ### Code-Based Client Initialization
83
+
84
+ ```ruby
85
+ require 'paze_checkout_api'
86
+ include PazeCheckoutApi
87
+
88
+ client = Client.new(
89
+ client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
90
+ o_auth_client_id: 'OAuthClientId',
91
+ o_auth_client_secret: 'OAuthClientSecret'
92
+ ),
93
+ environment: Environment::PRODUCTION
94
+ )
95
+ ```
96
+
97
+ ### Environment-Based Client Initialization
98
+
99
+ ```ruby
100
+ require 'paze_checkout_api'
101
+ include PazeCheckoutApi
102
+
103
+ # Create client from environment
104
+ client = Client.from_env
105
+ ```
106
+
107
+ See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
108
+
109
+ ## Environments
110
+
111
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
112
+
113
+ ### Fields
114
+
115
+ | Name | Description |
116
+ | --- | --- |
117
+ | PRODUCTION | **Default** |
118
+
119
+ ## Authorization
120
+
121
+ This API uses the following authentication schemes.
122
+
123
+ * [`OAuth2 (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-client-credentials-grant.md)
124
+
125
+ ## List of APIs
126
+
127
+ * [Checkout Session](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/controllers/checkout-session.md)
128
+ * [Merchant Onboarding](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/controllers/merchant-onboarding.md)
129
+ * [Identity](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/controllers/identity.md)
130
+
131
+ ## SDK Infrastructure
132
+
133
+ ### Configuration
134
+
135
+ * [ProxySettings](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
136
+ * [Environment-Based Client Initialization](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
137
+
138
+ ### HTTP
139
+
140
+ * [HttpResponse](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/http-response.md)
141
+ * [HttpRequest](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/http-request.md)
142
+
143
+ ### Utilities
144
+
145
+ * [ApiHelper](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/api-helper.md)
146
+ * [DateTimeHelper](https://www.github.com/sdks-io/paze-apimatic-sdk-ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
147
+
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 'paze_checkout_api'
8
+
9
+ puts 'PazeCheckoutApi SDK loaded!'
10
+ puts 'You can now create a client with: client = PazeCheckoutApi::Client.new'
11
+ puts 'Or use from_env: client = PazeCheckoutApi::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,10 @@
1
+ # paze_checkout_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module PazeCheckoutApi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,97 @@
1
+ # paze_checkout_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module PazeCheckoutApi
7
+ # paze_checkout_api 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 identity controller.
22
+ # @return [IdentityController] Returns the controller instance.
23
+ def identity
24
+ @identity ||= IdentityController.new @global_configuration
25
+ end
26
+
27
+ # Access to checkout_session controller.
28
+ # @return [CheckoutSessionController] Returns the controller instance.
29
+ def checkout_session
30
+ @checkout_session ||= CheckoutSessionController.new @global_configuration
31
+ end
32
+
33
+ # Access to merchant_onboarding controller.
34
+ # @return [MerchantOnboardingController] Returns the controller instance.
35
+ def merchant_onboarding
36
+ @merchant_onboarding ||= MerchantOnboardingController.new @global_configuration
37
+ end
38
+
39
+ # Access to o_auth_authorization controller.
40
+ # @return [OAuthAuthorizationController] Returns the controller instance.
41
+ def o_auth_authorization
42
+ @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration
43
+ end
44
+
45
+ def initialize(
46
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
47
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
48
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
49
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
50
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
51
+ o_auth_client_secret: nil, o_auth_token: nil,
52
+ client_credentials_auth_credentials: nil, config: nil
53
+ )
54
+ @config = if config.nil?
55
+ Configuration.new(
56
+ connection: connection, adapter: adapter, timeout: timeout,
57
+ max_retries: max_retries, retry_interval: retry_interval,
58
+ backoff_factor: backoff_factor,
59
+ retry_statuses: retry_statuses,
60
+ retry_methods: retry_methods, http_callback: http_callback,
61
+ proxy_settings: proxy_settings, environment: environment,
62
+ o_auth_client_id: o_auth_client_id,
63
+ o_auth_client_secret: o_auth_client_secret,
64
+ o_auth_token: o_auth_token,
65
+ client_credentials_auth_credentials: client_credentials_auth_credentials
66
+ )
67
+ else
68
+ config
69
+ end
70
+
71
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
72
+ .base_uri_executor(@config.method(:get_base_uri))
73
+ .global_errors(BaseController::GLOBAL_ERRORS)
74
+ .user_agent(BaseController.user_agent)
75
+
76
+ initialize_auth_managers(@global_configuration)
77
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
78
+ end
79
+
80
+ # Initializes the auth managers hash used for authenticating API calls.
81
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
82
+ def initialize_auth_managers(global_config)
83
+ @auth_managers = {}
84
+ http_client_config = global_config.client_configuration
85
+ %w[OAuth2].each { |auth| @auth_managers[auth] = nil }
86
+ @auth_managers['OAuth2'] = OAuth2.new(http_client_config.client_credentials_auth_credentials,
87
+ global_config)
88
+ end
89
+
90
+ # Creates a client directly from environment variables.
91
+ def self.from_env(**overrides)
92
+ default_config = Configuration.build_default_config_from_env
93
+ new_config = default_config.clone_with(**overrides)
94
+ new(config: new_config)
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,221 @@
1
+ # paze_checkout_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module PazeCheckoutApi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+
13
+ # Converts a string or symbol into a valid Environment constant.
14
+ def self.from_value(value, default_value = PRODUCTION)
15
+ return default_value if value.nil?
16
+
17
+ default_value
18
+ end
19
+ end
20
+
21
+ # An enum for API servers.
22
+ class Server
23
+ SERVER = [
24
+ DEFAULT = 'default'.freeze,
25
+ ACCESS_TOKEN_SERVER = 'access token server'.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
+ str = value.to_s.strip.downcase
33
+ case str
34
+ when 'default' then DEFAULT
35
+ when 'access_token_server' then ACCESS_TOKEN_SERVER
36
+
37
+ else
38
+ warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
39
+ default_value
40
+ end
41
+ end
42
+ end
43
+
44
+ # All configuration including auth info and base URI for the API access
45
+ # are configured in this class.
46
+ class Configuration < CoreLibrary::HttpClientConfiguration
47
+ def o_auth_client_id
48
+ @client_credentials_auth_credentials.o_auth_client_id
49
+ end
50
+
51
+ def o_auth_client_secret
52
+ @client_credentials_auth_credentials.o_auth_client_secret
53
+ end
54
+
55
+ def o_auth_token
56
+ @client_credentials_auth_credentials.o_auth_token
57
+ end
58
+
59
+ # The attribute readers for properties.
60
+ attr_reader :environment, :client_credentials_auth_credentials
61
+
62
+ class << self
63
+ attr_reader :environments
64
+ end
65
+
66
+ def initialize(
67
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
68
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
69
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
70
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
71
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
72
+ o_auth_client_secret: nil, o_auth_token: nil,
73
+ client_credentials_auth_credentials: nil
74
+ )
75
+ super connection: connection, adapter: adapter, timeout: timeout,
76
+ max_retries: max_retries, retry_interval: retry_interval,
77
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
78
+ retry_methods: retry_methods, http_callback: http_callback,
79
+ proxy_settings: proxy_settings
80
+
81
+ # Current API environment
82
+ @environment = String(environment)
83
+
84
+ # OAuth 2 Client ID
85
+ @o_auth_client_id = o_auth_client_id
86
+
87
+ # OAuth 2 Client Secret
88
+ @o_auth_client_secret = o_auth_client_secret
89
+
90
+ # Object for storing information about the OAuth token
91
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
92
+ OAuthToken.from_hash o_auth_token.to_hash
93
+ else
94
+ o_auth_token
95
+ end
96
+
97
+ # Initializing OAuth 2 Client Credentials Grant credentials with the provided auth parameters
98
+ @client_credentials_auth_credentials = create_auth_credentials_object(
99
+ o_auth_client_id, o_auth_client_secret, o_auth_token,
100
+ client_credentials_auth_credentials
101
+ )
102
+
103
+ # The Http Client to use for making requests.
104
+ set_http_client CoreLibrary::FaradayClient.new(self)
105
+ end
106
+
107
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
108
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
109
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
110
+ proxy_settings: nil, environment: nil, o_auth_client_id: nil,
111
+ o_auth_client_secret: nil, o_auth_token: nil,
112
+ client_credentials_auth_credentials: nil)
113
+ connection ||= self.connection
114
+ adapter ||= self.adapter
115
+ timeout ||= self.timeout
116
+ max_retries ||= self.max_retries
117
+ retry_interval ||= self.retry_interval
118
+ backoff_factor ||= self.backoff_factor
119
+ retry_statuses ||= self.retry_statuses
120
+ retry_methods ||= self.retry_methods
121
+ http_callback ||= self.http_callback
122
+ proxy_settings ||= self.proxy_settings
123
+ environment ||= self.environment
124
+ client_credentials_auth_credentials = create_auth_credentials_object(
125
+ o_auth_client_id, o_auth_client_secret, o_auth_token,
126
+ client_credentials_auth_credentials || self.client_credentials_auth_credentials
127
+ )
128
+
129
+ Configuration.new(
130
+ connection: connection, adapter: adapter, timeout: timeout,
131
+ max_retries: max_retries, retry_interval: retry_interval,
132
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
133
+ retry_methods: retry_methods, http_callback: http_callback,
134
+ proxy_settings: proxy_settings, environment: environment,
135
+ client_credentials_auth_credentials: client_credentials_auth_credentials
136
+ )
137
+ end
138
+
139
+ def create_auth_credentials_object(o_auth_client_id, o_auth_client_secret,
140
+ o_auth_token,
141
+ client_credentials_auth_credentials)
142
+ return client_credentials_auth_credentials if o_auth_client_id.nil? &&
143
+ o_auth_client_secret.nil? &&
144
+ o_auth_token.nil?
145
+
146
+ warn('The \'o_auth_client_id\', \'o_auth_client_secret\', \'o_auth_token'\
147
+ '\' params are deprecated. Use \'client_credentials_auth_credential'\
148
+ 's\' param instead.')
149
+
150
+ unless client_credentials_auth_credentials.nil?
151
+ return client_credentials_auth_credentials.clone_with(
152
+ o_auth_client_id: o_auth_client_id,
153
+ o_auth_client_secret: o_auth_client_secret,
154
+ o_auth_token: o_auth_token
155
+ )
156
+ end
157
+
158
+ ClientCredentialsAuthCredentials.new(
159
+ o_auth_client_id: o_auth_client_id,
160
+ o_auth_client_secret: o_auth_client_secret, o_auth_token: o_auth_token
161
+ )
162
+ end
163
+
164
+ # All the environments the SDK can run in.
165
+ ENVIRONMENTS = {
166
+ Environment::PRODUCTION => {
167
+ Server::DEFAULT => 'https://api.paze.com',
168
+ Server::ACCESS_TOKEN_SERVER => 'https://auth.paze.com'
169
+ }
170
+ }.freeze
171
+
172
+ # Generates the appropriate base URI for the environment and the server.
173
+ # @param [Configuration::Server] server The server enum for which the base URI is
174
+ # required.
175
+ # @return [String] The base URI.
176
+ def get_base_uri(server = Server::DEFAULT)
177
+ ENVIRONMENTS[environment][server].clone
178
+ end
179
+
180
+ # Builds a Configuration instance using environment variables.
181
+ def self.build_default_config_from_env
182
+ # === Core environment ===
183
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
184
+ timeout = (ENV['TIMEOUT'] || 60).to_f
185
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
186
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
187
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
188
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
189
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
190
+ .split(',')
191
+ .map(&:strip)
192
+ .map do |item|
193
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
194
+ end
195
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
196
+ .split(',')
197
+ .map(&:strip)
198
+ .map do |item|
199
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
200
+ end
201
+
202
+ # === Authentication credentials ===
203
+ client_credentials_auth_credentials = ClientCredentialsAuthCredentials.from_env
204
+
205
+ # === Proxy settings ===
206
+ proxy_settings = ProxySettings.from_env
207
+
208
+ Configuration.new(
209
+ environment: environment,
210
+ timeout: timeout,
211
+ max_retries: max_retries,
212
+ retry_interval: retry_interval,
213
+ backoff_factor: backoff_factor,
214
+ retry_statuses: retry_statuses,
215
+ retry_methods: retry_methods,
216
+ client_credentials_auth_credentials: client_credentials_auth_credentials,
217
+ proxy_settings: proxy_settings
218
+ )
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,60 @@
1
+ # paze_checkout_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module PazeCheckoutApi
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