adyen-ruby-api-library 6.3.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Makefile +72 -0
  4. data/README.md +20 -18
  5. data/lib/adyen/client.rb +68 -36
  6. data/lib/adyen/services/balanceControlService.rb +28 -0
  7. data/lib/adyen/services/balancePlatform/account_holders_api.rb +63 -0
  8. data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +123 -0
  9. data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +27 -0
  10. data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +27 -0
  11. data/lib/adyen/services/balancePlatform/grant_offers_api.rb +39 -0
  12. data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +51 -0
  13. data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +75 -0
  14. data/lib/adyen/services/balancePlatform/platform_api.rb +39 -0
  15. data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +63 -0
  16. data/lib/adyen/services/balancePlatform.rb +61 -0
  17. data/lib/adyen/services/binLookup.rb +40 -0
  18. data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +39 -0
  19. data/lib/adyen/services/checkout/modifications_api.rb +87 -0
  20. data/lib/adyen/services/checkout/orders_api.rb +51 -0
  21. data/lib/adyen/services/checkout/payment_links_api.rb +51 -0
  22. data/lib/adyen/services/checkout/payments_api.rb +87 -0
  23. data/lib/adyen/services/checkout/recurring_api.rb +39 -0
  24. data/lib/adyen/services/checkout/utility_api.rb +39 -0
  25. data/lib/adyen/services/checkout.rb +38 -211
  26. data/lib/adyen/services/dataProtection.rb +28 -0
  27. data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +63 -0
  28. data/lib/adyen/services/legalEntityManagement/documents_api.rb +63 -0
  29. data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +51 -0
  30. data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +75 -0
  31. data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +63 -0
  32. data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +51 -0
  33. data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +63 -0
  34. data/lib/adyen/services/legalEntityManagement.rb +51 -0
  35. data/lib/adyen/services/management/account_company_level_api.rb +51 -0
  36. data/lib/adyen/services/management/account_merchant_level_api.rb +63 -0
  37. data/lib/adyen/services/management/account_store_level_api.rb +111 -0
  38. data/lib/adyen/services/management/allowed_origins_company_level_api.rb +63 -0
  39. data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +63 -0
  40. data/lib/adyen/services/management/api_credentials_company_level_api.rb +63 -0
  41. data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +63 -0
  42. data/lib/adyen/services/management/api_key_company_level_api.rb +27 -0
  43. data/lib/adyen/services/management/api_key_merchant_level_api.rb +27 -0
  44. data/lib/adyen/services/management/client_key_company_level_api.rb +27 -0
  45. data/lib/adyen/services/management/client_key_merchant_level_api.rb +27 -0
  46. data/lib/adyen/services/management/my_api_credential_api.rb +75 -0
  47. data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +87 -0
  48. data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +75 -0
  49. data/lib/adyen/services/management/terminal_actions_company_level_api.rb +63 -0
  50. data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +27 -0
  51. data/lib/adyen/services/management/terminal_orders_company_level_api.rb +135 -0
  52. data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +135 -0
  53. data/lib/adyen/services/management/terminal_settings_company_level_api.rb +63 -0
  54. data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +63 -0
  55. data/lib/adyen/services/management/terminal_settings_store_level_api.rb +111 -0
  56. data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +63 -0
  57. data/lib/adyen/services/management/terminals_terminal_level_api.rb +27 -0
  58. data/lib/adyen/services/management/users_company_level_api.rb +63 -0
  59. data/lib/adyen/services/management/users_merchant_level_api.rb +63 -0
  60. data/lib/adyen/services/management/webhooks_company_level_api.rb +99 -0
  61. data/lib/adyen/services/management/webhooks_merchant_level_api.rb +99 -0
  62. data/lib/adyen/services/management.rb +151 -0
  63. data/lib/adyen/services/payment.rb +172 -0
  64. data/lib/adyen/services/payout/initialization_api.rb +51 -0
  65. data/lib/adyen/services/payout/instant_payouts_api.rb +27 -0
  66. data/lib/adyen/services/payout/reviewing_api.rb +39 -0
  67. data/lib/adyen/services/payout.rb +31 -0
  68. data/lib/adyen/services/posTerminalManagement.rb +76 -0
  69. data/lib/adyen/services/recurring.rb +81 -13
  70. data/lib/adyen/services/service.rb +2 -2
  71. data/lib/adyen/services/storedValue.rb +88 -0
  72. data/lib/adyen/services/transfers/transactions_api.rb +39 -0
  73. data/lib/adyen/services/transfers/transfers_api.rb +27 -0
  74. data/lib/adyen/services/transfers.rb +26 -0
  75. data/lib/adyen/version.rb +1 -1
  76. data/lib/adyen-ruby-api-library.rb +11 -5
  77. data/spec/account_spec.rb +1 -1
  78. data/spec/balance_control_spec.rb +44 -0
  79. data/spec/balance_platform_spec.rb +123 -0
  80. data/spec/bin_lookup_spec.rb +68 -10
  81. data/spec/checkout_spec.rb +56 -66
  82. data/spec/client_spec.rb +88 -9
  83. data/spec/fund_spec.rb +1 -1
  84. data/spec/hop_spec.rb +1 -1
  85. data/spec/lem_spec.rb +68 -0
  86. data/spec/management_spec.rb +68 -0
  87. data/spec/mocks/requests/BalanceControl/balance_transfer.json +10 -0
  88. data/spec/mocks/requests/BalancePlatform/create_account_holder.json +5 -0
  89. data/spec/mocks/requests/BalancePlatform/update_account_holder.json +10 -0
  90. data/spec/mocks/requests/LegalEntityManagement/create_business_line.json +15 -0
  91. data/spec/mocks/requests/Management/create_store.json +15 -0
  92. data/spec/mocks/requests/Recurring/create_permit.json +6 -0
  93. data/spec/mocks/requests/StoredValue/issue_giftcard.json +12 -0
  94. data/spec/mocks/requests/Transfers/get_transactions.json +82 -0
  95. data/spec/mocks/requests/Transfers/make_transfer.json +32 -0
  96. data/spec/mocks/responses/BalanceControl/balance_transfer.json +14 -0
  97. data/spec/mocks/responses/BalancePlatform/create_account_holder.json +41 -0
  98. data/spec/mocks/responses/BalancePlatform/get_balance_account.json +15 -0
  99. data/spec/mocks/responses/BalancePlatform/update_account_holder.json +16 -0
  100. data/spec/mocks/responses/LegalEntityManagement/create_business_line.json +17 -0
  101. data/spec/mocks/responses/Management/create_store.json +23 -0
  102. data/spec/mocks/responses/Management/get_companies.json +42 -0
  103. data/spec/mocks/responses/Recurring/create_permit.json +4 -0
  104. data/spec/mocks/responses/StoredValue/issue_giftcard.json +13 -0
  105. data/spec/mocks/responses/Transfers/get_transactions.json +82 -0
  106. data/spec/mocks/responses/Transfers/make_transfer.json +36 -0
  107. data/spec/notification_spec.rb +1 -1
  108. data/spec/payments_spec.rb +41 -23
  109. data/spec/payouts_spec.rb +43 -16
  110. data/spec/pos_terminal_management_spec.rb +46 -0
  111. data/spec/recurring_spec.rb +2 -2
  112. data/spec/spec_helper.rb +0 -10
  113. data/spec/stored_value_spec.rb +43 -0
  114. data/spec/transfers_spec.rb +63 -0
  115. data/templates/api-single.mustache +29 -0
  116. data/templates/api-small.mustache +37 -0
  117. data/templates/api.mustache +36 -0
  118. data/templates/config.yaml +10 -0
  119. metadata +101 -11
  120. data/lib/adyen/services/bin_lookup.rb +0 -18
  121. data/lib/adyen/services/data_protection.rb +0 -17
  122. data/lib/adyen/services/payments.rb +0 -34
  123. data/lib/adyen/services/payouts.rb +0 -22
  124. data/lib/adyen/services/postfmapi.rb +0 -19
  125. data/spec/mocks/requests/Recurring/store_token.json +0 -15
  126. data/spec/mocks/responses/Recurring/store_token.json +0 -7
  127. data/spec/postfmapi_spec.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45627b45fc5df26d004c1a86d7640412d615383ccac35201f24f0e3ebed99394
4
- data.tar.gz: 72a067ba4b95419ed87e526a371db2377d5b1af7056f9ac035a6e11327715da0
3
+ metadata.gz: c19d03c4d3dce36a0ad9b33ed6a5d0231b44a875314ed93da684c956f08adee1
4
+ data.tar.gz: 7dfddb2b1a02025f841a22041692c7e96f64ee243b6edd55fd0bde233b36c219
5
5
  SHA512:
6
- metadata.gz: a893d921b3236805bb89b6ca5fc1c553888d010c84c1927689f6bc47e1a78b23302c081edbc979d596ac70c0b6f23cad61b9a83cc11c6f8b22e1d73520951bdb
7
- data.tar.gz: 3cc14ff3d1550ffb11f6ec08c37ae7858b5e39e1b14023e6323e3a132441b59ee383e39ca6db6dcb83eff24e4b9ae937bff416bc9684e1ba6cb8ba7b20e37405
6
+ metadata.gz: a9c68c262addccf25287f2b466458053a8f5bf7b91a1e5aea20e51cb1ff18e8521e22fc52db805b7a509becd45d012c7eb93e5554dbba7722c02d321c55d1afb
7
+ data.tar.gz: '0980d9b00a6b387dacd4dade732e7cd8951e93bf545f2344aaf0c6bfb93c4b9685649fba3fd755bd2a30007ff90104d9397d553af75eace3c43262383d5f2247'
data/.gitignore CHANGED
@@ -15,3 +15,6 @@ design.txt
15
15
  .DS_Store
16
16
 
17
17
  .idea
18
+ main.rb
19
+ build/
20
+ openapi-generator-cli-6.0.1.jar
data/Makefile ADDED
@@ -0,0 +1,72 @@
1
+ generator:=ruby
2
+ openapi-generator-version:=6.4.0
3
+ openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
4
+ openapi-generator-jar:=build/openapi-generator-cli.jar
5
+ openapi-generator-cli:=java -jar build/openapi-generator-cli.jar
6
+ output:=build/out
7
+
8
+ services:=balancePlatform checkout legalEntityManagement management payout platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration transfers
9
+ singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue posTerminalManagement payment
10
+
11
+ binLookup: spec=BinLookupService-v54
12
+ checkout: spec=CheckoutService-v70
13
+ dataProtection: spec=DataProtectionService-v1
14
+ storedValue: spec=StoredValueService-v46
15
+ posTerminalManagement: spec=TfmAPIService-v1
16
+ payment: spec=PaymentService-v68
17
+ recurring: spec=RecurringService-v68
18
+ payout: spec=PayoutService-v68
19
+ management: spec=ManagementService-v1
20
+ legalEntityManagement: spec=LegalEntityService-v3
21
+ balancePlatform: spec=BalancePlatformService-v2
22
+ platformsAccount: spec=AccountService-v6
23
+ platformsFund: spec=FundService-v6
24
+ platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
25
+ platformsHostedOnboardingPage: spec=HopService-v6
26
+ transfers: spec=TransferService-v3
27
+ balanceControlService: spec=BalanceControlService-v1
28
+
29
+ allServices: $(services) $(singleFileServices)
30
+
31
+ $(services): build/spec $(openapi-generator-jar)
32
+ wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
33
+ rm -rf $(output)
34
+ $(openapi-generator-cli) generate \
35
+ -i build/spec/json/$(spec).json \
36
+ -g $(generator) \
37
+ -c ./templates/config.yaml \
38
+ -o $(output) \
39
+ --global-property apis,apiTests=false,apiDocs=false,supportingFiles=api-single.rb\
40
+ --additional-properties serviceName=$@\
41
+ --skip-validate-spec
42
+ rm -f $(output)/lib/openapi_client/api/*-small.rb
43
+ mkdir -p lib/adyen/services/$@
44
+ mv $(output)/lib/openapi_client/api/*.rb lib/adyen/services/$@
45
+ mv $(output)/api/api-single.rb lib/adyen/services/$@.rb
46
+ rm -rf $(output)
47
+
48
+ $(singleFileServices): build/spec
49
+ wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
50
+ cat <<< "$$(jq 'del(.paths[][].tags)' build/spec/json/$(spec).json)" > build/spec/json/$(spec).json
51
+ rm -rf $(output)
52
+ $(openapi-generator-cli) generate \
53
+ -i build/spec/json/$(spec).json \
54
+ -g $(generator) \
55
+ -c ./templates/config.yaml \
56
+ -o $(output) \
57
+ --global-property apis,apiTests=false,apiDocs=false\
58
+ --additional-properties serviceName=$@\
59
+ --skip-validate-spec
60
+ mv $(output)/lib/openapi_client/api/default_api-small.rb lib/adyen/services/$@.rb
61
+ rm -rf $(output)
62
+
63
+ templates: $(openapi-generator-jar)
64
+ $(openapi-generator-cli) author template -g $(generator) -o build/templates
65
+
66
+ # Download the generator
67
+ $(openapi-generator-jar):
68
+ wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)
69
+
70
+ build/spec:
71
+ git clone https://github.com/Adyen/adyen-openapi.git build/spec
72
+ perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
data/README.md CHANGED
@@ -1,24 +1,26 @@
1
+ ![Ruby](https://user-images.githubusercontent.com/93914435/236416787-3da4dd32-0a7d-43f7-9aa4-8d77697c85f9.png)
1
2
  # Adyen API Library for Ruby
2
3
 
3
-
4
4
  This is the officially supported Ruby library for using Adyen's APIs.
5
5
 
6
- ## Integration
7
- The library supports all APIs under the following services:
8
-
9
- * [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v68/overview): Our latest integration for accepting online payments. Current supported version: **v68**
10
- * [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
11
- * [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
12
- * [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
13
- * [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms.
14
- * [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**
15
- * [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6**
16
- * [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6**
17
- * [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Current supported version: **v1**
18
- * [Adyen BinLookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview): Current supported version: **v50**
19
- * [Data Protection API](https://docs.adyen.com/development-resources/data-protection-api): Current supported version: **v1**
20
- * [Disputes API](https://docs.adyen.com/risk-management/disputes-api): Current supported version: **v50**
21
-
6
+ ## Supported APIs
7
+
8
+ This library supports the following:
9
+
10
+ | API name | API version | Description | API object |
11
+ |----------|:-----------:|-------------|------------|
12
+ | [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview) | v54 | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | [BinLookup](lib/adyen/services/binLookup.rb) |
13
+ | [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview) | v70 | Our latest integration for accepting online payments. | [CheckoutAPI](lib/adyen/services/checkout.rb) |
14
+ | [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview) | v2 | The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | [BalancePlatform](lib/adyen/services/balancePlatform.rb) |
15
+ | [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | v1 | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | [DataProtection](lib/adyen/services/dataProtection.rb) |
16
+ | [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](lib/adyen/services/legalEntityManagement.rb) |
17
+ | [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview) | v1 | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | [Management](lib/adyen/services/management.rb) |
18
+ | [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview) | v68 | Our classic integration for online payments. | [Classic Integration API](lib/adyen/services/payment.rb) |
19
+ | [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](lib/adyen/services/payout.rb) |
20
+ | [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview) | v1 | Endpoints for managing your point-of-sale payment terminals. | [TerminalManagement](lib/adyen/services/posTerminalManagement.rb) |
21
+ | [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
22
+ | [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | v46 | Manage both online and point-of-sale gift cards and other stored-value cards. | [StoredValue](lib/adyen/services/storedValue.rb) |
23
+ | [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | v3 | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | [Transfers](lib/adyen/services/transfers.rb) |
22
24
 
23
25
  For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
24
26
 
@@ -64,7 +66,7 @@ adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
64
66
 
65
67
  - Make a Payment
66
68
  ~~~~ruby
67
- response = adyen.checkout.payments({
69
+ response = adyen.checkout.payments_api.payments({
68
70
  :amount => {
69
71
  :currency => "EUR",
70
72
  :value => 1000
data/lib/adyen/client.rb CHANGED
@@ -35,30 +35,43 @@ module Adyen
35
35
 
36
36
  # base URL for API given service and @env
37
37
  def service_url_base(service)
38
- raise ArgumentError, "Please set Client.live_url_prefix to the portion of your merchant-specific URL prior to '-[service]-live.adyenpayments.com'" if @live_url_prefix.nil? and @env == :live
39
38
  if @env == :mock
40
39
  @mock_service_url_base
41
40
  else
42
41
  case service
43
42
  when "Checkout"
44
- url = "https://checkout-#{@env}.adyen.com/checkout"
43
+ url = "https://checkout-#{@env}.adyen.com"
45
44
  supports_live_url_prefix = true
46
45
  when "Account", "Fund", "Notification", "Hop"
47
- url = "https://cal-#{@env}.adyen.com/cal/services"
46
+ url = "https://cal-#{@env}.adyen.com/cal/services/#{service}"
48
47
  supports_live_url_prefix = false
49
- when "Recurring", "Payment", "Payout", "BinLookup"
50
- url = "https://pal-#{@env}.adyen.com/pal/servlet"
48
+ when "Recurring", "Payment", "Payout", "BinLookup", "StoredValue", "BalanceControlService"
49
+ url = "https://pal-#{@env}.adyen.com/pal/servlet/#{service}"
51
50
  supports_live_url_prefix = true
52
- when "Terminal"
51
+ when "PosTerminalManagement"
53
52
  url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
54
53
  supports_live_url_prefix = false
55
54
  when "DataProtectionService", "DisputeService"
56
- url = "https://ca-#{@env}.adyen.com/ca/services"
55
+ url = "https://ca-#{@env}.adyen.com/ca/services/#{service}"
56
+ supports_live_url_prefix = false
57
+ when "LegalEntityManagement"
58
+ url = "https://kyc-#{@env}.adyen.com/lem"
59
+ supports_live_url_prefix = false
60
+ when "BalancePlatform"
61
+ url = "https://balanceplatform-api-#{@env}.adyen.com/bcl"
62
+ supports_live_url_prefix = false
63
+ when "Transfers"
64
+ url = "https://balanceplatform-api-#{@env}.adyen.com/btl"
65
+ supports_live_url_prefix = false
66
+ when "Management"
67
+ url = "https://management-#{@env}.adyen.com"
57
68
  supports_live_url_prefix = false
58
69
  else
59
70
  raise ArgumentError, "Invalid service specified"
60
71
  end
61
-
72
+
73
+ raise ArgumentError, "Please set Client.live_url_prefix to the portion of your merchant-specific URL prior to '-[service]-live.adyenpayments.com'" \
74
+ if @live_url_prefix.nil? and @env == :live and supports_live_url_prefix
62
75
  if @env == :live && supports_live_url_prefix
63
76
  url.insert(8, "#{@live_url_prefix}-")
64
77
  url["adyen.com"] = "adyenpayments.com"
@@ -70,10 +83,10 @@ module Adyen
70
83
 
71
84
  # construct full URL from service and endpoint
72
85
  def service_url(service, action, version)
73
- if service == "Checkout" || service == "Terminal"
74
- "#{service_url_base(service)}/v#{version}/#{action}"
86
+ if service == "Checkout" && @env == :live
87
+ return "#{service_url_base(service)}/checkout/v#{version}/#{action}"
75
88
  else
76
- "#{service_url_base(service)}/#{service}/v#{version}/#{action}"
89
+ return "#{service_url_base(service)}/v#{version}/#{action}"
77
90
  end
78
91
  end
79
92
 
@@ -121,6 +134,10 @@ module Adyen
121
134
  headers.map do |key, value|
122
135
  faraday.headers[key] = value
123
136
  end
137
+
138
+ # add library headers
139
+ faraday.headers["adyen-library-name"] = Adyen::NAME
140
+ faraday.headers["adyen-library-version"] = Adyen::VERSION
124
141
  end
125
142
  # if json string convert to hash
126
143
  # needed to add applicationInfo
@@ -128,10 +145,6 @@ module Adyen
128
145
  request_data = JSON.parse(request_data)
129
146
  end
130
147
 
131
- # add application only on checkout service
132
- if with_application_info
133
- add_application_info(request_data)
134
- end
135
148
 
136
149
  # convert to json
137
150
  request_data = request_data.to_json
@@ -160,7 +173,7 @@ module Adyen
160
173
  raise connection_error, "Connection to #{url} failed"
161
174
  end
162
175
  end
163
- else
176
+ if action.fetch(:method) == 'post'
164
177
  # post request to Adyen
165
178
  begin
166
179
  response = conn.post do |req|
@@ -169,8 +182,16 @@ module Adyen
169
182
  rescue Faraday::ConnectionFailed => connection_error
170
183
  raise connection_error, "Connection to #{url} failed"
171
184
  end
185
+ end
186
+ else
187
+ begin
188
+ response = conn.post do |req|
189
+ req.body = request_data
190
+ end # handle client errors
191
+ rescue Faraday::ConnectionFailed => connection_error
192
+ raise connection_error, "Connection to #{url} failed"
193
+ end
172
194
  end
173
-
174
195
  # check for API errors
175
196
  case response.status
176
197
  when 401
@@ -189,31 +210,18 @@ module Adyen
189
210
  formatted_response
190
211
  end
191
212
 
192
- # add application_info for analytics
193
- def add_application_info(request_data)
194
- adyenLibrary = {
195
- :name => Adyen::NAME,
196
- :version => Adyen::VERSION.to_s,
197
- }
198
-
199
- if request_data[:applicationInfo].nil?
200
- request_data[:applicationInfo] = {}
201
- end
202
-
203
- request_data[:applicationInfo][:adyenLibrary] = adyenLibrary
204
- end
205
213
 
206
214
  # services
207
215
  def checkout
208
216
  @checkout ||= Adyen::Checkout.new(self)
209
217
  end
210
218
 
211
- def payments
212
- @payments ||= Adyen::Payments.new(self)
219
+ def payment
220
+ @payment ||= Adyen::Payment.new(self)
213
221
  end
214
222
 
215
- def payouts
216
- @payouts ||= Adyen::Payouts.new(self)
223
+ def payout
224
+ @payout ||= Adyen::Payout.new(self)
217
225
  end
218
226
 
219
227
  def recurring
@@ -224,8 +232,8 @@ module Adyen
224
232
  @marketpay ||= Adyen::Marketpay::Marketpay.new(self)
225
233
  end
226
234
 
227
- def postfmapi
228
- @postfmapi ||= Adyen::PosTerminalManagement.new(self)
235
+ def pos_terminal_management
236
+ @pos_terminal_management ||= Adyen::PosTerminalManagement.new(self)
229
237
  end
230
238
 
231
239
  def data_protection
@@ -239,5 +247,29 @@ module Adyen
239
247
  def bin_lookup
240
248
  @bin_lookup ||= Adyen::BinLookup.new(self)
241
249
  end
250
+
251
+ def legal_entity_management
252
+ @legal_entity_management ||= Adyen::LegalEntityManagement.new(self)
253
+ end
254
+
255
+ def balance_platform
256
+ @balance_platform ||= Adyen::BalancePlatform.new(self)
257
+ end
258
+
259
+ def transfers
260
+ @transfers ||= Adyen::Transfers.new(self)
261
+ end
262
+
263
+ def management
264
+ @management ||= Adyen::Management.new(self)
265
+ end
266
+
267
+ def stored_value
268
+ @stored_value ||=Adyen::StoredValue.new(self)
269
+ end
270
+
271
+ def balance_control_service
272
+ @balance_control_service ||=Adyen::BalanceControlService.new(self)
273
+ end
242
274
  end
243
275
  end
@@ -0,0 +1,28 @@
1
+ require_relative './service'
2
+ module Adyen
3
+
4
+
5
+ class BalanceControlService < Service
6
+ attr_accessor :service, :version
7
+ DEFAULT_VERSION = 1
8
+
9
+ def initialize(client, version = DEFAULT_VERSION)
10
+ @service = "BalanceControlService"
11
+ @client = client
12
+ @version = version
13
+ end
14
+
15
+ def balance_transfer(request, headers: {} )
16
+ """
17
+ Start a balance transfer
18
+ """
19
+ endpoint = "/balanceTransfer".gsub(/{.+?}/, '%s')
20
+ endpoint = endpoint.gsub(/^\//, "")
21
+ endpoint = endpoint % []
22
+
23
+ action = { method: "post", url: endpoint}
24
+ @client.call_adyen_api(@service, action, request, headers, @version)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+
4
+
5
+ class AccountHoldersApi < Service
6
+ attr_accessor :service, :version
7
+
8
+ def initialize(client, version = DEFAULT_VERSION)
9
+ @service = "BalancePlatform"
10
+ @client = client
11
+ @version = version
12
+ end
13
+
14
+ def get_account_holder(id, headers: {} )
15
+ """
16
+ Get an account holder
17
+ """
18
+ endpoint = "/accountHolders/{id}".gsub(/{.+?}/, '%s')
19
+ endpoint = endpoint.gsub(/^\//, "")
20
+ endpoint = endpoint % [id]
21
+
22
+ action = { method: "get", url: endpoint}
23
+ @client.call_adyen_api(@service, action, {}, headers, @version)
24
+ end
25
+
26
+ def get_all_balance_accounts_of_account_holder(id, headers: {} , queryParams: {})
27
+ """
28
+ Get all balance accounts of an account holder
29
+ """
30
+ endpoint = "/accountHolders/{id}/balanceAccounts".gsub(/{.+?}/, '%s')
31
+ endpoint = endpoint.gsub(/^\//, "")
32
+ endpoint = endpoint % [id]
33
+ endpoint = endpoint + create_query_string(queryParams)
34
+ action = { method: "get", url: endpoint}
35
+ @client.call_adyen_api(@service, action, {}, headers, @version)
36
+ end
37
+
38
+ def update_account_holder(request, id, headers: {} )
39
+ """
40
+ Update an account holder
41
+ """
42
+ endpoint = "/accountHolders/{id}".gsub(/{.+?}/, '%s')
43
+ endpoint = endpoint.gsub(/^\//, "")
44
+ endpoint = endpoint % [id]
45
+
46
+ action = { method: "patch", url: endpoint}
47
+ @client.call_adyen_api(@service, action, request, headers, @version)
48
+ end
49
+
50
+ def create_account_holder(request, headers: {} )
51
+ """
52
+ Create an account holder
53
+ """
54
+ endpoint = "/accountHolders".gsub(/{.+?}/, '%s')
55
+ endpoint = endpoint.gsub(/^\//, "")
56
+ endpoint = endpoint % []
57
+
58
+ action = { method: "post", url: endpoint}
59
+ @client.call_adyen_api(@service, action, request, headers, @version)
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,123 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+
4
+
5
+ class BalanceAccountsApi < Service
6
+ attr_accessor :service, :version
7
+
8
+ def initialize(client, version = DEFAULT_VERSION)
9
+ @service = "BalancePlatform"
10
+ @client = client
11
+ @version = version
12
+ end
13
+
14
+ def delete_sweep(balanceAccountId, sweepId, headers: {} )
15
+ """
16
+ Delete a sweep
17
+ """
18
+ endpoint = "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}".gsub(/{.+?}/, '%s')
19
+ endpoint = endpoint.gsub(/^\//, "")
20
+ endpoint = endpoint % [balanceAccountId,sweepId]
21
+
22
+ action = { method: "delete", url: endpoint}
23
+ @client.call_adyen_api(@service, action, {}, headers, @version)
24
+ end
25
+
26
+ def get_all_sweeps_for_balance_account(balanceAccountId, headers: {} , queryParams: {})
27
+ """
28
+ Get all sweeps for a balance account
29
+ """
30
+ endpoint = "/balanceAccounts/{balanceAccountId}/sweeps".gsub(/{.+?}/, '%s')
31
+ endpoint = endpoint.gsub(/^\//, "")
32
+ endpoint = endpoint % [balanceAccountId]
33
+ endpoint = endpoint + create_query_string(queryParams)
34
+ action = { method: "get", url: endpoint}
35
+ @client.call_adyen_api(@service, action, {}, headers, @version)
36
+ end
37
+
38
+ def get_sweep(balanceAccountId, sweepId, headers: {} )
39
+ """
40
+ Get a sweep
41
+ """
42
+ endpoint = "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}".gsub(/{.+?}/, '%s')
43
+ endpoint = endpoint.gsub(/^\//, "")
44
+ endpoint = endpoint % [balanceAccountId,sweepId]
45
+
46
+ action = { method: "get", url: endpoint}
47
+ @client.call_adyen_api(@service, action, {}, headers, @version)
48
+ end
49
+
50
+ def get_balance_account(id, headers: {} )
51
+ """
52
+ Get a balance account
53
+ """
54
+ endpoint = "/balanceAccounts/{id}".gsub(/{.+?}/, '%s')
55
+ endpoint = endpoint.gsub(/^\//, "")
56
+ endpoint = endpoint % [id]
57
+
58
+ action = { method: "get", url: endpoint}
59
+ @client.call_adyen_api(@service, action, {}, headers, @version)
60
+ end
61
+
62
+ def get_all_payment_instruments_for_balance_account(id, headers: {} , queryParams: {})
63
+ """
64
+ Get all payment instruments for a balance account
65
+ """
66
+ endpoint = "/balanceAccounts/{id}/paymentInstruments".gsub(/{.+?}/, '%s')
67
+ endpoint = endpoint.gsub(/^\//, "")
68
+ endpoint = endpoint % [id]
69
+ endpoint = endpoint + create_query_string(queryParams)
70
+ action = { method: "get", url: endpoint}
71
+ @client.call_adyen_api(@service, action, {}, headers, @version)
72
+ end
73
+
74
+ def update_sweep(request, balanceAccountId, sweepId, headers: {} )
75
+ """
76
+ Update a sweep
77
+ """
78
+ endpoint = "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}".gsub(/{.+?}/, '%s')
79
+ endpoint = endpoint.gsub(/^\//, "")
80
+ endpoint = endpoint % [balanceAccountId,sweepId]
81
+
82
+ action = { method: "patch", url: endpoint}
83
+ @client.call_adyen_api(@service, action, request, headers, @version)
84
+ end
85
+
86
+ def update_balance_account(request, id, headers: {} )
87
+ """
88
+ Update a balance account
89
+ """
90
+ endpoint = "/balanceAccounts/{id}".gsub(/{.+?}/, '%s')
91
+ endpoint = endpoint.gsub(/^\//, "")
92
+ endpoint = endpoint % [id]
93
+
94
+ action = { method: "patch", url: endpoint}
95
+ @client.call_adyen_api(@service, action, request, headers, @version)
96
+ end
97
+
98
+ def create_balance_account(request, headers: {} )
99
+ """
100
+ Create a balance account
101
+ """
102
+ endpoint = "/balanceAccounts".gsub(/{.+?}/, '%s')
103
+ endpoint = endpoint.gsub(/^\//, "")
104
+ endpoint = endpoint % []
105
+
106
+ action = { method: "post", url: endpoint}
107
+ @client.call_adyen_api(@service, action, request, headers, @version)
108
+ end
109
+
110
+ def create_sweep(request, balanceAccountId, headers: {} )
111
+ """
112
+ Create a sweep
113
+ """
114
+ endpoint = "/balanceAccounts/{balanceAccountId}/sweeps".gsub(/{.+?}/, '%s')
115
+ endpoint = endpoint.gsub(/^\//, "")
116
+ endpoint = endpoint % [balanceAccountId]
117
+
118
+ action = { method: "post", url: endpoint}
119
+ @client.call_adyen_api(@service, action, request, headers, @version)
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+
4
+
5
+ class BankAccountValidationApi < Service
6
+ attr_accessor :service, :version
7
+
8
+ def initialize(client, version = DEFAULT_VERSION)
9
+ @service = "BalancePlatform"
10
+ @client = client
11
+ @version = version
12
+ end
13
+
14
+ def validate_bank_account_identification(request, headers: {} )
15
+ """
16
+ Validate a bank account
17
+ """
18
+ endpoint = "/validateBankAccountIdentification".gsub(/{.+?}/, '%s')
19
+ endpoint = endpoint.gsub(/^\//, "")
20
+ endpoint = endpoint % []
21
+
22
+ action = { method: "post", url: endpoint}
23
+ @client.call_adyen_api(@service, action, request, headers, @version)
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+
4
+
5
+ class GrantAccountsApi < Service
6
+ attr_accessor :service, :version
7
+
8
+ def initialize(client, version = DEFAULT_VERSION)
9
+ @service = "BalancePlatform"
10
+ @client = client
11
+ @version = version
12
+ end
13
+
14
+ def get_grant_account(id, headers: {} )
15
+ """
16
+ Get a grant account
17
+ """
18
+ endpoint = "/grantAccounts/{id}".gsub(/{.+?}/, '%s')
19
+ endpoint = endpoint.gsub(/^\//, "")
20
+ endpoint = endpoint % [id]
21
+
22
+ action = { method: "get", url: endpoint}
23
+ @client.call_adyen_api(@service, action, {}, headers, @version)
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,39 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+
4
+
5
+ class GrantOffersApi < Service
6
+ attr_accessor :service, :version
7
+
8
+ def initialize(client, version = DEFAULT_VERSION)
9
+ @service = "BalancePlatform"
10
+ @client = client
11
+ @version = version
12
+ end
13
+
14
+ def get_all_available_grant_offers(headers: {} , queryParams: {})
15
+ """
16
+ Get all available grant offers
17
+ """
18
+ endpoint = "/grantOffers".gsub(/{.+?}/, '%s')
19
+ endpoint = endpoint.gsub(/^\//, "")
20
+ endpoint = endpoint % []
21
+ endpoint = endpoint + create_query_string(queryParams)
22
+ action = { method: "get", url: endpoint}
23
+ @client.call_adyen_api(@service, action, {}, headers, @version)
24
+ end
25
+
26
+ def get_grant_offer(grantOfferId, headers: {} )
27
+ """
28
+ Get a grant offer
29
+ """
30
+ endpoint = "/grantOffers/{grantOfferId}".gsub(/{.+?}/, '%s')
31
+ endpoint = endpoint.gsub(/^\//, "")
32
+ endpoint = endpoint % [grantOfferId]
33
+
34
+ action = { method: "get", url: endpoint}
35
+ @client.call_adyen_api(@service, action, {}, headers, @version)
36
+ end
37
+
38
+ end
39
+ end