adyen-ruby-api-library 7.0.0 → 7.0.2

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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/release.yml +18 -0
  4. data/.github/workflows/gh_release.yml +16 -0
  5. data/.github/workflows/release_request.yml +15 -0
  6. data/.github/workflows/ruby.yml +1 -1
  7. data/.github/workflows/services.yml +28 -0
  8. data/.rubocop.yml +8 -0
  9. data/Gemfile +7 -7
  10. data/Makefile +14 -10
  11. data/README.md +13 -10
  12. data/Rakefile +3 -3
  13. data/adyen-ruby-api-library.gemspec +6 -3
  14. data/bin/console +2 -2
  15. data/lib/adyen/client.rb +96 -76
  16. data/lib/adyen/errors.rb +23 -18
  17. data/lib/adyen/hash_with_accessors.rb +12 -7
  18. data/lib/adyen/services/balanceControlService.rb +7 -14
  19. data/lib/adyen/services/balancePlatform/account_holders_api.rb +22 -38
  20. data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +48 -79
  21. data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +6 -13
  22. data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +6 -13
  23. data/lib/adyen/services/balancePlatform/grant_offers_api.rb +12 -22
  24. data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +16 -29
  25. data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +26 -45
  26. data/lib/adyen/services/balancePlatform/platform_api.rb +12 -22
  27. data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +21 -37
  28. data/lib/adyen/services/balancePlatform.rb +38 -40
  29. data/lib/adyen/services/binLookup.rb +12 -22
  30. data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +11 -21
  31. data/lib/adyen/services/checkout/modifications_api.rb +31 -53
  32. data/lib/adyen/services/checkout/orders_api.rb +16 -29
  33. data/lib/adyen/services/checkout/payment_links_api.rb +16 -29
  34. data/lib/adyen/services/checkout/payments_api.rb +40 -53
  35. data/lib/adyen/services/checkout/recurring_api.rb +13 -23
  36. data/lib/adyen/services/checkout/utility_api.rb +11 -21
  37. data/lib/adyen/services/checkout.rb +32 -34
  38. data/lib/adyen/services/dataProtection.rb +7 -14
  39. data/lib/adyen/services/dispute.rb +6 -5
  40. data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +21 -37
  41. data/lib/adyen/services/legalEntityManagement/documents_api.rb +21 -37
  42. data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +16 -29
  43. data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +26 -45
  44. data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +21 -37
  45. data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +25 -29
  46. data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +21 -37
  47. data/lib/adyen/services/legalEntityManagement.rb +32 -34
  48. data/lib/adyen/services/management/account_company_level_api.rb +18 -31
  49. data/lib/adyen/services/management/account_merchant_level_api.rb +22 -38
  50. data/lib/adyen/services/management/account_store_level_api.rb +43 -71
  51. data/lib/adyen/services/management/allowed_origins_company_level_api.rb +21 -37
  52. data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +21 -37
  53. data/lib/adyen/services/management/api_credentials_company_level_api.rb +22 -38
  54. data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +22 -38
  55. data/lib/adyen/services/management/api_key_company_level_api.rb +6 -13
  56. data/lib/adyen/services/management/api_key_merchant_level_api.rb +6 -13
  57. data/lib/adyen/services/management/client_key_company_level_api.rb +6 -13
  58. data/lib/adyen/services/management/client_key_merchant_level_api.rb +6 -13
  59. data/lib/adyen/services/management/my_api_credential_api.rb +26 -45
  60. data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +32 -54
  61. data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +26 -45
  62. data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +92 -0
  63. data/lib/adyen/services/management/terminal_actions_company_level_api.rb +24 -40
  64. data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +6 -13
  65. data/lib/adyen/services/management/terminal_orders_company_level_api.rb +55 -89
  66. data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +55 -89
  67. data/lib/adyen/services/management/terminal_settings_company_level_api.rb +23 -39
  68. data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +23 -39
  69. data/lib/adyen/services/management/terminal_settings_store_level_api.rb +45 -73
  70. data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +21 -37
  71. data/lib/adyen/services/management/terminals_terminal_level_api.rb +7 -14
  72. data/lib/adyen/services/management/users_company_level_api.rb +22 -38
  73. data/lib/adyen/services/management/users_merchant_level_api.rb +22 -38
  74. data/lib/adyen/services/management/webhooks_company_level_api.rb +37 -62
  75. data/lib/adyen/services/management/webhooks_merchant_level_api.rb +37 -62
  76. data/lib/adyen/services/management.rb +99 -96
  77. data/lib/adyen/services/marketpay.rb +42 -36
  78. data/lib/adyen/services/payment/general_api.rb +56 -0
  79. data/lib/adyen/services/payment/modifications_api.rb +83 -0
  80. data/lib/adyen/services/payment.rb +10 -158
  81. data/lib/adyen/services/payout/initialization_api.rb +16 -29
  82. data/lib/adyen/services/payout/instant_payouts_api.rb +6 -13
  83. data/lib/adyen/services/payout/reviewing_api.rb +11 -21
  84. data/lib/adyen/services/payout.rb +19 -21
  85. data/lib/adyen/services/posTerminalManagement.rb +27 -46
  86. data/lib/adyen/services/recurring.rb +32 -54
  87. data/lib/adyen/services/service.rb +5 -4
  88. data/lib/adyen/services/storedValue.rb +32 -54
  89. data/lib/adyen/services/transfers/capital_api.rb +38 -0
  90. data/lib/adyen/services/transfers/transactions_api.rb +12 -22
  91. data/lib/adyen/services/transfers/transfers_api.rb +6 -13
  92. data/lib/adyen/services/transfers.rb +20 -17
  93. data/lib/adyen/utils/hmac_validator.rb +9 -9
  94. data/lib/adyen/version.rb +3 -3
  95. data/lib/adyen-ruby-api-library.rb +21 -21
  96. data/spec/account_spec.rb +20 -20
  97. data/spec/balance_control_spec.rb +28 -29
  98. data/spec/balance_platform_spec.rb +108 -102
  99. data/spec/bin_lookup_spec.rb +50 -50
  100. data/spec/checkout_spec.rb +581 -515
  101. data/spec/client_spec.rb +118 -71
  102. data/spec/data_protection_spec.rb +4 -4
  103. data/spec/dispute_spec.rb +7 -7
  104. data/spec/errors_spec.rb +37 -17
  105. data/spec/fund_spec.rb +10 -10
  106. data/spec/hash_with_accessors_spec.rb +18 -8
  107. data/spec/hop_spec.rb +4 -4
  108. data/spec/lem_spec.rb +44 -49
  109. data/spec/management_spec.rb +46 -48
  110. data/spec/notification_spec.rb +9 -9
  111. data/spec/payments_spec.rb +31 -32
  112. data/spec/payouts_spec.rb +29 -32
  113. data/spec/pos_terminal_management_spec.rb +30 -32
  114. data/spec/recurring_spec.rb +8 -8
  115. data/spec/service_spec.rb +4 -0
  116. data/spec/spec_helper.rb +37 -35
  117. data/spec/stored_value_spec.rb +28 -27
  118. data/spec/transfers_spec.rb +48 -47
  119. data/spec/utils/hmac_validator_spec.rb +15 -14
  120. data/templates/api-single.mustache +13 -15
  121. data/templates/api-small.mustache +8 -15
  122. data/templates/api.mustache +7 -14
  123. metadata +27 -18
  124. data/.github/dependabot.yml +0 -8
  125. /data/spec/mocks/responses/Webhooks/{backslash_notification.json → backslash_webhook.json} +0 -0
  126. /data/spec/mocks/responses/Webhooks/{colon_notification.json → colon_webhook.json} +0 -0
  127. /data/spec/mocks/responses/Webhooks/{forwardslash_notification.json → forwardslash_webhook.json} +0 -0
  128. /data/spec/mocks/responses/Webhooks/{mixed_notification.json → mixed_webhook.json} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a353164deda5fc44de3ec027f4022732e9c4afdb1a5bfacf91704e9d8c9e90a
4
- data.tar.gz: 1f1f2d92d0f9528a9c6945da699a3a9d8a05e0594c7fe4d2fb66ad8c85c01c77
3
+ metadata.gz: dfc331f9e3975a74232200c6167ae29c56be90875e00de8ab2b369c32b8e52a2
4
+ data.tar.gz: f21165fdab9fd26003fa1a9ebd540d4c18985160c14b0603a7e0c48e0b8ff048
5
5
  SHA512:
6
- metadata.gz: a8d4190c1cbb857fa27ca0134a34b559c4e30c46d9397bce514b5894820c6fc0a33e4af10076953a27bfe5c36e3ab06558a55264c34a1ae3acfc26c818786979
7
- data.tar.gz: be1328cdf8c4592cf0c3dc6573c1a248b761efc30f01e4eb997744234295c397c35b3b2755ab07593f6d5f1e776287daedf8f98493f462492e1f2284bcfda346
6
+ metadata.gz: 30ca572d49863116b7b0054cee61e7c41aa73455232abedd23c2d83b6d14376d5b80b7f71978d06b6364e20f053d84131ad327e15d4b56e6bbd5a71dbec4a02c
7
+ data.tar.gz: 8f57fe334a6f4b24894c88504d75ffeacc6f3f3df28b00c0ed511a80ce6c70002d469d1327ef6db297a519b72f94d6ce3cd32716a253cf37c18e09e9b129ad45
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @Adyen/api-libraries-reviewers
1
+ * @Adyen/integration-tools-testing
@@ -0,0 +1,18 @@
1
+ changelog:
2
+ exclude:
3
+ authors:
4
+ - renovate[bot]
5
+ - dependabot[bot]
6
+ categories:
7
+ - title: Breaking Changes 🛠
8
+ labels:
9
+ - Breaking change
10
+ - title: New Features 💎
11
+ labels:
12
+ - Feature
13
+ - title: Fixes ⛑️
14
+ labels:
15
+ - Fix
16
+ - title: Other Changes 🖇️
17
+ labels:
18
+ - "*"
@@ -0,0 +1,16 @@
1
+ name: Github Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ gh_release:
11
+ permissions:
12
+ contents: write
13
+ uses: Adyen/adyen-node-api-library/.github/workflows/lib-gh-release.yml@develop
14
+ with:
15
+ project-name: Ruby
16
+ secrets: inherit
@@ -0,0 +1,15 @@
1
+ name: Release request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - develop
8
+
9
+ jobs:
10
+ release:
11
+ permissions:
12
+ contents: write
13
+ pull-requests: write
14
+ uses: Adyen/adyen-node-api-library/.github/workflows/lib-release.yml@develop
15
+ secrets: inherit
@@ -9,7 +9,7 @@ jobs:
9
9
  matrix:
10
10
  os: [ubuntu-latest]
11
11
  # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
12
- ruby: [2.5, 2.6, 2.7, '3.0', head]
12
+ ruby: [2.7, '3.0', 3.1, 3.2, head]
13
13
  runs-on: ${{ matrix.os }}
14
14
  steps:
15
15
  - uses: actions/checkout@v3
@@ -0,0 +1,28 @@
1
+ name: Ruby Library Services Generation
2
+
3
+ on: [ workflow_dispatch ]
4
+
5
+ jobs:
6
+ generate:
7
+ runs-on: ubuntu-latest
8
+ name: Generate Services
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - run: make allServices
12
+ - name: Set PR variables
13
+ id: vars
14
+ run: |
15
+ echo ::set-output name=pr_title::"Update services"
16
+ echo ::set-output name=pr_body::"OpenAPI spec or templates produced new services on $(date +%d-%m-%Y) \
17
+ by [commit](https://github.com/Adyen/adyen-openapi/commit/$(git rev-parse HEAD))."
18
+ - name: Create Pull Request
19
+ uses: peter-evans/create-pull-request@v5
20
+ with:
21
+ token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
22
+ committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
23
+ author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
24
+ base: develop
25
+ branch: automation/services
26
+ title: ${{ steps.vars.outputs.pr_title }}
27
+ body: ${{ steps.vars.outputs.pr_body }}
28
+ add-paths: lib/adyen/services
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Style/FrozenStringLiteralComment:
2
+ Enabled: false
3
+ Metrics/BlockLength:
4
+ Enabled: false
5
+ Documentation:
6
+ Enabled: false
7
+ Naming/FileName:
8
+ Enabled: false
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- ruby ">= 2.1.0"
5
+ ruby '>= 2.7.0'
6
6
 
7
- gem "faraday"
7
+ gem 'faraday'
8
8
 
9
- gem "bundler", :group => :development
10
- gem "webmock", :group => :development
11
- gem "rspec", :group => :development
12
- gem "activesupport", :group => :development
9
+ gem 'activesupport', group: :development
10
+ gem 'bundler', group: :development
11
+ gem 'rspec', group: :development
12
+ gem 'webmock', group: :development
data/Makefile CHANGED
@@ -5,8 +5,8 @@ openapi-generator-jar:=build/openapi-generator-cli.jar
5
5
  openapi-generator-cli:=java -jar build/openapi-generator-cli.jar
6
6
  output:=build/out
7
7
 
8
- services:=balancePlatform checkout legalEntityManagement management payout platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration transfers
9
- singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue posTerminalManagement payment
8
+ services:=balancePlatform checkout legalEntityManagement management payment payout transfers
9
+ singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue posTerminalManagement
10
10
 
11
11
  binLookup: spec=BinLookupService-v54
12
12
  checkout: spec=CheckoutService-v70
@@ -19,12 +19,8 @@ payout: spec=PayoutService-v68
19
19
  management: spec=ManagementService-v1
20
20
  legalEntityManagement: spec=LegalEntityService-v3
21
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
22
  balanceControlService: spec=BalanceControlService-v1
23
+ transfers: spec=TransferService-v3
28
24
 
29
25
  allServices: $(services) $(singleFileServices)
30
26
 
@@ -47,7 +43,6 @@ $(services): build/spec $(openapi-generator-jar)
47
43
 
48
44
  $(singleFileServices): build/spec
49
45
  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
46
  rm -rf $(output)
52
47
  $(openapi-generator-cli) generate \
53
48
  -i build/spec/json/$(spec).json \
@@ -57,7 +52,7 @@ $(singleFileServices): build/spec
57
52
  --global-property apis,apiTests=false,apiDocs=false\
58
53
  --additional-properties serviceName=$@\
59
54
  --skip-validate-spec
60
- mv $(output)/lib/openapi_client/api/default_api-small.rb lib/adyen/services/$@.rb
55
+ mv $(output)/lib/openapi_client/api/*-small.rb lib/adyen/services/$@.rb
61
56
  rm -rf $(output)
62
57
 
63
58
  templates: $(openapi-generator-jar)
@@ -69,4 +64,13 @@ $(openapi-generator-jar):
69
64
 
70
65
  build/spec:
71
66
  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
67
+ perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
68
+
69
+ # Releases
70
+
71
+ version:
72
+ perl -lne 'print "currentVersion=$$1" if /(\d+\.\d+\.\d+)/' < lib/adyen/version.rb >> "$$GITHUB_OUTPUT"
73
+
74
+ version_files:=lib/adyen/version.rb
75
+ bump:
76
+ perl -i -pe 's/$$ENV{"CURRENT_VERSION"}/$$ENV{"NEXT_VERSION"}/' $(version_files)
data/README.md CHANGED
@@ -9,16 +9,16 @@ This library supports the following:
9
9
 
10
10
  | API name | API version | Description | API object |
11
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) |
12
+ | [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) |
13
+ | [Checkout API](https://docs.adyen.com/api-explorer/Checkout/70/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/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) |
15
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) |
16
+ | [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/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/Management/1/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/68/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/68/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/1/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/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
22
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
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) |
24
24
 
@@ -27,7 +27,7 @@ For more information, refer to our [documentation](https://docs.adyen.com/) or t
27
27
  ## Prerequisites
28
28
  - [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
29
29
  - [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
30
- - Ruby >= 2.1
30
+ - Ruby >= 2.7
31
31
 
32
32
  ## Installation
33
33
 
@@ -99,6 +99,9 @@ To run the tests use :
99
99
  bundle install --with development
100
100
  ~~~~
101
101
 
102
+ ## Feedback
103
+ We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out [our feedback form](https://forms.gle/A4EERrR6CWgKWe5r9) to share your thoughts, suggestions or ideas.
104
+
102
105
  ## Contributing
103
106
 
104
107
  We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -3,12 +3,15 @@ require_relative 'lib/adyen/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'adyen-ruby-api-library'
5
5
  spec.version = Adyen::VERSION
6
- spec.required_ruby_version = '>= 2.1.0'
6
+ spec.required_ruby_version = '>= 2.7.0'
7
7
  spec.authors = ['Adyen']
8
8
  spec.email = ['support@adyen.com']
9
9
 
10
10
  spec.summary = 'Official Adyen Ruby API Library'
11
- spec.description = 'Official Adyen API Library for Ruby. Simplifies integrating with the Adyen API, including Checkout, Marketpay, payments, recurring, and payouts. For support please reach out to support@adyen.com. If you would like to contribute please submit a comment or pull request at https://github.com/Adyen/adyen-ruby-api-library.'
11
+ spec.description = 'Official Adyen API Library for Ruby. Simplifies integrating with the Adyen API,\
12
+ including Checkout, Marketpay, payments, recurring, and payouts. For support please reach out to \
13
+ support@adyen.com. If you would like to contribute please submit \
14
+ a comment or pull request at https://github.com/Adyen/adyen-ruby-api-library.'
12
15
  spec.homepage = 'https://www.adyen.com'
13
16
  spec.license = 'MIT'
14
17
 
@@ -22,7 +25,7 @@ Gem::Specification.new do |spec|
22
25
 
23
26
  spec.add_dependency 'faraday'
24
27
 
28
+ spec.add_development_dependency 'activesupport'
25
29
  spec.add_development_dependency 'bundler'
26
30
  spec.add_development_dependency 'webmock'
27
- spec.add_development_dependency 'activesupport'
28
31
  end
data/bin/console CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative "../lib/adyen-ruby-api-library.rb"
3
+ require_relative '../lib/adyen-ruby-api-library'
4
4
 
5
5
  # You can add fixtures and/or initialization code here to make experimenting
6
6
  # with your gem easier. You can also use a different console, if you like.
@@ -9,5 +9,5 @@ require_relative "../lib/adyen-ruby-api-library.rb"
9
9
  # require "pry"
10
10
  # Pry.start
11
11
 
12
- require "irb"
12
+ require 'irb'
13
13
  IRB.start(__FILE__)
data/lib/adyen/client.rb CHANGED
@@ -1,14 +1,22 @@
1
- require "faraday"
2
- require "json"
3
- require_relative "./errors"
4
- require_relative "./result"
1
+ # rubocop:disable Metrics/ParameterLists
2
+ # rubocop:disable Metrics/PerceivedComplexity
3
+ # rubocop:disable Metrics/MethodLength
4
+ # rubocop:disable Metrics/CyclomaticComplexity
5
+ # rubocop:disable Metrics/AbcSize
6
+ # rubocop:disable Metrics/ClassLength
7
+
8
+ require 'faraday'
9
+ require 'json'
10
+ require_relative './errors'
11
+ require_relative './result'
5
12
 
6
13
  module Adyen
7
14
  class Client
8
- attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter, :live_url_prefix
15
+ attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter
9
16
  attr_reader :env, :connection_options
10
17
 
11
- def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001, live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil)
18
+ def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001,
19
+ live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil)
12
20
  @ws_user = ws_user
13
21
  @ws_password = ws_password
14
22
  @api_key = api_key
@@ -21,15 +29,16 @@ module Adyen
21
29
 
22
30
  # make sure that env can only be :live, :test, or :mock
23
31
  def env=(value)
24
- raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless [:live, :test, :mock].include? value
32
+ raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless %i[
33
+ live test mock
34
+ ].include? value
35
+
25
36
  @env = value
26
37
  end
27
38
 
28
39
  # remove 'https' from live_url_prefix if necessary
29
40
  def live_url_prefix=(value)
30
- if not value["https://"].nil?
31
- value["https://"] = ""
32
- end
41
+ value['https://'] = '' unless value['https://'].nil?
33
42
  @live_url_prefix = value
34
43
  end
35
44
 
@@ -39,81 +48,94 @@ module Adyen
39
48
  @mock_service_url_base
40
49
  else
41
50
  case service
42
- when "Checkout"
51
+ when 'Checkout'
43
52
  url = "https://checkout-#{@env}.adyen.com"
44
53
  supports_live_url_prefix = true
45
- when "Account", "Fund", "Notification", "Hop"
54
+ when 'Account', 'Fund', 'Notification', 'Hop'
46
55
  url = "https://cal-#{@env}.adyen.com/cal/services/#{service}"
47
56
  supports_live_url_prefix = false
48
- when "Recurring", "Payment", "Payout", "BinLookup", "StoredValue", "BalanceControlService"
57
+ when 'Recurring', 'Payment', 'Payout', 'BinLookup', 'StoredValue', 'BalanceControlService'
49
58
  url = "https://pal-#{@env}.adyen.com/pal/servlet/#{service}"
50
59
  supports_live_url_prefix = true
51
- when "PosTerminalManagement"
60
+ when 'PosTerminalManagement'
52
61
  url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
53
62
  supports_live_url_prefix = false
54
- when "DataProtectionService", "DisputeService"
63
+ when 'DataProtectionService', 'DisputeService'
55
64
  url = "https://ca-#{@env}.adyen.com/ca/services/#{service}"
56
65
  supports_live_url_prefix = false
57
- when "LegalEntityManagement"
66
+ when 'LegalEntityManagement'
58
67
  url = "https://kyc-#{@env}.adyen.com/lem"
59
68
  supports_live_url_prefix = false
60
- when "BalancePlatform"
69
+ when 'BalancePlatform'
61
70
  url = "https://balanceplatform-api-#{@env}.adyen.com/bcl"
62
71
  supports_live_url_prefix = false
63
- when "Transfers"
72
+ when 'Transfers'
64
73
  url = "https://balanceplatform-api-#{@env}.adyen.com/btl"
65
74
  supports_live_url_prefix = false
66
- when "Management"
75
+ when 'Management'
67
76
  url = "https://management-#{@env}.adyen.com"
68
77
  supports_live_url_prefix = false
69
78
  else
70
- raise ArgumentError, "Invalid service specified"
79
+ raise ArgumentError, 'Invalid service specified'
71
80
  end
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
81
+
82
+ if @live_url_prefix.nil? && (@env == :live) && supports_live_url_prefix
83
+ raise ArgumentError,
84
+ "Please set Client.live_url_prefix to the portion \
85
+ of your merchant-specific URL prior to '-[service]-live.adyenpayments.com'"
86
+ end
87
+
75
88
  if @env == :live && supports_live_url_prefix
76
89
  url.insert(8, "#{@live_url_prefix}-")
77
- url["adyen.com"] = "adyenpayments.com"
90
+ url['adyen.com'] = 'adyenpayments.com'
78
91
  end
79
92
 
80
- return url
93
+ url
81
94
  end
82
95
  end
83
96
 
84
97
  # construct full URL from service and endpoint
85
98
  def service_url(service, action, version)
86
- "#{service_url_base(service)}/v#{version}/#{action}"
99
+ if service == "Checkout" && @env == :live
100
+ return "#{service_url_base(service)}/checkout/v#{version}/#{action}"
101
+ else
102
+ return "#{service_url_base(service)}/v#{version}/#{action}"
103
+ end
87
104
  end
88
105
 
89
106
  # send request to adyen API
90
- def call_adyen_api(service, action, request_data, headers, version, with_application_info = false)
107
+ def call_adyen_api(service, action, request_data, headers, version, _with_application_info: false)
91
108
  # get URL for requested endpoint
92
109
  url = service_url(service, action.is_a?(String) ? action : action.fetch(:url), version)
93
110
 
94
111
  # make sure right authentication has been provided
95
112
  # will use api_key if present, otherwise ws_user and ws_password
96
113
  if @api_key.nil?
97
- if service == "PaymentSetupAndVerification"
98
- raise Adyen::AuthenticationError.new("Checkout service requires API-key", request_data), "Checkout service requires API-key"
114
+ if service == 'PaymentSetupAndVerification'
115
+ raise Adyen::AuthenticationError.new('Checkout service requires API-key', request_data),
116
+ 'Checkout service requires API-key'
99
117
  elsif @ws_password.nil? || @ws_user.nil?
100
- raise Adyen::AuthenticationError.new("No authentication found - please set api_key or ws_user and ws_password", request_data), "No authentication found - please set api_key or ws_user and ws_password"
118
+ raise Adyen::AuthenticationError.new(
119
+ 'No authentication found - please set api_key or ws_user and ws_password',
120
+ request_data
121
+ ),
122
+ 'No authentication found - please set api_key or ws_user and ws_password'
101
123
  else
102
- auth_type = "basic"
124
+ auth_type = 'basic'
103
125
  end
104
126
  else
105
- auth_type = "api-key"
127
+ auth_type = 'api-key'
106
128
  end
107
129
 
108
130
  # initialize Faraday connection object
109
131
  conn = Faraday.new(url, @connection_options) do |faraday|
110
132
  faraday.adapter @adapter
111
- faraday.headers["Content-Type"] = "application/json"
112
- faraday.headers["User-Agent"] = Adyen::NAME + "/" + Adyen::VERSION
133
+ faraday.headers['Content-Type'] = 'application/json'
134
+ faraday.headers['User-Agent'] = "#{Adyen::NAME}/#{Adyen::VERSION}"
113
135
 
114
136
  # set auth type based on service
115
137
  case auth_type
116
- when "basic"
138
+ when 'basic'
117
139
  if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
118
140
  # for faraday 2.0 and higher
119
141
  faraday.request :authorization, :basic, @ws_user, @ws_password
@@ -121,8 +143,8 @@ module Adyen
121
143
  # for faraday 1.x
122
144
  faraday.basic_auth(@ws_user, @ws_password)
123
145
  end
124
- when "api-key"
125
- faraday.headers["x-api-key"] = @api_key
146
+ when 'api-key'
147
+ faraday.headers['x-api-key'] = @api_key
126
148
  end
127
149
 
128
150
  # add optional headers if specified in request
@@ -132,81 +154,78 @@ module Adyen
132
154
  end
133
155
 
134
156
  # add library headers
135
- faraday.headers["adyen-library-name"] = Adyen::NAME
136
- faraday.headers["adyen-library-version"] = Adyen::VERSION
157
+ faraday.headers['adyen-library-name'] = Adyen::NAME
158
+ faraday.headers['adyen-library-version'] = Adyen::VERSION
137
159
  end
138
160
  # if json string convert to hash
139
161
  # needed to add applicationInfo
140
- if request_data.is_a?(String)
141
- request_data = JSON.parse(request_data)
142
- end
143
-
162
+ request_data = JSON.parse(request_data) if request_data.is_a?(String)
144
163
 
145
164
  # convert to json
146
165
  request_data = request_data.to_json
147
166
 
148
167
  if action.is_a?(::Hash)
149
- if action.fetch(:method) == "get"
168
+ if action.fetch(:method) == 'get'
150
169
  begin
151
170
  response = conn.get
152
- rescue Faraday::ConnectionFailed => connection_error
153
- raise connection_error, "Connection to #{url} failed"
171
+ rescue Faraday::ConnectionFailed => e
172
+ raise e, "Connection to #{url} failed"
154
173
  end
155
174
  end
156
- if action.fetch(:method) == "delete"
175
+ if action.fetch(:method) == 'delete'
157
176
  begin
158
177
  response = conn.delete
159
- rescue Faraday::ConnectionFailed => connection_error
160
- raise connection_error, "Connection to #{url} failed"
178
+ rescue Faraday::ConnectionFailed => e
179
+ raise e, "Connection to #{url} failed"
161
180
  end
162
181
  end
163
- if action.fetch(:method) == "patch"
182
+ if action.fetch(:method) == 'patch'
164
183
  begin
165
184
  response = conn.patch do |req|
166
185
  req.body = request_data
167
186
  end
168
- rescue Faraday::ConnectionFailed => connection_error
169
- raise connection_error, "Connection to #{url} failed"
187
+ rescue Faraday::ConnectionFailed => e
188
+ raise e, "Connection to #{url} failed"
170
189
  end
171
190
  end
172
- if action.fetch(:method) == 'post'
173
- # post request to Adyen
174
- begin
175
- response = conn.post do |req|
176
- req.body = request_data
177
- end # handle client errors
178
- rescue Faraday::ConnectionFailed => connection_error
179
- raise connection_error, "Connection to #{url} failed"
191
+ if action.fetch(:method) == 'post'
192
+ # post request to Adyen
193
+ begin
194
+ response = conn.post do |req|
195
+ req.body = request_data
196
+ end
197
+ rescue Faraday::ConnectionFailed => e
198
+ raise e, "Connection to #{url} failed"
199
+ end
180
200
  end
181
- end
182
201
  else
183
202
  begin
184
203
  response = conn.post do |req|
185
204
  req.body = request_data
186
- end # handle client errors
187
- rescue Faraday::ConnectionFailed => connection_error
188
- raise connection_error, "Connection to #{url} failed"
205
+ end
206
+ rescue Faraday::ConnectionFailed => e
207
+ raise e, "Connection to #{url} failed"
189
208
  end
190
209
  end
191
210
  # check for API errors
192
211
  case response.status
193
212
  when 401
194
- raise Adyen::AuthenticationError.new("Invalid API authentication; https://docs.adyen.com/user-management/how-to-get-the-api-key", request_data)
213
+ raise Adyen::AuthenticationError.new(
214
+ 'Invalid API authentication; https://docs.adyen.com/user-management/how-to-get-the-api-key', request_data
215
+ )
195
216
  when 403
196
- raise Adyen::PermissionError.new("Missing user permissions; https://docs.adyen.com/user-management/user-roles", request_data, response.body)
217
+ raise Adyen::PermissionError.new('Missing user permissions; https://docs.adyen.com/user-management/user-roles',
218
+ request_data, response.body)
197
219
  end
198
-
220
+
199
221
  # delete has no response.body (unless it throws an error)
200
- if response.body == nil
201
- formatted_response = AdyenResult.new("{}", response.headers, response.status)
222
+ if response.body.nil? || response.body === ''
223
+ AdyenResult.new('{}', response.headers, response.status)
202
224
  else
203
- formatted_response = AdyenResult.new(response.body, response.headers, response.status)
225
+ AdyenResult.new(response.body, response.headers, response.status)
204
226
  end
205
-
206
- formatted_response
207
227
  end
208
228
 
209
-
210
229
  # services
211
230
  def checkout
212
231
  @checkout ||= Adyen::Checkout.new(self)
@@ -259,13 +278,14 @@ module Adyen
259
278
  def management
260
279
  @management ||= Adyen::Management.new(self)
261
280
  end
262
-
281
+
263
282
  def stored_value
264
- @stored_value ||=Adyen::StoredValue.new(self)
283
+ @stored_value ||= Adyen::StoredValue.new(self)
265
284
  end
266
285
 
267
286
  def balance_control_service
268
- @balance_control_service ||=Adyen::BalanceControlService.new(self)
287
+ @balance_control_service ||= Adyen::BalanceControlService.new(self)
269
288
  end
270
289
  end
271
290
  end
291
+ # rubocop:enable all