univapay-client-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 (241) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +212 -0
  4. data/bin/console +15 -0
  5. data/lib/univapay_client_sdk/api_helper.rb +10 -0
  6. data/lib/univapay_client_sdk/apis/base_api.rb +67 -0
  7. data/lib/univapay_client_sdk/apis/cancels_api.rb +293 -0
  8. data/lib/univapay_client_sdk/apis/charges_api.rb +909 -0
  9. data/lib/univapay_client_sdk/apis/merchants_api.rb +57 -0
  10. data/lib/univapay_client_sdk/apis/refunds_api.rb +298 -0
  11. data/lib/univapay_client_sdk/apis/stores_api.rb +126 -0
  12. data/lib/univapay_client_sdk/apis/subscriptions_api.rb +1014 -0
  13. data/lib/univapay_client_sdk/apis/transaction_tokens_api.rb +455 -0
  14. data/lib/univapay_client_sdk/apis/webhooks_api.rb +463 -0
  15. data/lib/univapay_client_sdk/client.rb +128 -0
  16. data/lib/univapay_client_sdk/configuration.rb +179 -0
  17. data/lib/univapay_client_sdk/events/unknown_event.rb +32 -0
  18. data/lib/univapay_client_sdk/events/webhooks/bank_transfer_handler.rb +37 -0
  19. data/lib/univapay_client_sdk/events/webhooks/cancel_handler.rb +37 -0
  20. data/lib/univapay_client_sdk/events/webhooks/charge_handler.rb +37 -0
  21. data/lib/univapay_client_sdk/events/webhooks/customs_handler.rb +37 -0
  22. data/lib/univapay_client_sdk/events/webhooks/refund_handler.rb +37 -0
  23. data/lib/univapay_client_sdk/events/webhooks/subscription_handler.rb +37 -0
  24. data/lib/univapay_client_sdk/events/webhooks/token_handler.rb +37 -0
  25. data/lib/univapay_client_sdk/exceptions/api_error_exception.rb +199 -0
  26. data/lib/univapay_client_sdk/exceptions/api_exception.rb +21 -0
  27. data/lib/univapay_client_sdk/extensions.rb +127 -0
  28. data/lib/univapay_client_sdk/http/api_response.rb +19 -0
  29. data/lib/univapay_client_sdk/http/auth/oauth_2.rb +58 -0
  30. data/lib/univapay_client_sdk/http/http_call_back.rb +10 -0
  31. data/lib/univapay_client_sdk/http/http_method_enum.rb +10 -0
  32. data/lib/univapay_client_sdk/http/http_request.rb +10 -0
  33. data/lib/univapay_client_sdk/http/http_response.rb +10 -0
  34. data/lib/univapay_client_sdk/http/proxy_settings.rb +22 -0
  35. data/lib/univapay_client_sdk/logging/configuration/api_logging_configuration.rb +186 -0
  36. data/lib/univapay_client_sdk/logging/sdk_logger.rb +17 -0
  37. data/lib/univapay_client_sdk/models/api_error_detail.rb +87 -0
  38. data/lib/univapay_client_sdk/models/api_error_status.rb +26 -0
  39. data/lib/univapay_client_sdk/models/bank_transfer_event.rb +27 -0
  40. data/lib/univapay_client_sdk/models/bank_transfer_ledger.rb +199 -0
  41. data/lib/univapay_client_sdk/models/bank_transfer_ledger_bank_ledger_type.rb +36 -0
  42. data/lib/univapay_client_sdk/models/bank_transfer_ledger_list.rb +104 -0
  43. data/lib/univapay_client_sdk/models/bank_transfer_ledger_mode.rb +36 -0
  44. data/lib/univapay_client_sdk/models/bank_transfer_payment_status.rb +44 -0
  45. data/lib/univapay_client_sdk/models/bank_transfer_status_data.rb +229 -0
  46. data/lib/univapay_client_sdk/models/bank_transfer_status_webhook_callback.rb +134 -0
  47. data/lib/univapay_client_sdk/models/bank_transfer_status_webhook_callback_extension.rb +75 -0
  48. data/lib/univapay_client_sdk/models/base_bank_transfer_data.rb +100 -0
  49. data/lib/univapay_client_sdk/models/base_konbini_data.rb +99 -0
  50. data/lib/univapay_client_sdk/models/base_konbini_data_convenience_store.rb +60 -0
  51. data/lib/univapay_client_sdk/models/base_model.rb +110 -0
  52. data/lib/univapay_client_sdk/models/base_online_data.rb +123 -0
  53. data/lib/univapay_client_sdk/models/base_online_data_brand.rb +48 -0
  54. data/lib/univapay_client_sdk/models/base_online_data_call_method.rb +52 -0
  55. data/lib/univapay_client_sdk/models/base_online_data_os_type.rb +36 -0
  56. data/lib/univapay_client_sdk/models/base_online_data_user_identifier_source.rb +36 -0
  57. data/lib/univapay_client_sdk/models/cancel.rb +183 -0
  58. data/lib/univapay_client_sdk/models/cancel_create_request.rb +77 -0
  59. data/lib/univapay_client_sdk/models/cancel_event.rb +26 -0
  60. data/lib/univapay_client_sdk/models/cancel_list.rb +94 -0
  61. data/lib/univapay_client_sdk/models/cancel_status.rb +44 -0
  62. data/lib/univapay_client_sdk/models/cancel_update_request.rb +76 -0
  63. data/lib/univapay_client_sdk/models/cancel_webhook_callback.rb +132 -0
  64. data/lib/univapay_client_sdk/models/cancel_webhook_callback_extension.rb +74 -0
  65. data/lib/univapay_client_sdk/models/card_processor_installment_config.rb +89 -0
  66. data/lib/univapay_client_sdk/models/charge.rb +411 -0
  67. data/lib/univapay_client_sdk/models/charge_capture_request.rb +84 -0
  68. data/lib/univapay_client_sdk/models/charge_create_request.rb +179 -0
  69. data/lib/univapay_client_sdk/models/charge_create_request_client_metadata.rb +76 -0
  70. data/lib/univapay_client_sdk/models/charge_create_request_redirect.rb +75 -0
  71. data/lib/univapay_client_sdk/models/charge_create_request_three_ds.rb +88 -0
  72. data/lib/univapay_client_sdk/models/charge_create_request_three_ds_mode.rb +44 -0
  73. data/lib/univapay_client_sdk/models/charge_event.rb +36 -0
  74. data/lib/univapay_client_sdk/models/charge_list.rb +104 -0
  75. data/lib/univapay_client_sdk/models/charge_mode.rb +36 -0
  76. data/lib/univapay_client_sdk/models/charge_redirect.rb +96 -0
  77. data/lib/univapay_client_sdk/models/charge_status.rb +56 -0
  78. data/lib/univapay_client_sdk/models/charge_three_ds.rb +97 -0
  79. data/lib/univapay_client_sdk/models/charge_transaction_token_type.rb +40 -0
  80. data/lib/univapay_client_sdk/models/charge_update_request.rb +75 -0
  81. data/lib/univapay_client_sdk/models/charge_webhook_event.rb +138 -0
  82. data/lib/univapay_client_sdk/models/cursor_direction_query.rb +36 -0
  83. data/lib/univapay_client_sdk/models/customs_declaration_create_request.rb +106 -0
  84. data/lib/univapay_client_sdk/models/customs_declaration_event.rb +27 -0
  85. data/lib/univapay_client_sdk/models/customs_declaration_patch_request.rb +77 -0
  86. data/lib/univapay_client_sdk/models/customs_declaration_webhook_callback.rb +135 -0
  87. data/lib/univapay_client_sdk/models/customs_declaration_webhook_callback_extension.rb +76 -0
  88. data/lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb +232 -0
  89. data/lib/univapay_client_sdk/models/customs_declaration_webhook_declaration.rb +121 -0
  90. data/lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb +127 -0
  91. data/lib/univapay_client_sdk/models/customs_declaration_webhook_other_error.rb +120 -0
  92. data/lib/univapay_client_sdk/models/customs_declaration_webhook_result.rb +125 -0
  93. data/lib/univapay_client_sdk/models/customs_declaration_webhook_status.rb +44 -0
  94. data/lib/univapay_client_sdk/models/generic_metadata.rb +111 -0
  95. data/lib/univapay_client_sdk/models/installment_fixed_cycles.rb +70 -0
  96. data/lib/univapay_client_sdk/models/installment_plan_type.rb +36 -0
  97. data/lib/univapay_client_sdk/models/issuer_token.rb +177 -0
  98. data/lib/univapay_client_sdk/models/issuer_token_call_method.rb +51 -0
  99. data/lib/univapay_client_sdk/models/issuer_token_payload.rb +105 -0
  100. data/lib/univapay_client_sdk/models/issuer_token_payment_type.rb +36 -0
  101. data/lib/univapay_client_sdk/models/merchant.rb +179 -0
  102. data/lib/univapay_client_sdk/models/merchant_webhook_bank_transfer_configuration.rb +342 -0
  103. data/lib/univapay_client_sdk/models/merchant_webhook_card_brand_percent_fees.rb +167 -0
  104. data/lib/univapay_client_sdk/models/merchant_webhook_card_configuration.rb +301 -0
  105. data/lib/univapay_client_sdk/models/merchant_webhook_checkout_configuration.rb +87 -0
  106. data/lib/univapay_client_sdk/models/merchant_webhook_checkout_toggle.rb +77 -0
  107. data/lib/univapay_client_sdk/models/merchant_webhook_configuration.rb +505 -0
  108. data/lib/univapay_client_sdk/models/merchant_webhook_convenience_configuration.rb +88 -0
  109. data/lib/univapay_client_sdk/models/merchant_webhook_customer_management_configuration.rb +99 -0
  110. data/lib/univapay_client_sdk/models/merchant_webhook_installment_plan_configuration.rb +139 -0
  111. data/lib/univapay_client_sdk/models/merchant_webhook_limit_charge_by_card_configuration.rb +88 -0
  112. data/lib/univapay_client_sdk/models/merchant_webhook_limit_refund_by_sales_configuration.rb +100 -0
  113. data/lib/univapay_client_sdk/models/merchant_webhook_money_amount.rb +85 -0
  114. data/lib/univapay_client_sdk/models/merchant_webhook_online_configuration.rb +77 -0
  115. data/lib/univapay_client_sdk/models/merchant_webhook_paidy_configuration.rb +77 -0
  116. data/lib/univapay_client_sdk/models/merchant_webhook_qr_merchant_configuration.rb +77 -0
  117. data/lib/univapay_client_sdk/models/merchant_webhook_qr_scan_configuration.rb +93 -0
  118. data/lib/univapay_client_sdk/models/merchant_webhook_recurring_cvv_confirmation_config.rb +97 -0
  119. data/lib/univapay_client_sdk/models/merchant_webhook_recurring_token_configuration.rb +109 -0
  120. data/lib/univapay_client_sdk/models/merchant_webhook_security_configuration.rb +234 -0
  121. data/lib/univapay_client_sdk/models/merchant_webhook_subscription_configuration.rb +138 -0
  122. data/lib/univapay_client_sdk/models/merchant_webhook_subscription_plan_configuration.rb +138 -0
  123. data/lib/univapay_client_sdk/models/merchant_webhook_transfer_schedule_configuration.rb +159 -0
  124. data/lib/univapay_client_sdk/models/merchant_webhook_user_transactions_configuration.rb +349 -0
  125. data/lib/univapay_client_sdk/models/mode_query.rb +36 -0
  126. data/lib/univapay_client_sdk/models/payment_error.rb +178 -0
  127. data/lib/univapay_client_sdk/models/plan_settings_type.rb +36 -0
  128. data/lib/univapay_client_sdk/models/refund.rb +240 -0
  129. data/lib/univapay_client_sdk/models/refund_create_request.rb +118 -0
  130. data/lib/univapay_client_sdk/models/refund_event.rb +26 -0
  131. data/lib/univapay_client_sdk/models/refund_list.rb +104 -0
  132. data/lib/univapay_client_sdk/models/refund_reason_request.rb +42 -0
  133. data/lib/univapay_client_sdk/models/refund_reason_response.rb +62 -0
  134. data/lib/univapay_client_sdk/models/refund_status.rb +47 -0
  135. data/lib/univapay_client_sdk/models/refund_update_request.rb +99 -0
  136. data/lib/univapay_client_sdk/models/refund_webhook_callback.rb +132 -0
  137. data/lib/univapay_client_sdk/models/refund_webhook_callback_extension.rb +74 -0
  138. data/lib/univapay_client_sdk/models/restrict_ip_after_failed_charge_config.rb +99 -0
  139. data/lib/univapay_client_sdk/models/store.rb +119 -0
  140. data/lib/univapay_client_sdk/models/store_list.rb +104 -0
  141. data/lib/univapay_client_sdk/models/store_list_item.rb +114 -0
  142. data/lib/univapay_client_sdk/models/subscription.rb +310 -0
  143. data/lib/univapay_client_sdk/models/subscription_create_request.rb +216 -0
  144. data/lib/univapay_client_sdk/models/subscription_event.rb +54 -0
  145. data/lib/univapay_client_sdk/models/subscription_installment_plan.rb +86 -0
  146. data/lib/univapay_client_sdk/models/subscription_list.rb +104 -0
  147. data/lib/univapay_client_sdk/models/subscription_list_item.rb +352 -0
  148. data/lib/univapay_client_sdk/models/subscription_next_payment.rb +222 -0
  149. data/lib/univapay_client_sdk/models/subscription_patch_payment_request.rb +117 -0
  150. data/lib/univapay_client_sdk/models/subscription_patch_token_request.rb +79 -0
  151. data/lib/univapay_client_sdk/models/subscription_payment.rb +185 -0
  152. data/lib/univapay_client_sdk/models/subscription_payment_list.rb +94 -0
  153. data/lib/univapay_client_sdk/models/subscription_period.rb +56 -0
  154. data/lib/univapay_client_sdk/models/subscription_plan_settings.rb +98 -0
  155. data/lib/univapay_client_sdk/models/subscription_schedule_settings.rb +132 -0
  156. data/lib/univapay_client_sdk/models/subscription_status.rb +56 -0
  157. data/lib/univapay_client_sdk/models/subscription_suspend_request.rb +79 -0
  158. data/lib/univapay_client_sdk/models/subscription_terminate_with_status.rb +36 -0
  159. data/lib/univapay_client_sdk/models/subscription_termination_mode.rb +36 -0
  160. data/lib/univapay_client_sdk/models/subscription_update_next_payment.rb +104 -0
  161. data/lib/univapay_client_sdk/models/subscription_update_request.rb +134 -0
  162. data/lib/univapay_client_sdk/models/subscription_update_schedule_settings.rb +110 -0
  163. data/lib/univapay_client_sdk/models/subscription_update_status.rb +37 -0
  164. data/lib/univapay_client_sdk/models/subscription_user_data.rb +134 -0
  165. data/lib/univapay_client_sdk/models/subscription_webhook_event.rb +143 -0
  166. data/lib/univapay_client_sdk/models/suspend_schedule_settings.rb +78 -0
  167. data/lib/univapay_client_sdk/models/three_ds_issuer_token.rb +116 -0
  168. data/lib/univapay_client_sdk/models/three_ds_issuer_token_call_method.rb +26 -0
  169. data/lib/univapay_client_sdk/models/three_ds_issuer_token_payment_type.rb +26 -0
  170. data/lib/univapay_client_sdk/models/token_create_bank_transfer_data.rb +122 -0
  171. data/lib/univapay_client_sdk/models/token_create_card_data.rb +230 -0
  172. data/lib/univapay_client_sdk/models/token_create_card_data_cvv_authorize.rb +95 -0
  173. data/lib/univapay_client_sdk/models/token_create_card_data_three_ds.rb +97 -0
  174. data/lib/univapay_client_sdk/models/token_create_konbini_data.rb +146 -0
  175. data/lib/univapay_client_sdk/models/token_create_online_data.rb +142 -0
  176. data/lib/univapay_client_sdk/models/token_create_phone_number.rb +104 -0
  177. data/lib/univapay_client_sdk/models/token_event.rb +59 -0
  178. data/lib/univapay_client_sdk/models/token_response_bank_transfer_data.rb +181 -0
  179. data/lib/univapay_client_sdk/models/token_response_card_data.rb +129 -0
  180. data/lib/univapay_client_sdk/models/token_response_card_data_billing.rb +153 -0
  181. data/lib/univapay_client_sdk/models/token_response_card_data_card.rb +187 -0
  182. data/lib/univapay_client_sdk/models/token_response_card_data_cvv_authorize.rb +132 -0
  183. data/lib/univapay_client_sdk/models/token_response_card_data_cvv_authorize_check.rb +118 -0
  184. data/lib/univapay_client_sdk/models/token_response_card_data_three_ds.rb +142 -0
  185. data/lib/univapay_client_sdk/models/token_response_card_data_three_ds_status.rb +48 -0
  186. data/lib/univapay_client_sdk/models/token_response_konbini_data.rb +135 -0
  187. data/lib/univapay_client_sdk/models/token_response_online_data.rb +158 -0
  188. data/lib/univapay_client_sdk/models/token_response_phone_number.rb +96 -0
  189. data/lib/univapay_client_sdk/models/token_webhook_event.rb +144 -0
  190. data/lib/univapay_client_sdk/models/transaction_token.rb +250 -0
  191. data/lib/univapay_client_sdk/models/transaction_token_create_request.rb +161 -0
  192. data/lib/univapay_client_sdk/models/transaction_token_create_request_metadata.rb +124 -0
  193. data/lib/univapay_client_sdk/models/transaction_token_create_request_payment_type.rb +44 -0
  194. data/lib/univapay_client_sdk/models/transaction_token_create_request_type.rb +40 -0
  195. data/lib/univapay_client_sdk/models/transaction_token_list.rb +104 -0
  196. data/lib/univapay_client_sdk/models/transaction_token_list_item.rb +204 -0
  197. data/lib/univapay_client_sdk/models/transaction_token_list_item_user_data.rb +96 -0
  198. data/lib/univapay_client_sdk/models/transaction_token_mode.rb +36 -0
  199. data/lib/univapay_client_sdk/models/transaction_token_payment_type.rb +48 -0
  200. data/lib/univapay_client_sdk/models/transaction_token_type.rb +40 -0
  201. data/lib/univapay_client_sdk/models/transaction_token_update_request.rb +95 -0
  202. data/lib/univapay_client_sdk/models/transaction_token_update_request_data.rb +184 -0
  203. data/lib/univapay_client_sdk/models/transaction_token_update_request_data_phone_number.rb +86 -0
  204. data/lib/univapay_client_sdk/models/webhook.rb +191 -0
  205. data/lib/univapay_client_sdk/models/webhook_callback_envelope.rb +98 -0
  206. data/lib/univapay_client_sdk/models/webhook_create_request.rb +97 -0
  207. data/lib/univapay_client_sdk/models/webhook_event.rb +166 -0
  208. data/lib/univapay_client_sdk/models/webhook_event_list.rb +94 -0
  209. data/lib/univapay_client_sdk/models/webhook_list.rb +94 -0
  210. data/lib/univapay_client_sdk/models/webhook_trigger.rb +104 -0
  211. data/lib/univapay_client_sdk/models/webhook_update_request.rb +108 -0
  212. data/lib/univapay_client_sdk/utilities/date_time_helper.rb +11 -0
  213. data/lib/univapay_client_sdk/utilities/file_wrapper.rb +28 -0
  214. data/lib/univapay_client_sdk/utilities/union_type_lookup.rb +182 -0
  215. data/lib/univapay_client_sdk.rb +285 -0
  216. data/test/apis/api_test_base.rb +23 -0
  217. data/test/apis/test_cancels_api.rb +162 -0
  218. data/test/apis/test_charges_api.rb +565 -0
  219. data/test/apis/test_error_messages.rb +38 -0
  220. data/test/apis/test_merchants_api.rb +50 -0
  221. data/test/apis/test_refunds_api.rb +172 -0
  222. data/test/apis/test_stores_api.rb +86 -0
  223. data/test/apis/test_subscriptions_api.rb +579 -0
  224. data/test/apis/test_transaction_tokens_api.rb +305 -0
  225. data/test/apis/test_webhooks_api.rb +245 -0
  226. data/test/events/webhooks/test_bank_transfer_handler.rb +95 -0
  227. data/test/events/webhooks/test_cancel_handler.rb +90 -0
  228. data/test/events/webhooks/test_charge_handler.rb +138 -0
  229. data/test/events/webhooks/test_customs_handler.rb +100 -0
  230. data/test/events/webhooks/test_refund_handler.rb +95 -0
  231. data/test/events/webhooks/test_subscription_handler.rb +346 -0
  232. data/test/events/webhooks/test_token_handler.rb +332 -0
  233. data/test/framework_integrations/rails_app_test_helper.rb +14 -0
  234. data/test/framework_integrations/webhooks/apps/hanami_charge_app.rb +61 -0
  235. data/test/framework_integrations/webhooks/apps/rails_charge_app.rb +24 -0
  236. data/test/framework_integrations/webhooks/apps/sinatra_charge_app.rb +27 -0
  237. data/test/framework_integrations/webhooks/test/test_hanami_charge_app.rb +57 -0
  238. data/test/framework_integrations/webhooks/test/test_rails_charge_app.rb +57 -0
  239. data/test/framework_integrations/webhooks/test/test_sinatra_charge_app.rb +58 -0
  240. data/test/http_response_catcher.rb +32 -0
  241. metadata +366 -0
@@ -0,0 +1,179 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ # PRODUCTION: Production Server
10
+ ENVIRONMENT = [
11
+ PRODUCTION = 'production'.freeze
12
+ ].freeze
13
+
14
+ # Converts a string or symbol into a valid Environment constant.
15
+ def self.from_value(value, default_value = PRODUCTION)
16
+ return default_value if value.nil?
17
+
18
+ default_value
19
+ end
20
+ end
21
+
22
+ # An enum for API servers.
23
+ class Server
24
+ SERVER = [
25
+ DEFAULT = 'default'.freeze
26
+ ].freeze
27
+
28
+ # Converts a string or symbol into a valid Server constant.
29
+ def self.from_value(value, default_value = DEFAULT)
30
+ return default_value if value.nil?
31
+
32
+ default_value
33
+ end
34
+ end
35
+
36
+ # All configuration including auth info and base URI for the API access
37
+ # are configured in this class.
38
+ class Configuration < CoreLibrary::HttpClientConfiguration
39
+ # The attribute readers for properties.
40
+ attr_reader :environment, :base_url, :bearer_auth_credentials
41
+
42
+ class << self
43
+ attr_reader :environments
44
+ end
45
+
46
+ def initialize(
47
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
48
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
49
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
50
+ retry_methods: %i[get put get put], http_callback: nil,
51
+ proxy_settings: nil, logging_configuration: nil,
52
+ environment: Environment::PRODUCTION,
53
+ base_url: 'https://api.univapay.com', bearer_auth_credentials: nil
54
+ )
55
+ super connection: connection, adapter: adapter, timeout: timeout,
56
+ max_retries: max_retries, retry_interval: retry_interval,
57
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
58
+ retry_methods: retry_methods, http_callback: http_callback,
59
+ proxy_settings: proxy_settings,
60
+ logging_configuration: logging_configuration
61
+
62
+ # Current API environment
63
+ @environment = String(environment)
64
+
65
+ # Base URL for the API
66
+ @base_url = base_url
67
+
68
+ # The object holding OAuth 2 Bearer token credentials
69
+ @bearer_auth_credentials = bearer_auth_credentials
70
+
71
+ # Initializing OAuth 2 Bearer token credentials with the provided auth parameters
72
+ @bearer_auth_credentials = bearer_auth_credentials
73
+
74
+ # The Http Client to use for making requests.
75
+ set_http_client CoreLibrary::FaradayClient.new(self)
76
+ end
77
+
78
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
79
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
80
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
81
+ proxy_settings: nil, logging_configuration: nil,
82
+ environment: nil, base_url: nil,
83
+ bearer_auth_credentials: nil)
84
+ connection ||= self.connection
85
+ adapter ||= self.adapter
86
+ timeout ||= self.timeout
87
+ max_retries ||= self.max_retries
88
+ retry_interval ||= self.retry_interval
89
+ backoff_factor ||= self.backoff_factor
90
+ retry_statuses ||= self.retry_statuses
91
+ retry_methods ||= self.retry_methods
92
+ http_callback ||= self.http_callback
93
+ proxy_settings ||= self.proxy_settings
94
+ logging_configuration ||= self.logging_configuration
95
+ environment ||= self.environment
96
+ base_url ||= self.base_url
97
+ bearer_auth_credentials ||= self.bearer_auth_credentials
98
+
99
+ Configuration.new(connection: connection, adapter: adapter,
100
+ timeout: timeout, max_retries: max_retries,
101
+ retry_interval: retry_interval,
102
+ backoff_factor: backoff_factor,
103
+ retry_statuses: retry_statuses,
104
+ retry_methods: retry_methods,
105
+ http_callback: http_callback,
106
+ proxy_settings: proxy_settings,
107
+ logging_configuration: logging_configuration,
108
+ environment: environment, base_url: base_url,
109
+ bearer_auth_credentials: bearer_auth_credentials)
110
+ end
111
+
112
+
113
+ # All the environments the SDK can run in.
114
+ ENVIRONMENTS = {
115
+ Environment::PRODUCTION => {
116
+ Server::DEFAULT => '{baseUrl}'
117
+ }
118
+ }.freeze
119
+
120
+ # Generates the appropriate base URI for the environment and the server.
121
+ # @param [Configuration::Server] server The server enum for which the base URI is
122
+ # required.
123
+ # @return [String] The base URI.
124
+ def get_base_uri(server = Server::DEFAULT)
125
+ parameters = {
126
+ 'baseUrl' => { 'value' => base_url, 'encode' => false }
127
+ }
128
+ APIHelper.append_url_with_template_parameters(
129
+ ENVIRONMENTS[environment][server], parameters
130
+ )
131
+ end
132
+
133
+ # Builds a Configuration instance using environment variables.
134
+ def self.build_default_config_from_env
135
+ # === Core environment ===
136
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
137
+ base_url = ENV.fetch('BASE_URL', 'https://api.univapay.com')
138
+ timeout = (ENV['TIMEOUT'] || 30).to_f
139
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
140
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
141
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
142
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
143
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
144
+ .split(',')
145
+ .map(&:strip)
146
+ .map do |item|
147
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
148
+ end
149
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put get put]').gsub(/[\[\]]/, '')
150
+ .split(',')
151
+ .map(&:strip)
152
+ .map do |item|
153
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
154
+ end
155
+
156
+ # === Authentication credentials ===
157
+ bearer_auth_credentials = BearerAuthCredentials.from_env
158
+
159
+ # === Proxy settings ===
160
+ proxy_settings = ProxySettings.from_env
161
+ # === Logging Configuration ===
162
+ logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
163
+
164
+ Configuration.new(
165
+ environment: environment,
166
+ base_url: base_url,
167
+ timeout: timeout,
168
+ max_retries: max_retries,
169
+ retry_interval: retry_interval,
170
+ backoff_factor: backoff_factor,
171
+ retry_statuses: retry_statuses,
172
+ retry_methods: retry_methods,
173
+ bearer_auth_credentials: bearer_auth_credentials,
174
+ proxy_settings: proxy_settings,
175
+ logging_configuration: logging_configuration
176
+ )
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,32 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # Represents an unrecognized or unsupported event during processing.
8
+ class UnknownEvent
9
+ # @return [Array<String>]
10
+ attr_reader :errors
11
+
12
+ # Initialize with the errors that caused the failure.
13
+ # @param errors [Array<String>] A list of error messages describing the reasons for verification failure.
14
+ def initialize(errors)
15
+ @errors = errors
16
+ end
17
+
18
+ # Provides a user-friendly string representation of the failure.
19
+ # @return [String]
20
+ def to_s
21
+ class_name = self.class.name.split('::').last
22
+ "<#{class_name} errors: #{@errors}>"
23
+ end
24
+
25
+ # Provides a debugging-friendly string with detailed object information.
26
+ # @return [String]
27
+ def inspect
28
+ class_name = self.class.name.split('::').last
29
+ "<#{class_name} errors: #{@errors.inspect}>"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # BankTransferHandler is responsible for verifying request signatures
8
+ # and parsing incoming bank-transfer events into strongly typed objects.
9
+ class BankTransferHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the BankTransferHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[BankTransferStatusWebhookCallback, UnknownEvent]
18
+ # BankTransferStatusWebhookCallback for successful parsing;
19
+ #
20
+ # UnknownEvent for unknown events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:BankTransfer)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # CancelHandler is responsible for verifying request signatures
8
+ # and parsing incoming cancel events into strongly typed objects.
9
+ class CancelHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the CancelHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[CancelWebhookCallback, UnknownEvent]
18
+ # CancelWebhookCallback for successful parsing;
19
+ # UnknownEvent for
20
+ # unknown events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:Cancel)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # ChargeHandler is responsible for verifying request signatures
8
+ # and parsing incoming charge events into strongly typed objects.
9
+ class ChargeHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the ChargeHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[ChargeWebhookEvent, UnknownEvent]
18
+ # ChargeWebhookEvent for successful parsing;
19
+ # UnknownEvent for unknown
20
+ # events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:Charge)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # CustomsHandler is responsible for verifying request signatures
8
+ # and parsing incoming customs events into strongly typed objects.
9
+ class CustomsHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the CustomsHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[CustomsDeclarationWebhookCallback, UnknownEvent]
18
+ # CustomsDeclarationWebhookCallback for successful parsing;
19
+ #
20
+ # UnknownEvent for unknown events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:Customs)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # RefundHandler is responsible for verifying request signatures
8
+ # and parsing incoming refund events into strongly typed objects.
9
+ class RefundHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the RefundHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[RefundWebhookCallback, UnknownEvent]
18
+ # RefundWebhookCallback for successful parsing;
19
+ # UnknownEvent for
20
+ # unknown events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:Refund)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # SubscriptionHandler is responsible for verifying request signatures
8
+ # and parsing incoming subscription events into strongly typed objects.
9
+ class SubscriptionHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the SubscriptionHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[SubscriptionWebhookEvent, UnknownEvent]
18
+ # SubscriptionWebhookEvent for successful parsing;
19
+ # UnknownEvent for
20
+ # unknown events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:Subscription)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # TokenHandler is responsible for verifying request signatures
8
+ # and parsing incoming token events into strongly typed objects.
9
+ class TokenHandler
10
+ include CoreLibrary
11
+ # Creates a new instance of the TokenHandler.
12
+ def initialize; end
13
+
14
+ # Parse the event.
15
+ #
16
+ # @param [Rack::Request] request The incoming HTTP request containing the event payload.
17
+ # @return[TokenWebhookEvent, UnknownEvent]
18
+ # TokenWebhookEvent for successful parsing;
19
+ # UnknownEvent for unknown
20
+ # events.
21
+ def parse_event(request)
22
+ return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
23
+
24
+ raw_body = RackRequestHelper.read_raw_body(request)
25
+ return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
26
+
27
+ # Deserialize payload
28
+ begin
29
+ union = UnionTypeLookUp.get(:Token)
30
+ raw = RackRequestHelper.read_raw_body(request)
31
+ APIHelper.deserialize_union_type(union, raw, false, true)
32
+ rescue StandardError => e
33
+ UnknownEvent.new(['Deserialization failed.', e.message])
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,199 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module UnivapayClientSdk
7
+ # Standard API error response payload.
8
+ class ApiErrorException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Always returns 'error'.
13
+ # @return [String]
14
+ attr_reader :status
15
+
16
+ # API Request Error Codes.
17
+ # | HTTP | Error Code | Description |
18
+ # | :--- | :--- | :--- |
19
+ # | 400 | ALREADY_CAPTURED | The target charge is already captured or
20
+ # authorization is incomplete. |
21
+ # | 400 | AUTH_NOT_SUPPORTED | The configured gateway does not support
22
+ # authorization. |
23
+ # | 400 | CANCEL_NOT_ALLOWED | This payment method does not support
24
+ # cancellation, or the charge status cannot be canceled. |
25
+ # | 400 | CANNOT_CHANGE_CANCELED_SUBSCRIPTION | A canceled subscription
26
+ # cannot be modified. |
27
+ # | 400 | CANNOT_CHANGE_TOKEN | The transaction token for a subscription in
28
+ # this state cannot be changed. |
29
+ # | 400 | CANNOT_REFUND_UNSUCCESSFUL_CHARGE | Charges in a state other than
30
+ # 'successful' cannot be refunded. |
31
+ # | 400 | CAPTURE_AMOUNT_TOO_LARGE | The capture amount exceeds the
32
+ # authorized amount. |
33
+ # | 400 | CARD_BRAND_NOT_SUPPORTED | The configured gateway does not support
34
+ # the specified card brand. |
35
+ # | 400 | CARD_COUNTRY_NOT_SUPPORTED | The configured gateway does not
36
+ # support the specified card issuing country. |
37
+ # | 400 | CARD_PROCESSING_DISABLED | Card processing is disabled for this
38
+ # payment method. |
39
+ # | 400 | CHARGE_TOO_QUICK | Attempted to create multiple charges with the
40
+ # same amount within 30 seconds for the same card or recurring token. |
41
+ # | 400 | CONVENIENCE_PROCESSING_DISABLED | Konbini processing is disabled
42
+ # for this payment method. |
43
+ # | 400 | CURRENCY_MUST_MATCH_CHARGE | The refund currency must match the
44
+ # original charge currency. |
45
+ # | 400 | CVV_REQUIRED | CVV is required. |
46
+ # | 400 | CVV_AUTHORIZATION_NOT_COMPLETED | CVV authorization failed. |
47
+ # | 400 | FILE_INVALID_TYPE | The uploaded file has an incorrect MIME type.
48
+ # |
49
+ # | 400 | FILE_MAX_SIZE_EXCEEDED | The uploaded file size is too large. |
50
+ # | 400 | FORBIDDEN_IP | The country determined by the request's IP address
51
+ # is not permitted. |
52
+ # | 400 | INSTALLMENT_MAX_PAYOUT_PERIOD_EXCEEDED | The installment payment
53
+ # period exceeds the maximum allowed period. |
54
+ # | 400 | INSTALLMENT_PAYMENT_TYPE_NOT_ALLOWED_FOR_PLAN | The payment method
55
+ # is not allowed for this installment plan. |
56
+ # | 400 | INSTALLMENT_INVALID_CYCLES_COUNT | The number of installment
57
+ # cycles is unavailable. |
58
+ # | 400 | INSTALLMENT_INVALID_PLAN | Unsupported installment plan. |
59
+ # | 400 | INVALID_PLATFORM | Invalid platform specified. |
60
+ # | 400 | INVALID_TOKEN_TYPE | Invalid transaction token type. |
61
+ # | 400 | INVALID_QR_SCAN_GATEWAY | The QR code scanning gateway is not
62
+ # configured or not active. |
63
+ # | 400 | LAST_NAME_REQUIRED | A space-separated last name is required for
64
+ # the cardholder. |
65
+ # | 400 | LIVE_MODE_NOT_ENABLED_WHEN_UNVERIFIED | Account review must be
66
+ # completed to use live mode. |
67
+ # | 400 | NO_DIRECT_CURRENCY_GATEWAY | No gateway available to process the
68
+ # payment without currency conversion. |
69
+ # | 400 | NO_GATEWAYS_AVAILABLE | No available gateways found. |
70
+ # | 400 | NO_TEST_CARD_IN_LIVE_MODE | Test cards cannot be used in live
71
+ # mode. |
72
+ # | 400 | NON_SUBSCRIPTION_PAYMENT | Please specify a one-time token or
73
+ # recurring token to create a charge. |
74
+ # | 400 | NOT_ONE_TIME_TOKEN | Only one-time tokens are supported. |
75
+ # | 400 | NOT_SUBSCRIPTION_TOKEN | Please specify a subscription or
76
+ # recurring token. |
77
+ # | 400 | PARTIAL_CAPTURE_NOT_SUPPORTED | Partial capture is not supported.
78
+ # |
79
+ # | 400 | PAYMENT_EXPIRATION_EXCEEDS_PERIOD | Payment expiration date
80
+ # exceeds the allowed cycle. |
81
+ # | 400 | PROCESSING_MODE_MISMATCH | Application token and transaction token
82
+ # modes do not match (e.g., live vs. test). |
83
+ # | 400 | QR_PROCESSING_DISABLED | QR processing is disabled for this
84
+ # payment method. |
85
+ # | 400 | RECURRING_TOKEN_DISABLED | Transaction token is disabled or the
86
+ # account lacks permission to use recurring tokens. |
87
+ # | 400 | RECURRING_USAGE_LIMIT_REQUIRED | The `usage_limit` parameter is
88
+ # required. |
89
+ # | 400 | RECURRING_USAGE_REQUIRES_CVV | CVV is required for recurring
90
+ # usage. |
91
+ # | 400 | REFUND_EXCEEDS_CHARGE_AMOUNT | The refund amount exceeds the
92
+ # charge amount. |
93
+ # | 400 | REFUND_NOT_ALLOWED | The payment method does not support refunds,
94
+ # or the refund was declined. |
95
+ # | 400 | REFUND_EXCEEDS_SALES | The refund amount exceeds the merchant's
96
+ # available balance limit. |
97
+ # | 400 | REFUND_NOT_WITHIN_BOUNDS | The combined partial refund amounts
98
+ # exceed the total charge amount. |
99
+ # | 400 | RESOURCE_LIMIT_REACHED | Resource limit reached. |
100
+ # | 400 | SUBSCRIPTION_ALREADY_ENDED | The subscription has already ended. |
101
+ # | 400 | TOKEN_FOR_WRONG_STORE | The transaction token's store differs from
102
+ # the subscription's store. |
103
+ # | 400 | TRANSACTION_ALREADY_PROCESSED | Used transaction tokens cannot be
104
+ # specified again. |
105
+ # | 400 | TRANSACTION_TOKEN_EXPIRED | The transaction token has expired. |
106
+ # | 400 | USAGE_LIMIT_NOT_APPLICABLE | `usage_limit` cannot be specified
107
+ # here. |
108
+ # | 400 | VALIDATION_ERROR | There is a validation error in the request
109
+ # parameters. Check `errors` for details. |
110
+ # | 400 | CHARGE_AMOUNT_TOO_HIGH | The charge amount exceeds the maximum
111
+ # allowed limit. |
112
+ # | 400 | NOT_SUPPORTED_BY_PROCESSOR | The gateway does not support this
113
+ # request. |
114
+ # | 401 | AUTH_HEADER_MISSING | The `Authorization` header is missing. |
115
+ # | 401 | EXPIRED_LOGIN_TOKEN | The login token has expired. |
116
+ # | 401 | INVALID_APP_TOKEN | The specified application token is invalid. |
117
+ # | 401 | INVALID_CREDENTIALS | Authentication credentials are invalid. |
118
+ # | 401 | INVALID_DOMAIN | The requested `Origin` domain is not registered
119
+ # for the specified application token. |
120
+ # | 401 | INVALID_LOGIN_TOKEN | The login token is invalid. |
121
+ # | 401 | DIRECT_CARD_TOKEN_CREATION_DISABLED | Cannot send raw card data
122
+ # due to lack of PCI DSS compliance. |
123
+ # | 403 | CARD_LOCKED | This card is temporarily locked due to exceeding the
124
+ # failure threshold within a certain period. |
125
+ # | 403 | INVALID_PERMISSIONS | The application token type is incorrect or
126
+ # the account lacks sufficient permissions. |
127
+ # | 403 | INSTALLMENT_PROCESSOR_INITIAL_AMOUNTS_NOT_SUPPORTED | Initial
128
+ # installment amount specification is not supported by this gateway. |
129
+ # | 403 | OUTDATED_APP_TOKEN | Application token version is outdated. Please
130
+ # create a new one. |
131
+ # | 403 | TEST_CARD_CANNOT_BE_BANNED | Test cards cannot be banned. |
132
+ # | 403 | INSTALLMENTS_NOT_ENABLED | Installment payments are not enabled. |
133
+ # | 409 | IDEMPOTENCY_KEY_CONFLICT | The specified idempotency key has been
134
+ # used previously for a different request. |
135
+ # | 409 | NON_UNIQUE_ACTIVE_TOKEN | An active transaction token already
136
+ # exists. |
137
+ # | 409 | WEBHOOK_URL_EXISTS | The specified Webhook URL is already
138
+ # registered. |
139
+ # | 500 | COULD_NOT_REFRESH_AUTH | Failed to refresh the login token. |
140
+ # | 500 | DB_ERROR | Internal database error. |
141
+ # | 500 | FILE_UPLOAD_ERROR | File upload failed. |
142
+ # | 500 | IMPROPER_AUTH | Authorization state is improper. |
143
+ # | 500 | TIMEOUT | A timeout occurred during internal processing. |
144
+ # | 500 | UNABLE_TO_GET_IDEMPOTENT_RESULT | Cache found for idempotency key,
145
+ # but failed to retrieve the previous processing result. |
146
+ # | 500 | UNKNOWN_ERROR | An unexpected error occurred. |
147
+ # | 503 | SERVICE_UNAVAILABLE_TRY_AGAIN | Service is temporarily
148
+ # unavailable. Please try again later. |
149
+ # | 504 | NO_GATEWAY_AVAILABLE_TO_PROCESS_THE_REQUEST | This request is not
150
+ # supported by the connected gateway system. |
151
+ # @return [String]
152
+ attr_accessor :code
153
+
154
+ # List of detailed API errors.
155
+ # @return [Array[ApiErrorDetail]]
156
+ attr_accessor :errors
157
+
158
+ # The constructor.
159
+ # @param [String] reason The reason for raising an exception.
160
+ # @param [HttpResponse] response The HttpReponse of the API call.
161
+ def initialize(reason, response)
162
+ super(reason, response)
163
+ hash = APIHelper.json_deserialize(@response.raw_body)
164
+ unbox(hash)
165
+ end
166
+
167
+ # Populates this object by extracting properties from a hash.
168
+ # @param [Hash] hash The deserialized response sent by the server in the
169
+ # response body.
170
+ def unbox(hash)
171
+ return nil unless hash
172
+
173
+ @code = hash.key?('code') ? hash['code'] : nil
174
+ # Parameter is an array, so we need to iterate through it
175
+ @errors = nil
176
+ unless hash['errors'].nil?
177
+ @errors = []
178
+ hash['errors'].each do |structure|
179
+ @errors << (ApiErrorDetail.from_hash(structure) if structure)
180
+ end
181
+ end
182
+
183
+ @errors = SKIP unless hash.key?('errors')
184
+ end
185
+
186
+ # Provides a human-readable string representation of the object.
187
+ def to_s
188
+ class_name = self.class.name.split('::').last
189
+ "<#{class_name} status: #{@status}, code: #{@code}, errors: #{@errors}>"
190
+ end
191
+
192
+ # Provides a debugging-friendly string with detailed object information.
193
+ def inspect
194
+ class_name = self.class.name.split('::').last
195
+ "<#{class_name} status: #{@status.inspect}, code: #{@code.inspect}, errors:"\
196
+ " #{@errors.inspect}>"
197
+ end
198
+ end
199
+ end