adyen-ruby-api-library 11.1.0 → 11.3.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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/workflows/codeql.yml +4 -4
  4. data/.github/workflows/label_new_issues.yml +1 -1
  5. data/.github/workflows/release.yml +2 -2
  6. data/.github/workflows/ruby.yml +11 -3
  7. data/.github/workflows/rubygems_release.yml +2 -2
  8. data/.github/workflows/stale.yml +1 -1
  9. data/AGENTS.md +73 -0
  10. data/README.md +3 -0
  11. data/VERSION +1 -1
  12. data/lib/adyen/client.rb +18 -8
  13. data/lib/adyen/services/balanceControl/balance_control_api.rb +1 -3
  14. data/lib/adyen/services/balancePlatform/account_holders_api.rb +14 -18
  15. data/lib/adyen/services/balancePlatform/authorized_card_users_api.rb +4 -12
  16. data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +10 -30
  17. data/lib/adyen/services/balancePlatform/balances_api.rb +5 -15
  18. data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +1 -3
  19. data/lib/adyen/services/balancePlatform/card_orders_api.rb +2 -6
  20. data/lib/adyen/services/balancePlatform/direct_debit_mandates_api.rb +48 -0
  21. data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +1 -3
  22. data/lib/adyen/services/balancePlatform/grant_offers_api.rb +2 -6
  23. data/lib/adyen/services/balancePlatform/manage_card_pin_api.rb +3 -9
  24. data/lib/adyen/services/balancePlatform/manage_sca_devices_api.rb +6 -18
  25. data/lib/adyen/services/balancePlatform/network_tokens_api.rb +2 -6
  26. data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +3 -9
  27. data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +9 -27
  28. data/lib/adyen/services/balancePlatform/platform_api.rb +3 -9
  29. data/lib/adyen/services/balancePlatform/sca_association_management_api.rb +40 -0
  30. data/lib/adyen/services/balancePlatform/sca_device_management_api.rb +40 -0
  31. data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +4 -12
  32. data/lib/adyen/services/balancePlatform/transfer_limits_balance_account_level_api.rb +6 -18
  33. data/lib/adyen/services/balancePlatform/transfer_limits_balance_platform_level_api.rb +4 -12
  34. data/lib/adyen/services/balancePlatform/transfer_routes_api.rb +1 -3
  35. data/lib/adyen/services/balancePlatform.rb +15 -0
  36. data/lib/adyen/services/binLookup/bin_lookup_api.rb +2 -6
  37. data/lib/adyen/services/capital/dynamic_offers_api.rb +40 -0
  38. data/lib/adyen/services/capital/grant_accounts_api.rb +24 -0
  39. data/lib/adyen/services/capital/grant_offers_api.rb +32 -0
  40. data/lib/adyen/services/capital/grants_api.rb +64 -0
  41. data/lib/adyen/services/capital.rb +39 -0
  42. data/lib/adyen/services/checkout/donations_api.rb +2 -6
  43. data/lib/adyen/services/checkout/modifications_api.rb +6 -18
  44. data/lib/adyen/services/checkout/orders_api.rb +3 -9
  45. data/lib/adyen/services/checkout/payment_links_api.rb +3 -9
  46. data/lib/adyen/services/checkout/payments_api.rb +6 -18
  47. data/lib/adyen/services/checkout/recurring_api.rb +11 -9
  48. data/lib/adyen/services/checkout/utility_api.rb +4 -12
  49. data/lib/adyen/services/dataProtection/data_protection_api.rb +1 -3
  50. data/lib/adyen/services/disputes/disputes_api.rb +5 -15
  51. data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +4 -12
  52. data/lib/adyen/services/legalEntityManagement/documents_api.rb +4 -12
  53. data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +3 -9
  54. data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +7 -21
  55. data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +5 -15
  56. data/lib/adyen/services/legalEntityManagement/tax_e_delivery_consent_api.rb +2 -6
  57. data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +5 -15
  58. data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +4 -12
  59. data/lib/adyen/services/management/account_company_level_api.rb +3 -9
  60. data/lib/adyen/services/management/account_merchant_level_api.rb +4 -12
  61. data/lib/adyen/services/management/account_store_level_api.rb +8 -24
  62. data/lib/adyen/services/management/allowed_origins_company_level_api.rb +4 -12
  63. data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +4 -12
  64. data/lib/adyen/services/management/android_files_company_level_api.rb +6 -18
  65. data/lib/adyen/services/management/api_credentials_company_level_api.rb +4 -12
  66. data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +4 -12
  67. data/lib/adyen/services/management/api_key_company_level_api.rb +1 -3
  68. data/lib/adyen/services/management/api_key_merchant_level_api.rb +1 -3
  69. data/lib/adyen/services/management/client_key_company_level_api.rb +1 -3
  70. data/lib/adyen/services/management/client_key_merchant_level_api.rb +1 -3
  71. data/lib/adyen/services/management/my_api_credential_api.rb +6 -18
  72. data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +6 -18
  73. data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +5 -15
  74. data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +9 -27
  75. data/lib/adyen/services/management/terminal_actions_company_level_api.rb +2 -6
  76. data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +1 -3
  77. data/lib/adyen/services/management/terminal_orders_company_level_api.rb +10 -30
  78. data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +10 -30
  79. data/lib/adyen/services/management/terminal_settings_company_level_api.rb +4 -12
  80. data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +4 -12
  81. data/lib/adyen/services/management/terminal_settings_store_level_api.rb +8 -24
  82. data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +4 -12
  83. data/lib/adyen/services/management/terminals_terminal_level_api.rb +2 -6
  84. data/lib/adyen/services/management/users_company_level_api.rb +4 -12
  85. data/lib/adyen/services/management/users_merchant_level_api.rb +4 -12
  86. data/lib/adyen/services/management/webhooks_company_level_api.rb +7 -21
  87. data/lib/adyen/services/management/webhooks_merchant_level_api.rb +7 -21
  88. data/lib/adyen/services/payment/modifications_api.rb +8 -24
  89. data/lib/adyen/services/payment/payments_api.rb +5 -15
  90. data/lib/adyen/services/paymentsApp/payments_app_api.rb +5 -15
  91. data/lib/adyen/services/payout/initialization_api.rb +3 -9
  92. data/lib/adyen/services/payout/instant_payouts_api.rb +1 -3
  93. data/lib/adyen/services/payout/reviewing_api.rb +2 -6
  94. data/lib/adyen/services/posMobile/pos_mobile_api.rb +1 -3
  95. data/lib/adyen/services/recurring/recurring_api.rb +7 -19
  96. data/lib/adyen/services/recurring.rb +1 -1
  97. data/lib/adyen/services/service.rb +10 -2
  98. data/lib/adyen/services/sessionAuthentication/session_authentication_api.rb +1 -3
  99. data/lib/adyen/services/storedValue/stored_value_api.rb +6 -18
  100. data/lib/adyen/services/transfers/capital_api.rb +3 -9
  101. data/lib/adyen/services/transfers/transactions_api.rb +2 -6
  102. data/lib/adyen/services/transfers/transfers_api.rb +6 -18
  103. data/lib/adyen/utils/hmac_validator.rb +0 -1
  104. data/lib/adyen/version.rb +1 -1
  105. data/lib/adyen-ruby-api-library.rb +1 -0
  106. data/sdk-generation-log/balancecontrol.json +8 -0
  107. data/sdk-generation-log/balanceplatform.json +8 -0
  108. data/sdk-generation-log/binlookup.json +8 -0
  109. data/sdk-generation-log/capital.json +8 -0
  110. data/sdk-generation-log/checkout.json +8 -0
  111. data/sdk-generation-log/dataprotection.json +8 -0
  112. data/sdk-generation-log/disputes.json +8 -0
  113. data/sdk-generation-log/legalentitymanagement.json +8 -0
  114. data/sdk-generation-log/management.json +8 -0
  115. data/sdk-generation-log/payment.json +8 -0
  116. data/sdk-generation-log/paymentsapp.json +8 -0
  117. data/sdk-generation-log/payout.json +8 -0
  118. data/sdk-generation-log/posmobile.json +8 -0
  119. data/sdk-generation-log/recurring.json +8 -0
  120. data/sdk-generation-log/sessionauthentication.json +8 -0
  121. data/sdk-generation-log/storedvalue.json +8 -0
  122. data/sdk-generation-log/transfers.json +8 -0
  123. data/spec/balance_platform_spec.rb +111 -0
  124. data/spec/capital_spec.rb +268 -0
  125. data/spec/client_spec.rb +206 -68
  126. data/spec/mocks/requests/BalancePlatform/update_mandate.json +14 -0
  127. data/spec/mocks/responses/BalancePlatform/get_list_of_mandates.json +19 -0
  128. data/spec/mocks/responses/BalancePlatform/get_mandate_by_id.json +14 -0
  129. data/spec/mocks/responses/BalancePlatform/get_tax_form_summary.json +17 -0
  130. data/spec/mocks/responses/Capital/calculate-preliminary-offer-from-dynamic-offer.json +16 -0
  131. data/spec/mocks/responses/Capital/create-static-offer-from-dynamic-offer.json +9 -0
  132. data/spec/mocks/responses/Capital/get-all-dynamic-offers.json +18 -0
  133. data/spec/mocks/responses/Capital/get-grant-account-success.json +20 -0
  134. data/spec/mocks/responses/Capital/get-grant-disbursement-success.json +26 -0
  135. data/spec/mocks/responses/Capital/get-grant-disbursements-success.json +30 -0
  136. data/spec/mocks/responses/Capital/get-grant-offer-success.json +31 -0
  137. data/spec/mocks/responses/Capital/get-grant-success.json +22 -0
  138. data/spec/mocks/responses/Capital/grant-offers-success.json +19 -0
  139. data/spec/mocks/responses/Capital/grants-success.json +26 -0
  140. data/spec/mocks/responses/Capital/request-grant.json +31 -0
  141. data/spec/mocks/responses/Capital/update-grant-disbursement-success.json +26 -0
  142. data/spec/service_spec.rb +40 -0
  143. data/templates/api-small.mustache +1 -3
  144. data/templates/api.mustache +1 -3
  145. metadata +44 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92b51bd749bf2197660b344467eb810e18fc85c595313444b25b0b1c6e5efd4e
4
- data.tar.gz: fe1566a9a57a0be999ca83dc1704893050f13756f07529526fa457aa270bec6c
3
+ metadata.gz: 10f1c74499bd2f3448b7e4dbf1705bcb4def1719a63f4e23390eca41ff7adcfd
4
+ data.tar.gz: eb5f39decf49d935ad0b949be13684754af64da9cabaf1f08f98bdd3560188de
5
5
  SHA512:
6
- metadata.gz: acf09d5e10e31179b243638b37e9c5528193fad0b3bb0fcb6d667f8a75a045a79efeb8dec96338bbec1bc3f13efd608c9c4c231325c76123a98afb342155c830
7
- data.tar.gz: e5e9e834d79ef4a52e8ecb5d863394dbdce70050f3f0e72577fa0cfdc39b1475bf984adbb1a02ef4d0376f3cd2aeb99ef976922e02e2c31b3ce207fe82c5cde3
6
+ metadata.gz: 5bba85b9828d293d97c44eceecfae49755d34496977755b40be3d0569840c093010dd1916203ecafb5adf2e19be578dc89cf6484195568f6e70b4296876975b9
7
+ data.tar.gz: f1285563c2abeaf38e4aa8260cba67250a992b30508cfc226eeb627d05a1fc0bafecf04f131d7ca84d20b6b8533f8bf768d8d0a1c9f6d3f38e0ab75800a70900
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @Adyen/developer-relations @Adyen/api-library-maintainers
1
+ * @Adyen/api-library-maintainers
@@ -20,18 +20,18 @@ jobs:
20
20
 
21
21
  steps:
22
22
  - name: Checkout
23
- uses: actions/checkout@v5
23
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24
24
 
25
25
  - name: Initialize CodeQL
26
- uses: github/codeql-action/init@v3
26
+ uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4
27
27
  with:
28
28
  languages: ${{ matrix.language }}
29
29
  queries: +security-and-quality
30
30
 
31
31
  - name: Autobuild
32
- uses: github/codeql-action/autobuild@v3
32
+ uses: github/codeql-action/autobuild@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4
33
33
 
34
34
  - name: Perform CodeQL Analysis
35
- uses: github/codeql-action/analyze@v3
35
+ uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4
36
36
  with:
37
37
  category: "/language:${{ matrix.language }}"
@@ -8,7 +8,7 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
10
  - name: Add 'needs response' label to new issues
11
- uses: actions-ecosystem/action-add-labels@v1
11
+ uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1
12
12
  with:
13
13
  github_token: ${{ secrets.GITHUB_TOKEN }}
14
14
  labels: 'needs response'
@@ -28,9 +28,9 @@ jobs:
28
28
  pull-requests: write
29
29
  runs-on: ubuntu-latest
30
30
  steps:
31
- - uses: actions/checkout@v5
31
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
32
32
  - name: Prepare the next main release
33
- uses: Adyen/release-automation-action@v1.4.0
33
+ uses: Adyen/release-automation-action@3e5694d5b365f344a62436e84049511ef318ecf5 # v1.4.0
34
34
  with:
35
35
  token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
36
36
  develop-branch: main
@@ -1,6 +1,14 @@
1
1
  name: ruby
2
2
 
3
- on: [push, pull_request]
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ merge_group:
11
+ workflow_dispatch: {}
4
12
 
5
13
  jobs:
6
14
  test:
@@ -12,8 +20,8 @@ jobs:
12
20
  ruby: [2.7, '3.0', 3.1, 3.2, head]
13
21
  runs-on: ${{ matrix.os }}
14
22
  steps:
15
- - uses: actions/checkout@v5
16
- - uses: ruby/setup-ruby@v1
23
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24
+ - uses: ruby/setup-ruby@8a836efbcebe5de0fe86b48a775b7a31b5c70c93 # v1
17
25
  with:
18
26
  ruby-version: ${{ matrix.ruby }}
19
27
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -9,10 +9,10 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v5
12
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
13
13
  - name: Release Gem on RubyGems
14
14
  if: contains(github.ref, 'refs/tags/v')
15
- uses: cadwallion/publish-rubygems-action@v1.1.0
15
+ uses: cadwallion/publish-rubygems-action@94a6f4cd5350581749c569b5001eecc864e3ad0b # v1.1.0
16
16
  env:
17
17
  GITHUB_TOKEN: ${{secrets.TOKEN_RUBYGEMS_RELEASES_WITH_EXPIRATION}}
18
18
  RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
@@ -7,7 +7,7 @@ jobs:
7
7
  stale:
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
- - uses: actions/stale@v9
10
+ - uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10
11
11
  with:
12
12
  repo-token: ${{ secrets.GITHUB_TOKEN }}
13
13
  stale-issue-message: 'This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs.'
data/AGENTS.md ADDED
@@ -0,0 +1,73 @@
1
+ ## Overview
2
+
3
+ This is the Adyen Ruby API Library, providing Ruby developers with an easy way to interact with the Adyen API. The library is a wrapper around the Adyen API, with services generated from OpenAPI specifications.
4
+
5
+ ## Code Generation
6
+
7
+ A significant portion of this library, particularly the API services, is automatically generated.
8
+
9
+ - **Engine**: We use [OpenAPI Generator](https://openapi-generator.tech/) with custom [Mustache](https://mustache.github.io/) templates to convert Adyen's OpenAPI specifications into Ruby code.
10
+ - **Templates**: The custom templates are located in the `/templates` directory. These templates are tailored to fit our custom HTTP client and service structure.
11
+ - **Automation**:
12
+ - **Centralized**: The primary generation process is managed in a separate repository, [`adyen-sdk-automation`](https://github.com/Adyen/adyen-sdk-automation). Changes to the OpenAPI specs trigger a GitHub workflow in that repository, which generates the code and opens Pull Requests in this library.
13
+ - **Local**: For development and testing, you must use the [`adyen-sdk-automation`](https://github.com/Adyen/adyen-sdk-automation) repository.
14
+
15
+ ### Local Code Generation
16
+
17
+ To test new features or changes to the templates, you must run the generation process from a local clone of the `adyen-sdk-automation` repository.
18
+
19
+ 1. **Clone the automation repository**:
20
+ ```bash
21
+ git clone https://github.com/Adyen/adyen-sdk-automation.git
22
+ ```
23
+
24
+ 2. **Link this library**: The automation project needs to target your local clone of `adyen-ruby-api-library`. From inside the `adyen-sdk-automation` directory, run the following commands. This will replace the `ruby/repo` directory with a symlink to your local project.
25
+ ```bash
26
+ rm -rf ruby/repo
27
+ ln -s /path/to/your/adyen-ruby-api-library ruby/repo
28
+ ```
29
+
30
+ 3. **Run the generator**: You can now run the Gradle commands to generate code.
31
+ - **To generate all services for the Ruby library**:
32
+ ```bash
33
+ ./gradlew :ruby:services
34
+ ```
35
+ - **To generate a single service (e.g., Checkout)**:
36
+ ```bash
37
+ ./gradlew :ruby:checkout
38
+ ```
39
+ - **To clean the repository before generating**:
40
+ ```bash
41
+ ./gradlew :ruby:cleanRepo :ruby:checkout
42
+ ```
43
+
44
+ ## Core Components
45
+
46
+ - **`Adyen::Client`**: The main class in `lib/adyen/client.rb` that provides easy access to all API services and handles configuration (API key, environment, etc.).
47
+ - **`Adyen::Service`**: The base class located in `lib/adyen/services/service.rb` from which all generated services inherit. It contains the logic for making API calls.
48
+ - **`lib/adyen/services/`**: This directory contains the generated service classes (e.g., `Checkout`, `Management`) that expose methods for specific API endpoints. This library does not use generated models for requests and responses; standard Ruby Hashes are used instead.
49
+
50
+ ## Development Workflow
51
+
52
+ ### Setup
53
+
54
+ To install the library and its development dependencies, run:
55
+ ```bash
56
+ bundle config set with development
57
+ bundle install
58
+ ```
59
+
60
+ ### Running Tests
61
+
62
+ To run the RSpec test suite, use the following command:
63
+ ```bash
64
+ bundle exec rspec
65
+ ```
66
+ This is the command used in our GitHub Actions workflow to ensure code quality and correctness.
67
+
68
+ ## Release Process
69
+
70
+ The release process is automated via GitHub Actions and involves two main workflows:
71
+
72
+ 1. **Release PR Creation**: After a pull request is merged to `main`, the `release.yml` workflow automatically creates a new pull request that bumps the version number in `lib/adyen/version.rb`.
73
+ 2. **Publishing to RubyGems**: Once the version bump PR is merged, a maintainer can create a GitHub Release. This can be done by manually running the `Release` workflow with the `github-release` option. The creation of a published release on GitHub triggers the `rubygems_release.yml` workflow, which publishes the new version of the gem to RubyGems.
data/README.md CHANGED
@@ -13,6 +13,7 @@ This library supports the following:
13
13
  |-------------------------------------------------------------------------------------------------------------------------------|:-----------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
14
14
  | [BIN lookup API](https://docs.adyen.com/api-explorer/BinLookup/54/overview) | v54 | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | [BinLookup](lib/adyen/services/binLookup.rb) |
15
15
  | [Checkout API](https://docs.adyen.com/api-explorer/Checkout/71/overview) | v71 | Our latest integration for accepting online payments. | [CheckoutAPI](lib/adyen/services/checkout.rb) |
16
+ | [Capital API](https://docs.adyen.com/api-explorer/capital/1/overview) | v1 | Provides endpoints for embedding Adyen Capital into your marketplace or platform. | [Capital](lib/adyen/services/capital.rb) |
16
17
  | [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/2/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) |
17
18
  | [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) |
18
19
  | [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/overview) | v4 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](lib/adyen/services/legalEntityManagement.rb) |
@@ -70,6 +71,8 @@ require 'adyen-ruby-api-library'
70
71
  adyen = Adyen::Client.new
71
72
 
72
73
  adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
74
+ # If applicable, set application name (for tracking purposes)
75
+ # adyen.application_name = 'MyTestApp'
73
76
 
74
77
  ~~~~
75
78
 
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 11.1.0
1
+ 11.3.0
2
2
 
data/lib/adyen/client.rb CHANGED
@@ -12,16 +12,18 @@ require_relative './result'
12
12
 
13
13
  module Adyen
14
14
  class Client
15
- attr_accessor :ws_user, :ws_password, :api_key, :oauth_token, :client, :adapter
15
+ attr_accessor :ws_user, :ws_password, :api_key, :oauth_token, :client, :adapter, :application_name
16
16
  attr_reader :env, :connection_options, :adapter_options, :terminal_region
17
17
 
18
18
  def initialize(ws_user: nil, ws_password: nil, api_key: nil, oauth_token: nil, env: :live, adapter: nil, mock_port: 3001,
19
- live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil, adapter_options: nil, terminal_region: nil)
19
+ live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil, adapter_options: nil, terminal_region: nil,
20
+ application_name: nil)
20
21
  @ws_user = ws_user
21
22
  @ws_password = ws_password
22
23
  @api_key = api_key
23
24
  @oauth_token = oauth_token
24
- @env = env
25
+ self.env = env
26
+ @application_name = application_name
25
27
  @adapter = adapter || Faraday.default_adapter
26
28
  if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.1')
27
29
  # for faraday 2.1 and higher
@@ -31,7 +33,7 @@ module Adyen
31
33
  @adapter_options = adapter_options || {}
32
34
  end
33
35
  @mock_service_url_base = mock_service_url_base || "http://localhost:#{mock_port}"
34
- @live_url_prefix = live_url_prefix
36
+ self.live_url_prefix = live_url_prefix
35
37
  if RUBY_VERSION >= '3.2'
36
38
  # set default timeouts
37
39
  @connection_options = connection_options || Faraday::ConnectionOptions.new(
@@ -49,7 +51,7 @@ module Adyen
49
51
 
50
52
  # make sure that env can only be :live, :test, or :mock
51
53
  def env=(value)
52
- raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless %i[
54
+ raise ArgumentError, "Invalid value for Client.env: '#{value}' - must be one of [:live, :test, :mock]" unless %i[
53
55
  live test mock
54
56
  ].include? value
55
57
 
@@ -58,8 +60,7 @@ module Adyen
58
60
 
59
61
  # remove 'https' from live_url_prefix if necessary
60
62
  def live_url_prefix=(value)
61
- value['https://'] = '' unless value['https://'].nil?
62
- @live_url_prefix = value
63
+ @live_url_prefix = value.nil? ? value : value.sub('https://', '')
63
64
  end
64
65
 
65
66
  # base URL for API given service and @env
@@ -95,6 +96,9 @@ module Adyen
95
96
  when 'Transfers'
96
97
  url = "https://balanceplatform-api-#{@env}.adyen.com/btl"
97
98
  supports_live_url_prefix = false
99
+ when 'Capital'
100
+ url = "https://balanceplatform-api-#{@env}.adyen.com/capital"
101
+ supports_live_url_prefix = false
98
102
  when 'Management'
99
103
  url = "https://management-#{@env}.adyen.com"
100
104
  supports_live_url_prefix = false
@@ -152,7 +156,9 @@ module Adyen
152
156
  conn = Faraday.new(url, @connection_options) do |faraday|
153
157
  faraday.adapter @adapter, **@adapter_options
154
158
  faraday.headers['Content-Type'] = 'application/json'
155
- faraday.headers['User-Agent'] = "#{Adyen::NAME}/#{Adyen::VERSION}"
159
+ user_agent = "#{Adyen::NAME}/#{Adyen::VERSION}"
160
+ user_agent = "#{@application_name} #{user_agent}" if @application_name && !@application_name.strip.empty?
161
+ faraday.headers['User-Agent'] = user_agent
156
162
 
157
163
  # set header based on auth_type and service
158
164
  auth_header(auth_type, faraday)
@@ -327,6 +333,10 @@ module Adyen
327
333
  @balance_control ||= Adyen::BalanceControl.new(self)
328
334
  end
329
335
 
336
+ def capital
337
+ @capital ||= Adyen::Capital.new(self)
338
+ end
339
+
330
340
 
331
341
  private
332
342
 
@@ -16,9 +16,7 @@ module Adyen
16
16
  #
17
17
  # Deprecated since Adyen Balance Control API v1
18
18
  def balance_transfer(request, headers: {})
19
- endpoint = '/balanceTransfer'.gsub(/{.+?}/, '%s')
20
- endpoint = endpoint.gsub(%r{^/}, '')
21
- endpoint = format(endpoint)
19
+ endpoint = build_endpoint('/balanceTransfer')
22
20
 
23
21
  action = { method: 'post', url: endpoint }
24
22
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -14,9 +14,7 @@ module Adyen
14
14
 
15
15
  # Create an account holder
16
16
  def create_account_holder(request, headers: {})
17
- endpoint = '/accountHolders'.gsub(/{.+?}/, '%s')
18
- endpoint = endpoint.gsub(%r{^/}, '')
19
- endpoint = format(endpoint)
17
+ endpoint = build_endpoint('/accountHolders')
20
18
 
21
19
  action = { method: 'post', url: endpoint }
22
20
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -24,9 +22,7 @@ module Adyen
24
22
 
25
23
  # Get an account holder
26
24
  def get_account_holder(id, headers: {})
27
- endpoint = '/accountHolders/{id}'.gsub(/{.+?}/, '%s')
28
- endpoint = endpoint.gsub(%r{^/}, '')
29
- endpoint = format(endpoint, id)
25
+ endpoint = build_endpoint('/accountHolders/{id}', id)
30
26
 
31
27
  action = { method: 'get', url: endpoint }
32
28
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -34,9 +30,7 @@ module Adyen
34
30
 
35
31
  # Get all balance accounts of an account holder
36
32
  def get_all_balance_accounts_of_account_holder(id, headers: {}, query_params: {})
37
- endpoint = '/accountHolders/{id}/balanceAccounts'.gsub(/{.+?}/, '%s')
38
- endpoint = endpoint.gsub(%r{^/}, '')
39
- endpoint = format(endpoint, id)
33
+ endpoint = build_endpoint('/accountHolders/{id}/balanceAccounts', id)
40
34
  endpoint += create_query_string(query_params)
41
35
  action = { method: 'get', url: endpoint }
42
36
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -44,9 +38,7 @@ module Adyen
44
38
 
45
39
  # Get all transaction rules for an account holder
46
40
  def get_all_transaction_rules_for_account_holder(id, headers: {})
47
- endpoint = '/accountHolders/{id}/transactionRules'.gsub(/{.+?}/, '%s')
48
- endpoint = endpoint.gsub(%r{^/}, '')
49
- endpoint = format(endpoint, id)
41
+ endpoint = build_endpoint('/accountHolders/{id}/transactionRules', id)
50
42
 
51
43
  action = { method: 'get', url: endpoint }
52
44
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -54,9 +46,15 @@ module Adyen
54
46
 
55
47
  # Get a tax form
56
48
  def get_tax_form(id, headers: {}, query_params: {})
57
- endpoint = '/accountHolders/{id}/taxForms'.gsub(/{.+?}/, '%s')
58
- endpoint = endpoint.gsub(%r{^/}, '')
59
- endpoint = format(endpoint, id)
49
+ endpoint = build_endpoint('/accountHolders/{id}/taxForms', id)
50
+ endpoint += create_query_string(query_params)
51
+ action = { method: 'get', url: endpoint }
52
+ @client.call_adyen_api(@service, action, {}, headers, @version)
53
+ end
54
+
55
+ # Get summary of tax forms for an account holder
56
+ def get_tax_form_summary(id, headers: {}, query_params: {})
57
+ endpoint = build_endpoint('/accountHolders/{id}/taxFormSummary', id)
60
58
  endpoint += create_query_string(query_params)
61
59
  action = { method: 'get', url: endpoint }
62
60
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -64,9 +62,7 @@ module Adyen
64
62
 
65
63
  # Update an account holder
66
64
  def update_account_holder(request, id, headers: {})
67
- endpoint = '/accountHolders/{id}'.gsub(/{.+?}/, '%s')
68
- endpoint = endpoint.gsub(%r{^/}, '')
69
- endpoint = format(endpoint, id)
65
+ endpoint = build_endpoint('/accountHolders/{id}', id)
70
66
 
71
67
  action = { method: 'patch', url: endpoint }
72
68
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -14,9 +14,7 @@ module Adyen
14
14
 
15
15
  # Create authorized users for a card.
16
16
  def create_authorised_card_users(request, payment_instrument_id, headers: {})
17
- endpoint = '/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers'.gsub(/{.+?}/, '%s')
18
- endpoint = endpoint.gsub(%r{^/}, '')
19
- endpoint = format(endpoint, payment_instrument_id)
17
+ endpoint = build_endpoint('/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers', payment_instrument_id)
20
18
 
21
19
  action = { method: 'post', url: endpoint }
22
20
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -24,9 +22,7 @@ module Adyen
24
22
 
25
23
  # Delete the authorized users for a card.
26
24
  def delete_authorised_card_users(payment_instrument_id, headers: {})
27
- endpoint = '/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers'.gsub(/{.+?}/, '%s')
28
- endpoint = endpoint.gsub(%r{^/}, '')
29
- endpoint = format(endpoint, payment_instrument_id)
25
+ endpoint = build_endpoint('/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers', payment_instrument_id)
30
26
 
31
27
  action = { method: 'delete', url: endpoint }
32
28
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -34,9 +30,7 @@ module Adyen
34
30
 
35
31
  # Get authorized users for a card.
36
32
  def get_all_authorised_card_users(payment_instrument_id, headers: {})
37
- endpoint = '/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers'.gsub(/{.+?}/, '%s')
38
- endpoint = endpoint.gsub(%r{^/}, '')
39
- endpoint = format(endpoint, payment_instrument_id)
33
+ endpoint = build_endpoint('/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers', payment_instrument_id)
40
34
 
41
35
  action = { method: 'get', url: endpoint }
42
36
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -44,9 +38,7 @@ module Adyen
44
38
 
45
39
  # Update the authorized users for a card.
46
40
  def update_authorised_card_users(request, payment_instrument_id, headers: {})
47
- endpoint = '/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers'.gsub(/{.+?}/, '%s')
48
- endpoint = endpoint.gsub(%r{^/}, '')
49
- endpoint = format(endpoint, payment_instrument_id)
41
+ endpoint = build_endpoint('/paymentInstruments/{paymentInstrumentId}/authorisedCardUsers', payment_instrument_id)
50
42
 
51
43
  action = { method: 'patch', url: endpoint }
52
44
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -14,9 +14,7 @@ module Adyen
14
14
 
15
15
  # Create a balance account
16
16
  def create_balance_account(request, headers: {})
17
- endpoint = '/balanceAccounts'.gsub(/{.+?}/, '%s')
18
- endpoint = endpoint.gsub(%r{^/}, '')
19
- endpoint = format(endpoint)
17
+ endpoint = build_endpoint('/balanceAccounts')
20
18
 
21
19
  action = { method: 'post', url: endpoint }
22
20
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -24,9 +22,7 @@ module Adyen
24
22
 
25
23
  # Create a sweep
26
24
  def create_sweep(request, balance_account_id, headers: {})
27
- endpoint = '/balanceAccounts/{balanceAccountId}/sweeps'.gsub(/{.+?}/, '%s')
28
- endpoint = endpoint.gsub(%r{^/}, '')
29
- endpoint = format(endpoint, balance_account_id)
25
+ endpoint = build_endpoint('/balanceAccounts/{balanceAccountId}/sweeps', balance_account_id)
30
26
 
31
27
  action = { method: 'post', url: endpoint }
32
28
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -34,9 +30,7 @@ module Adyen
34
30
 
35
31
  # Delete a sweep
36
32
  def delete_sweep(balance_account_id, sweep_id, headers: {})
37
- endpoint = '/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}'.gsub(/{.+?}/, '%s')
38
- endpoint = endpoint.gsub(%r{^/}, '')
39
- endpoint = format(endpoint, balance_account_id, sweep_id)
33
+ endpoint = build_endpoint('/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}', balance_account_id, sweep_id)
40
34
 
41
35
  action = { method: 'delete', url: endpoint }
42
36
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -44,9 +38,7 @@ module Adyen
44
38
 
45
39
  # Get all sweeps for a balance account
46
40
  def get_all_sweeps_for_balance_account(balance_account_id, headers: {}, query_params: {})
47
- endpoint = '/balanceAccounts/{balanceAccountId}/sweeps'.gsub(/{.+?}/, '%s')
48
- endpoint = endpoint.gsub(%r{^/}, '')
49
- endpoint = format(endpoint, balance_account_id)
41
+ endpoint = build_endpoint('/balanceAccounts/{balanceAccountId}/sweeps', balance_account_id)
50
42
  endpoint += create_query_string(query_params)
51
43
  action = { method: 'get', url: endpoint }
52
44
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -54,9 +46,7 @@ module Adyen
54
46
 
55
47
  # Get all transaction rules for a balance account
56
48
  def get_all_transaction_rules_for_balance_account(id, headers: {})
57
- endpoint = '/balanceAccounts/{id}/transactionRules'.gsub(/{.+?}/, '%s')
58
- endpoint = endpoint.gsub(%r{^/}, '')
59
- endpoint = format(endpoint, id)
49
+ endpoint = build_endpoint('/balanceAccounts/{id}/transactionRules', id)
60
50
 
61
51
  action = { method: 'get', url: endpoint }
62
52
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -64,9 +54,7 @@ module Adyen
64
54
 
65
55
  # Get a balance account
66
56
  def get_balance_account(id, headers: {})
67
- endpoint = '/balanceAccounts/{id}'.gsub(/{.+?}/, '%s')
68
- endpoint = endpoint.gsub(%r{^/}, '')
69
- endpoint = format(endpoint, id)
57
+ endpoint = build_endpoint('/balanceAccounts/{id}', id)
70
58
 
71
59
  action = { method: 'get', url: endpoint }
72
60
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -74,9 +62,7 @@ module Adyen
74
62
 
75
63
  # Get payment instruments linked to a balance account
76
64
  def get_payment_instruments_linked_to_balance_account(id, headers: {}, query_params: {})
77
- endpoint = '/balanceAccounts/{id}/paymentInstruments'.gsub(/{.+?}/, '%s')
78
- endpoint = endpoint.gsub(%r{^/}, '')
79
- endpoint = format(endpoint, id)
65
+ endpoint = build_endpoint('/balanceAccounts/{id}/paymentInstruments', id)
80
66
  endpoint += create_query_string(query_params)
81
67
  action = { method: 'get', url: endpoint }
82
68
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -84,9 +70,7 @@ module Adyen
84
70
 
85
71
  # Get a sweep
86
72
  def get_sweep(balance_account_id, sweep_id, headers: {})
87
- endpoint = '/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}'.gsub(/{.+?}/, '%s')
88
- endpoint = endpoint.gsub(%r{^/}, '')
89
- endpoint = format(endpoint, balance_account_id, sweep_id)
73
+ endpoint = build_endpoint('/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}', balance_account_id, sweep_id)
90
74
 
91
75
  action = { method: 'get', url: endpoint }
92
76
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -94,9 +78,7 @@ module Adyen
94
78
 
95
79
  # Update a balance account
96
80
  def update_balance_account(request, id, headers: {})
97
- endpoint = '/balanceAccounts/{id}'.gsub(/{.+?}/, '%s')
98
- endpoint = endpoint.gsub(%r{^/}, '')
99
- endpoint = format(endpoint, id)
81
+ endpoint = build_endpoint('/balanceAccounts/{id}', id)
100
82
 
101
83
  action = { method: 'patch', url: endpoint }
102
84
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -104,9 +86,7 @@ module Adyen
104
86
 
105
87
  # Update a sweep
106
88
  def update_sweep(request, balance_account_id, sweep_id, headers: {})
107
- endpoint = '/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}'.gsub(/{.+?}/, '%s')
108
- endpoint = endpoint.gsub(%r{^/}, '')
109
- endpoint = format(endpoint, balance_account_id, sweep_id)
89
+ endpoint = build_endpoint('/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}', balance_account_id, sweep_id)
110
90
 
111
91
  action = { method: 'patch', url: endpoint }
112
92
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -14,9 +14,7 @@ module Adyen
14
14
 
15
15
  # Create a balance webhook setting
16
16
  def create_webhook_setting(request, balance_platform_id, webhook_id, headers: {})
17
- endpoint = '/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings'.gsub(/{.+?}/, '%s')
18
- endpoint = endpoint.gsub(%r{^/}, '')
19
- endpoint = format(endpoint, balance_platform_id, webhook_id)
17
+ endpoint = build_endpoint('/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings', balance_platform_id, webhook_id)
20
18
 
21
19
  action = { method: 'post', url: endpoint }
22
20
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -24,9 +22,7 @@ module Adyen
24
22
 
25
23
  # Delete a balance webhook setting by id
26
24
  def delete_webhook_setting(balance_platform_id, webhook_id, setting_id, headers: {})
27
- endpoint = '/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}'.gsub(/{.+?}/, '%s')
28
- endpoint = endpoint.gsub(%r{^/}, '')
29
- endpoint = format(endpoint, balance_platform_id, webhook_id, setting_id)
25
+ endpoint = build_endpoint('/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}', balance_platform_id, webhook_id, setting_id)
30
26
 
31
27
  action = { method: 'delete', url: endpoint }
32
28
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -34,9 +30,7 @@ module Adyen
34
30
 
35
31
  # Get all balance webhook settings
36
32
  def get_all_webhook_settings(balance_platform_id, webhook_id, headers: {})
37
- endpoint = '/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings'.gsub(/{.+?}/, '%s')
38
- endpoint = endpoint.gsub(%r{^/}, '')
39
- endpoint = format(endpoint, balance_platform_id, webhook_id)
33
+ endpoint = build_endpoint('/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings', balance_platform_id, webhook_id)
40
34
 
41
35
  action = { method: 'get', url: endpoint }
42
36
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -44,9 +38,7 @@ module Adyen
44
38
 
45
39
  # Get a balance webhook setting by id
46
40
  def get_webhook_setting(balance_platform_id, webhook_id, setting_id, headers: {})
47
- endpoint = '/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}'.gsub(/{.+?}/, '%s')
48
- endpoint = endpoint.gsub(%r{^/}, '')
49
- endpoint = format(endpoint, balance_platform_id, webhook_id, setting_id)
41
+ endpoint = build_endpoint('/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}', balance_platform_id, webhook_id, setting_id)
50
42
 
51
43
  action = { method: 'get', url: endpoint }
52
44
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -54,9 +46,7 @@ module Adyen
54
46
 
55
47
  # Update a balance webhook setting by id
56
48
  def update_webhook_setting(request, balance_platform_id, webhook_id, setting_id, headers: {})
57
- endpoint = '/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}'.gsub(/{.+?}/, '%s')
58
- endpoint = endpoint.gsub(%r{^/}, '')
59
- endpoint = format(endpoint, balance_platform_id, webhook_id, setting_id)
49
+ endpoint = build_endpoint('/balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}', balance_platform_id, webhook_id, setting_id)
60
50
 
61
51
  action = { method: 'patch', url: endpoint }
62
52
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -14,9 +14,7 @@ module Adyen
14
14
 
15
15
  # Validate a bank account
16
16
  def validate_bank_account_identification(request, headers: {})
17
- endpoint = '/validateBankAccountIdentification'.gsub(/{.+?}/, '%s')
18
- endpoint = endpoint.gsub(%r{^/}, '')
19
- endpoint = format(endpoint)
17
+ endpoint = build_endpoint('/validateBankAccountIdentification')
20
18
 
21
19
  action = { method: 'post', url: endpoint }
22
20
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -14,9 +14,7 @@ module Adyen
14
14
 
15
15
  # Get card order items
16
16
  def get_card_order_items(id, headers: {}, query_params: {})
17
- endpoint = '/cardorders/{id}/items'.gsub(/{.+?}/, '%s')
18
- endpoint = endpoint.gsub(%r{^/}, '')
19
- endpoint = format(endpoint, id)
17
+ endpoint = build_endpoint('/cardorders/{id}/items', id)
20
18
  endpoint += create_query_string(query_params)
21
19
  action = { method: 'get', url: endpoint }
22
20
  @client.call_adyen_api(@service, action, {}, headers, @version)
@@ -24,9 +22,7 @@ module Adyen
24
22
 
25
23
  # Get a list of card orders
26
24
  def list_card_orders(headers: {}, query_params: {})
27
- endpoint = '/cardorders'.gsub(/{.+?}/, '%s')
28
- endpoint = endpoint.gsub(%r{^/}, '')
29
- endpoint = format(endpoint)
25
+ endpoint = build_endpoint('/cardorders')
30
26
  endpoint += create_query_string(query_params)
31
27
  action = { method: 'get', url: endpoint }
32
28
  @client.call_adyen_api(@service, action, {}, headers, @version)