bk-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 (140) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +203 -0
  4. data/bin/console +15 -0
  5. data/lib/boku_direct_payments_api/api_helper.rb +10 -0
  6. data/lib/boku_direct_payments_api/client.rb +99 -0
  7. data/lib/boku_direct_payments_api/configuration.rb +168 -0
  8. data/lib/boku_direct_payments_api/controllers/account_resources_controller.rb +45 -0
  9. data/lib/boku_direct_payments_api/controllers/base_controller.rb +60 -0
  10. data/lib/boku_direct_payments_api/controllers/charge_controller.rb +247 -0
  11. data/lib/boku_direct_payments_api/controllers/config_resources_controller.rb +50 -0
  12. data/lib/boku_direct_payments_api/controllers/consumer_registration_controller.rb +428 -0
  13. data/lib/boku_direct_payments_api/controllers/forex_controller.rb +38 -0
  14. data/lib/boku_direct_payments_api/controllers/fund_check_controller.rb +39 -0
  15. data/lib/boku_direct_payments_api/controllers/refund_controller.rb +80 -0
  16. data/lib/boku_direct_payments_api/controllers/seller_of_record_controller.rb +69 -0
  17. data/lib/boku_direct_payments_api/exceptions/api_exception.rb +21 -0
  18. data/lib/boku_direct_payments_api/http/http_call_back.rb +10 -0
  19. data/lib/boku_direct_payments_api/http/http_method_enum.rb +10 -0
  20. data/lib/boku_direct_payments_api/http/http_request.rb +10 -0
  21. data/lib/boku_direct_payments_api/http/http_response.rb +10 -0
  22. data/lib/boku_direct_payments_api/http/proxy_settings.rb +22 -0
  23. data/lib/boku_direct_payments_api/models/account_profile.rb +122 -0
  24. data/lib/boku_direct_payments_api/models/account_profile_attribute.rb +90 -0
  25. data/lib/boku_direct_payments_api/models/account_profile_request.rb +131 -0
  26. data/lib/boku_direct_payments_api/models/account_profile_response.rb +104 -0
  27. data/lib/boku_direct_payments_api/models/account_profile_response_record.rb +142 -0
  28. data/lib/boku_direct_payments_api/models/account_profile_result_status_enum.rb +47 -0
  29. data/lib/boku_direct_payments_api/models/account_profile_selector.rb +132 -0
  30. data/lib/boku_direct_payments_api/models/base_model.rb +110 -0
  31. data/lib/boku_direct_payments_api/models/begin_single_charge_request.rb +360 -0
  32. data/lib/boku_direct_payments_api/models/begin_single_charge_request_hosted.rb +110 -0
  33. data/lib/boku_direct_payments_api/models/begin_single_charge_request_qr_info.rb +74 -0
  34. data/lib/boku_direct_payments_api/models/begin_single_charge_response.rb +254 -0
  35. data/lib/boku_direct_payments_api/models/begin_single_charge_response_hosted.rb +90 -0
  36. data/lib/boku_direct_payments_api/models/begin_single_charge_response_qr_info.rb +85 -0
  37. data/lib/boku_direct_payments_api/models/business_details.rb +209 -0
  38. data/lib/boku_direct_payments_api/models/cancel_optin_request.rb +123 -0
  39. data/lib/boku_direct_payments_api/models/cancel_optin_response.rb +143 -0
  40. data/lib/boku_direct_payments_api/models/carrier_gw.rb +82 -0
  41. data/lib/boku_direct_payments_api/models/charge.rb +288 -0
  42. data/lib/boku_direct_payments_api/models/charge_msisdn_request.rb +233 -0
  43. data/lib/boku_direct_payments_api/models/charge_plus_optin_request.rb +390 -0
  44. data/lib/boku_direct_payments_api/models/charge_plus_optin_request_hosted.rb +96 -0
  45. data/lib/boku_direct_payments_api/models/charge_plus_optin_response.rb +278 -0
  46. data/lib/boku_direct_payments_api/models/charge_plus_optin_response_hosted.rb +75 -0
  47. data/lib/boku_direct_payments_api/models/charge_request.rb +332 -0
  48. data/lib/boku_direct_payments_api/models/charge_response.rb +253 -0
  49. data/lib/boku_direct_payments_api/models/charge_status_enum.rb +43 -0
  50. data/lib/boku_direct_payments_api/models/check_eligibility_request.rb +117 -0
  51. data/lib/boku_direct_payments_api/models/check_eligibility_response.rb +116 -0
  52. data/lib/boku_direct_payments_api/models/client_call.rb +91 -0
  53. data/lib/boku_direct_payments_api/models/confirm_optin_request.rb +141 -0
  54. data/lib/boku_direct_payments_api/models/confirm_optin_response.rb +211 -0
  55. data/lib/boku_direct_payments_api/models/confirm_verify_device_request.rb +161 -0
  56. data/lib/boku_direct_payments_api/models/confirm_verify_device_response.rb +137 -0
  57. data/lib/boku_direct_payments_api/models/eligibility_status_enum.rb +40 -0
  58. data/lib/boku_direct_payments_api/models/forex_request.rb +97 -0
  59. data/lib/boku_direct_payments_api/models/forex_response.rb +127 -0
  60. data/lib/boku_direct_payments_api/models/fund_check_request.rb +132 -0
  61. data/lib/boku_direct_payments_api/models/fund_check_response.rb +89 -0
  62. data/lib/boku_direct_payments_api/models/invalid_request_field.rb +93 -0
  63. data/lib/boku_direct_payments_api/models/mandate_constraint.rb +92 -0
  64. data/lib/boku_direct_payments_api/models/mandate_period_enum.rb +48 -0
  65. data/lib/boku_direct_payments_api/models/mcc_mnc_mapping.rb +85 -0
  66. data/lib/boku_direct_payments_api/models/method_enum.rb +36 -0
  67. data/lib/boku_direct_payments_api/models/msisdn_network_request.rb +97 -0
  68. data/lib/boku_direct_payments_api/models/msisdn_network_response.rb +116 -0
  69. data/lib/boku_direct_payments_api/models/network_info.rb +84 -0
  70. data/lib/boku_direct_payments_api/models/network_info_network.rb +168 -0
  71. data/lib/boku_direct_payments_api/models/optin_accept_networks.rb +87 -0
  72. data/lib/boku_direct_payments_api/models/optin_info.rb +99 -0
  73. data/lib/boku_direct_payments_api/models/optin_info_optin_network.rb +104 -0
  74. data/lib/boku_direct_payments_api/models/optin_info_optin_types.rb +128 -0
  75. data/lib/boku_direct_payments_api/models/optin_network.rb +115 -0
  76. data/lib/boku_direct_payments_api/models/optin_purpose_enum.rb +62 -0
  77. data/lib/boku_direct_payments_api/models/optin_request.rb +338 -0
  78. data/lib/boku_direct_payments_api/models/optin_request_hosted.rb +110 -0
  79. data/lib/boku_direct_payments_api/models/optin_request_qr_info.rb +75 -0
  80. data/lib/boku_direct_payments_api/models/optin_response.rb +220 -0
  81. data/lib/boku_direct_payments_api/models/optin_response_hosted.rb +87 -0
  82. data/lib/boku_direct_payments_api/models/optin_response_qr_info.rb +85 -0
  83. data/lib/boku_direct_payments_api/models/optin_state.rb +164 -0
  84. data/lib/boku_direct_payments_api/models/optin_status_enum.rb +51 -0
  85. data/lib/boku_direct_payments_api/models/optin_terms.rb +214 -0
  86. data/lib/boku_direct_payments_api/models/optin_type_enum.rb +45 -0
  87. data/lib/boku_direct_payments_api/models/payment_method_status_enum.rb +44 -0
  88. data/lib/boku_direct_payments_api/models/period.rb +89 -0
  89. data/lib/boku_direct_payments_api/models/period_unit_enum.rb +46 -0
  90. data/lib/boku_direct_payments_api/models/query_charge_request.rb +149 -0
  91. data/lib/boku_direct_payments_api/models/query_charge_response.rb +101 -0
  92. data/lib/boku_direct_payments_api/models/query_optin_request.rb +104 -0
  93. data/lib/boku_direct_payments_api/models/query_optin_response.rb +129 -0
  94. data/lib/boku_direct_payments_api/models/query_refund_request.rb +122 -0
  95. data/lib/boku_direct_payments_api/models/query_refund_response.rb +101 -0
  96. data/lib/boku_direct_payments_api/models/refund.rb +249 -0
  97. data/lib/boku_direct_payments_api/models/refund_charge_notification.rb +88 -0
  98. data/lib/boku_direct_payments_api/models/refund_charge_request.rb +231 -0
  99. data/lib/boku_direct_payments_api/models/refund_charge_response.rb +203 -0
  100. data/lib/boku_direct_payments_api/models/refund_status_enum.rb +43 -0
  101. data/lib/boku_direct_payments_api/models/refund_type_enum.rb +36 -0
  102. data/lib/boku_direct_payments_api/models/register_payment_method_request.rb +152 -0
  103. data/lib/boku_direct_payments_api/models/register_payment_method_response.rb +172 -0
  104. data/lib/boku_direct_payments_api/models/register_seller_of_record_request.rb +118 -0
  105. data/lib/boku_direct_payments_api/models/register_seller_of_record_response.rb +156 -0
  106. data/lib/boku_direct_payments_api/models/resend_otp_request.rb +167 -0
  107. data/lib/boku_direct_payments_api/models/resend_otp_response.rb +118 -0
  108. data/lib/boku_direct_payments_api/models/result.rb +154 -0
  109. data/lib/boku_direct_payments_api/models/result_status_enum.rb +36 -0
  110. data/lib/boku_direct_payments_api/models/reversal.rb +89 -0
  111. data/lib/boku_direct_payments_api/models/reverse_charge_request.rb +104 -0
  112. data/lib/boku_direct_payments_api/models/reverse_charge_response.rb +157 -0
  113. data/lib/boku_direct_payments_api/models/seller_of_record.rb +76 -0
  114. data/lib/boku_direct_payments_api/models/seller_of_record_status_enum.rb +44 -0
  115. data/lib/boku_direct_payments_api/models/send_sms.rb +89 -0
  116. data/lib/boku_direct_payments_api/models/settlement.rb +126 -0
  117. data/lib/boku_direct_payments_api/models/silent_mo.rb +78 -0
  118. data/lib/boku_direct_payments_api/models/status_enum.rb +40 -0
  119. data/lib/boku_direct_payments_api/models/subscription.rb +105 -0
  120. data/lib/boku_direct_payments_api/models/timeout.rb +75 -0
  121. data/lib/boku_direct_payments_api/models/type_enum.rb +36 -0
  122. data/lib/boku_direct_payments_api/models/validate_optin_request.rb +179 -0
  123. data/lib/boku_direct_payments_api/models/validate_optin_response.rb +195 -0
  124. data/lib/boku_direct_payments_api/models/verify_device_request.rb +135 -0
  125. data/lib/boku_direct_payments_api/models/verify_device_response.rb +137 -0
  126. data/lib/boku_direct_payments_api/utilities/date_time_helper.rb +11 -0
  127. data/lib/boku_direct_payments_api/utilities/file_wrapper.rb +28 -0
  128. data/lib/boku_direct_payments_api/utilities/xml_utilities.rb +12 -0
  129. data/lib/boku_direct_payments_api.rb +166 -0
  130. data/test/controllers/controller_test_base.rb +23 -0
  131. data/test/controllers/test_account_resources_controller.rb +44 -0
  132. data/test/controllers/test_charge_controller.rb +159 -0
  133. data/test/controllers/test_config_resources_controller.rb +47 -0
  134. data/test/controllers/test_consumer_registration_controller.rb +262 -0
  135. data/test/controllers/test_forex_controller.rb +40 -0
  136. data/test/controllers/test_fund_check_controller.rb +41 -0
  137. data/test/controllers/test_refund_controller.rb +76 -0
  138. data/test/controllers/test_seller_of_record_controller.rb +72 -0
  139. data/test/http_response_catcher.rb +19 -0
  140. metadata +255 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 954682d807d726b7a325dabaa054658063aaa00d09af8f93240db63929995dcd
4
+ data.tar.gz: 72b1d8c04587d7a62504aa3a13b344d6d0eb877b99a147b7b9c0593de2e0528a
5
+ SHA512:
6
+ metadata.gz: 1fa5a57fa39f05168ee7bb7c139f278ee5afe93f3d9c638860b1c383fb799c4e6e4343dad15b1fd11854cf008bf4cd453a290d9d89d43eb870aa8a3845c5e749
7
+ data.tar.gz: a14583ea1862d34cb37237d54a0527e5ff5767c4d673acf64f0c23542d65d1c4c953165c79d2bcfeae0cafe2e90ffc395edad08bb9ec36ac3acdc60405de5ba9
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,203 @@
1
+
2
+ # Getting Started with Boku Direct Payments API
3
+
4
+ ## Introduction
5
+
6
+ ### API Security
7
+
8
+ Security is a significant consideration for payment platforms. As part of the registration process for each registered merchant account, merchants receive a security key used to authenticate communications in either direction.
9
+
10
+ Developers should consult the [Boku API Signature Authentication Guide](page:guides/api-signature-authentication-guide) for additional details with respect to implementing security on the Boku APIs.
11
+
12
+ ### API Usage
13
+
14
+ When a consumer chooses to use a local payment-method (wallet), the consumer must go through an 'optin' flow to authenticate. This is accomplished using a redirect to the issuer's app or website where the consumer authenticates and completes the opt-in process.
15
+
16
+ After the consumer adds their local payment-method (wallet), as their registered payment method, the 'charge' method is used to charge the consumer's local payment-method.
17
+
18
+ If a customer decides to refund a transaction, the 'refund-charge' method can be used to refund the transaction.
19
+
20
+ ### API Versioning
21
+
22
+ The Boku Payment Gateway API is versioned to provide support for changes to functionality without affecting existing integrations. Each API URL includes version information that enables distinct functionality across different versions.
23
+
24
+ There are several types of changes that could result in a new API version:
25
+
26
+ 1. New API functionality – new APIs, new parameters, additional information in responses, improved error reporting.
27
+ 2. Deprecated API functionality – deprecated APIs, deprecated parameters, deprecated error messages.
28
+ 3. Changes in functionality – existing functional behavior changes such as the returned result of a call. A warning is changed to an error. Validation becomes stricter or more lenient.
29
+
30
+ In these cases, Boku will release a new API version through a new endpoint(s). When new versions of existing APIs are added, support for existing versions is maintained. Unless otherwise stated, as a rule, compatibility is maintained across versions. Prior supported endpoints should have unchanged behavior. If an API is deprecated and scheduled to be removed, a notice of not less than 6 months will be given. Requests for extensions to this period can be considered.
31
+
32
+ Boku may make changes to the API within an existing version without changing the version number. An example of a non-versioning change would be the addition of an optional field to a request or to a response.
33
+
34
+ ### API Calls
35
+
36
+ #### URL Scheme
37
+
38
+ All the below API calls are against URLs that follow the pattern,
39
+
40
+ `https://${api-node}.boku.com/${api-family}/${api-version}/${api-call}`
41
+
42
+ Definitions for the above placeholders:
43
+
44
+ * **api-node**: This follows the pattern '${country}-api4' (e.g. 'us-api4').
45
+ * 'country' is the two letter country code of the end-user's payment-method against which the call is made.
46
+ * The country code is required and is used for more efficient routing of the request.
47
+ * The country code in the url must match the country code supplied in the `optin-request`.`country` element.
48
+ * **api-family**: Groups a family of related API methods.
49
+ * In this API, family is either one of:
50
+ * 'optin' - For interacting with the user or handset to obtain billing approval.
51
+ * 'billing' - For actually performing billing operations against the user.
52
+ * **api-version**: In this version of the API, this value is always the string '3.0'.
53
+ * Calls under different version numbers may be used in the future to introduce non-compatible API changes.
54
+ * **api-call**: The name particular API call or method to invoke, for example 'charge' or 'refund-charge'.
55
+ * This usually matches the XML root element name, sans the '-request' suffix.
56
+
57
+ Fully qualified API call URLs are documented with each of the example calls detailed below.
58
+
59
+ ## Install the Package
60
+
61
+ Install the gem from the command line:
62
+
63
+ ```bash
64
+ gem install bk-apimatic-sdk -v 1.0.0
65
+ ```
66
+
67
+ Or add the gem to your Gemfile and run `bundle`:
68
+
69
+ ```ruby
70
+ gem 'bk-apimatic-sdk', '1.0.0'
71
+ ```
72
+
73
+ For additional gem details, see the [RubyGems page for the bk-apimatic-sdk gem](https://rubygems.org/gems/bk-apimatic-sdk/versions/1.0.0).
74
+
75
+ ## IRB Console Usage
76
+
77
+ You can explore the SDK interactively using IRB in two ways
78
+
79
+ ### 1. Use IRB with Installed Gem
80
+
81
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
82
+
83
+ ```bash
84
+ irb
85
+ ```
86
+
87
+ Now you can load the SDK in the IRB
88
+
89
+ ```ruby
90
+ require 'boku_direct_payments_api'
91
+ include BokuDirectPaymentsApi
92
+ ```
93
+
94
+ ### 2. Use IRB within SDK
95
+
96
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
97
+
98
+ ```
99
+ cd path/to/boku_direct_payments_api
100
+ ```
101
+
102
+ Now you can start the preconfigured irb console by running the following command
103
+
104
+ ```bash
105
+ ruby bin/console
106
+ ```
107
+
108
+ **_Note:_** This automatically loads the SDK from lib/
109
+
110
+ ## Test the SDK
111
+
112
+ To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
113
+
114
+ ```
115
+ rake
116
+ ```
117
+
118
+ ## Initialize the API Client
119
+
120
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/client.md)
121
+
122
+ The following parameters are configurable for the API Client:
123
+
124
+ | Parameter | Type | Description |
125
+ | --- | --- | --- |
126
+ | country | `String` | Country code in ISO 3166-1-alpha-2 standard<br>*Default*: `'gb'` |
127
+ | environment | [`Environment`](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/README.md#environments) | The API environment. <br> **Default: `Environment.MERCHANT_TEST_ENVIRONMENT`** |
128
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
129
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
130
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
131
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
132
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
133
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
134
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
135
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
136
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
137
+ | proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
138
+
139
+ The API client can be initialized as follows:
140
+
141
+ ### Code-Based Client Initialization
142
+
143
+ ```ruby
144
+ require 'boku_direct_payments_api'
145
+ include BokuDirectPaymentsApi
146
+
147
+ client = Client.new(
148
+ environment: Environment::MERCHANT_TEST_ENVIRONMENT,
149
+ country: 'gb'
150
+ )
151
+ ```
152
+
153
+ ### Environment-Based Client Initialization
154
+
155
+ ```ruby
156
+ require 'boku_direct_payments_api'
157
+ include BokuDirectPaymentsApi
158
+
159
+ # Create client from environment
160
+ client = Client.from_env
161
+ ```
162
+
163
+ See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
164
+
165
+ ## Environments
166
+
167
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
168
+
169
+ ### Fields
170
+
171
+ | Name | Description |
172
+ | --- | --- |
173
+ | MERCHANT_TEST_ENVIRONMENT | **Default** |
174
+ | PRODUCTION_ENVIRONMENT | - |
175
+
176
+ ## List of APIs
177
+
178
+ * [Consumer Registration](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/consumer-registration.md)
179
+ * [Account Resources](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/account-resources.md)
180
+ * [Config Resources](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/config-resources.md)
181
+ * [Charge](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/charge.md)
182
+ * [Refund](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/refund.md)
183
+ * [Forex](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/forex.md)
184
+ * [Fund-Check](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/fund-check.md)
185
+ * [Seller of Record](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/controllers/seller-of-record.md)
186
+
187
+ ## SDK Infrastructure
188
+
189
+ ### Configuration
190
+
191
+ * [ProxySettings](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
192
+ * [Environment-Based Client Initialization](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
193
+
194
+ ### HTTP
195
+
196
+ * [HttpResponse](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/http-response.md)
197
+ * [HttpRequest](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/http-request.md)
198
+
199
+ ### Utilities
200
+
201
+ * [ApiHelper](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/api-helper.md)
202
+ * [DateTimeHelper](https://www.github.com/sdks-io/bk--ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
203
+
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 'boku_direct_payments_api'
8
+
9
+ puts 'BokuDirectPaymentsApi SDK loaded!'
10
+ puts 'You can now create a client with: client = BokuDirectPaymentsApi::Client.new'
11
+ puts 'Or use from_env: client = BokuDirectPaymentsApi::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,10 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,99 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # boku_direct_payments_api client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config
11
+
12
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
15
+
16
+ # Access to consumer_registration controller.
17
+ # @return [ConsumerRegistrationController] Returns the controller instance.
18
+ def consumer_registration
19
+ @consumer_registration ||= ConsumerRegistrationController.new @global_configuration
20
+ end
21
+
22
+ # Access to charge controller.
23
+ # @return [ChargeController] Returns the controller instance.
24
+ def charge
25
+ @charge ||= ChargeController.new @global_configuration
26
+ end
27
+
28
+ # Access to refund controller.
29
+ # @return [RefundController] Returns the controller instance.
30
+ def refund
31
+ @refund ||= RefundController.new @global_configuration
32
+ end
33
+
34
+ # Access to account_resources controller.
35
+ # @return [AccountResourcesController] Returns the controller instance.
36
+ def account_resources
37
+ @account_resources ||= AccountResourcesController.new @global_configuration
38
+ end
39
+
40
+ # Access to forex controller.
41
+ # @return [ForexController] Returns the controller instance.
42
+ def forex
43
+ @forex ||= ForexController.new @global_configuration
44
+ end
45
+
46
+ # Access to fund_check controller.
47
+ # @return [FundCheckController] Returns the controller instance.
48
+ def fund_check
49
+ @fund_check ||= FundCheckController.new @global_configuration
50
+ end
51
+
52
+ # Access to config_resources controller.
53
+ # @return [ConfigResourcesController] Returns the controller instance.
54
+ def config_resources
55
+ @config_resources ||= ConfigResourcesController.new @global_configuration
56
+ end
57
+
58
+ # Access to seller_of_record controller.
59
+ # @return [SellerOfRecordController] Returns the controller instance.
60
+ def seller_of_record
61
+ @seller_of_record ||= SellerOfRecordController.new @global_configuration
62
+ end
63
+
64
+ def initialize(
65
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
66
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
67
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
68
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
69
+ environment: Environment::MERCHANT_TEST_ENVIRONMENT, country: 'gb',
70
+ config: nil
71
+ )
72
+ @config = if config.nil?
73
+ Configuration.new(connection: connection, adapter: adapter,
74
+ timeout: timeout, max_retries: max_retries,
75
+ retry_interval: retry_interval,
76
+ backoff_factor: backoff_factor,
77
+ retry_statuses: retry_statuses,
78
+ retry_methods: retry_methods,
79
+ http_callback: http_callback,
80
+ proxy_settings: proxy_settings,
81
+ environment: environment, country: country)
82
+ else
83
+ config
84
+ end
85
+
86
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
87
+ .base_uri_executor(@config.method(:get_base_uri))
88
+ .global_errors(BaseController::GLOBAL_ERRORS)
89
+ .user_agent(BaseController.user_agent)
90
+ end
91
+
92
+ # Creates a client directly from environment variables.
93
+ def self.from_env(**overrides)
94
+ default_config = Configuration.build_default_config_from_env
95
+ new_config = default_config.clone_with(**overrides)
96
+ new(config: new_config)
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,168 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ MERCHANT_TEST_ENVIRONMENT = 'Merchant Test Environment'.freeze,
11
+ PRODUCTION_ENVIRONMENT = 'Production Environment'.freeze
12
+ ].freeze
13
+
14
+ # Converts a string or symbol into a valid Environment constant.
15
+ def self.from_value(value, default_value = MERCHANT_TEST_ENVIRONMENT)
16
+ return default_value if value.nil?
17
+
18
+ str = value.to_s.strip.downcase
19
+ case str
20
+ when 'merchant_test_environment' then MERCHANT_TEST_ENVIRONMENT
21
+ when 'production_environment' then PRODUCTION_ENVIRONMENT
22
+
23
+ else
24
+ warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} "
25
+ default_value
26
+ end
27
+ end
28
+ end
29
+
30
+ # An enum for API servers.
31
+ class Server
32
+ SERVER = [
33
+ DEFAULT = 'default'.freeze
34
+ ].freeze
35
+
36
+ # Converts a string or symbol into a valid Server constant.
37
+ def self.from_value(value, default_value = DEFAULT)
38
+ return default_value if value.nil?
39
+
40
+ default_value
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
+ # The attribute readers for properties.
48
+ attr_reader :environment, :country
49
+
50
+ class << self
51
+ attr_reader :environments
52
+ end
53
+
54
+ def initialize(
55
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
56
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
57
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
58
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
59
+ environment: Environment::MERCHANT_TEST_ENVIRONMENT, country: 'gb'
60
+ )
61
+ super connection: connection, adapter: adapter, timeout: timeout,
62
+ max_retries: max_retries, retry_interval: retry_interval,
63
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
64
+ retry_methods: retry_methods, http_callback: http_callback,
65
+ proxy_settings: proxy_settings
66
+
67
+ # Current API environment
68
+ @environment = String(environment)
69
+
70
+ # Country code in ISO 3166-1-alpha-2 standard
71
+ @country = country
72
+
73
+ # The Http Client to use for making requests.
74
+ set_http_client CoreLibrary::FaradayClient.new(self)
75
+ end
76
+
77
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
78
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
79
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
80
+ proxy_settings: nil, environment: nil, country: nil)
81
+ connection ||= self.connection
82
+ adapter ||= self.adapter
83
+ timeout ||= self.timeout
84
+ max_retries ||= self.max_retries
85
+ retry_interval ||= self.retry_interval
86
+ backoff_factor ||= self.backoff_factor
87
+ retry_statuses ||= self.retry_statuses
88
+ retry_methods ||= self.retry_methods
89
+ http_callback ||= self.http_callback
90
+ proxy_settings ||= self.proxy_settings
91
+ environment ||= self.environment
92
+ country ||= self.country
93
+
94
+ Configuration.new(connection: connection, adapter: adapter,
95
+ timeout: timeout, max_retries: max_retries,
96
+ retry_interval: retry_interval,
97
+ backoff_factor: backoff_factor,
98
+ retry_statuses: retry_statuses,
99
+ retry_methods: retry_methods,
100
+ http_callback: http_callback,
101
+ proxy_settings: proxy_settings,
102
+ environment: environment, country: country)
103
+ end
104
+
105
+
106
+ # All the environments the SDK can run in.
107
+ ENVIRONMENTS = {
108
+ Environment::MERCHANT_TEST_ENVIRONMENT => {
109
+ Server::DEFAULT => 'https://{country}-api4-stage.boku.com'
110
+ },
111
+ Environment::PRODUCTION_ENVIRONMENT => {
112
+ Server::DEFAULT => 'https://{country}-api4.boku.com'
113
+ }
114
+ }.freeze
115
+
116
+ # Generates the appropriate base URI for the environment and the server.
117
+ # @param [Configuration::Server] server The server enum for which the base URI is
118
+ # required.
119
+ # @return [String] The base URI.
120
+ def get_base_uri(server = Server::DEFAULT)
121
+ parameters = {
122
+ 'country' => { 'value' => country, 'encode' => false }
123
+ }
124
+ APIHelper.append_url_with_template_parameters(
125
+ ENVIRONMENTS[environment][server], parameters
126
+ )
127
+ end
128
+
129
+ # Builds a Configuration instance using environment variables.
130
+ def self.build_default_config_from_env
131
+ # === Core environment ===
132
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'merchant_test_environment'))
133
+ country = ENV.fetch('COUNTRY', 'gb')
134
+ timeout = (ENV['TIMEOUT'] || 60).to_f
135
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
136
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
137
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
138
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
139
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
140
+ .split(',')
141
+ .map(&:strip)
142
+ .map do |item|
143
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
144
+ end
145
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
146
+ .split(',')
147
+ .map(&:strip)
148
+ .map do |item|
149
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
150
+ end
151
+
152
+ # === Proxy settings ===
153
+ proxy_settings = ProxySettings.from_env
154
+
155
+ Configuration.new(
156
+ environment: environment,
157
+ country: country,
158
+ timeout: timeout,
159
+ max_retries: max_retries,
160
+ retry_interval: retry_interval,
161
+ backoff_factor: backoff_factor,
162
+ retry_statuses: retry_statuses,
163
+ retry_methods: retry_methods,
164
+ proxy_settings: proxy_settings
165
+ )
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,45 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
7
+ # AccountResourcesController
8
+ class AccountResourcesController < BaseController
9
+ # **DISCLAIMER: This API or element is use-case specific and not needed for
10
+ # generic usage of our payment product. Please disregard unless otherwise
11
+ # directed to include in your integration.**
12
+ # The account profile is designed to be a batch API (i.e. each call can
13
+ # request and return multiple account-profile records) but it can also be
14
+ # used for single account-profile record requests.
15
+ # For each input `selector` element in the request, there is always exactly
16
+ # one `record` element in the response even if no corresponding account
17
+ # profile was found. Each `record` element in the response contains the
18
+ # exact `selector` element from the request that was used to process that
19
+ # record. The ordering of elements in the response always corresponds
20
+ # directly to the ordering of elements in the request, i.e.
21
+ # response.records[42].selector equals request.selectors[42].
22
+ # @param [AccountProfileRequest] body Required parameter: TODO: type
23
+ # description here
24
+ # @return [AccountProfileResponse] Response from the API call.
25
+ def get_optin_account_profile(body)
26
+ @api_call
27
+ .request(new_request_builder(HttpMethodEnum::POST,
28
+ '/account/3.0/query-account-profile',
29
+ Server::DEFAULT)
30
+ .header_param(new_parameter('application/xml', key: 'Content-Type'))
31
+ .xml_attributes(XmlAttributes.new
32
+ .value(body)
33
+ .root_element_name('account-profile-request'))
34
+ .header_param(new_parameter('application/xml', key: 'accept'))
35
+ .body_serializer(XmlUtilities.method(:serialize_to_xml)))
36
+ .response(new_response_handler
37
+ .deserializer(XmlUtilities.method(:deserialize_xml))
38
+ .deserialize_into(AccountProfileResponse)
39
+ .is_xml_response(true)
40
+ .xml_attribute(XmlAttributes.new
41
+ .root_element_name('account-profile-response')))
42
+ .execute
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,60 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module BokuDirectPaymentsApi
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