adyen-ruby-api-library 11.0.0 → 11.2.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql.yml +4 -4
  3. data/.github/workflows/label_new_issues.yml +1 -1
  4. data/.github/workflows/release.yml +2 -2
  5. data/.github/workflows/ruby.yml +11 -3
  6. data/.github/workflows/rubygems_release.yml +2 -2
  7. data/.github/workflows/stale.yml +1 -1
  8. data/AGENTS.md +73 -0
  9. data/README.md +5 -0
  10. data/VERSION +1 -1
  11. data/lib/adyen/client.rb +30 -9
  12. data/lib/adyen/errors.rb +6 -0
  13. data/lib/adyen/services/balancePlatform/sca_association_management_api.rb +46 -0
  14. data/lib/adyen/services/balancePlatform/sca_device_management_api.rb +46 -0
  15. data/lib/adyen/services/balancePlatform.rb +10 -0
  16. data/lib/adyen/services/capital/grant_accounts_api.rb +26 -0
  17. data/lib/adyen/services/capital/grant_offers_api.rb +36 -0
  18. data/lib/adyen/services/capital/grants_api.rb +76 -0
  19. data/lib/adyen/services/capital.rb +34 -0
  20. data/lib/adyen/services/checkout/recurring_api.rb +10 -0
  21. data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +10 -0
  22. data/lib/adyen/services/payment/modifications_api.rb +1 -1
  23. data/lib/adyen/services/payment/payments_api.rb +1 -1
  24. data/lib/adyen/services/payment.rb +2 -2
  25. data/lib/adyen/services/recurring/recurring_api.rb +1 -1
  26. data/lib/adyen/services/recurring.rb +1 -1
  27. data/lib/adyen/version.rb +1 -1
  28. data/lib/adyen-ruby-api-library.rb +1 -0
  29. data/renovate.json +3 -1
  30. data/spec/capital_spec.rb +186 -0
  31. data/spec/checkout_spec.rb +13 -0
  32. data/spec/client_spec.rb +235 -64
  33. data/spec/data_protection_spec.rb +2 -2
  34. data/spec/disputes_spec.rb +3 -3
  35. data/spec/lem_spec.rb +75 -0
  36. data/spec/mocks/responses/Capital/get-grant-account-success.json +20 -0
  37. data/spec/mocks/responses/Capital/get-grant-disbursement-success.json +26 -0
  38. data/spec/mocks/responses/Capital/get-grant-disbursements-success.json +30 -0
  39. data/spec/mocks/responses/Capital/get-grant-offer-success.json +31 -0
  40. data/spec/mocks/responses/Capital/get-grant-success.json +22 -0
  41. data/spec/mocks/responses/Capital/grant-offers-success.json +19 -0
  42. data/spec/mocks/responses/Capital/grants-success.json +26 -0
  43. data/spec/mocks/responses/Capital/request-grant.json +31 -0
  44. data/spec/mocks/responses/Capital/update-grant-disbursement-success.json +26 -0
  45. data/spec/mocks/responses/LegalEntityManagement/get_legal_entity.json +14 -0
  46. data/templates/api-single.mustache +1 -1
  47. data/templates/api.mustache +1 -1
  48. metadata +23 -6
  49. data/Makefile +0 -79
  50. /data/spec/mocks/requests/{DataProtectionService → DataProtection}/request_subject_erasure.json +0 -0
  51. /data/spec/mocks/requests/{DisputesService → Disputes}/retrieve_applicable_defense_reasons.json +0 -0
  52. /data/spec/mocks/responses/{DataProtectionService → DataProtection}/request_subject_erasure.json +0 -0
  53. /data/spec/mocks/responses/{DisputesService → Disputes}/retrieve_applicable_defense_reasons.json +0 -0
@@ -62,6 +62,16 @@ module Adyen
62
62
  @client.call_adyen_api(@service, action, {}, headers, @version)
63
63
  end
64
64
 
65
+ # Request periodic data review.
66
+ def request_periodic_review(id, headers: {})
67
+ endpoint = '/legalEntities/{id}/requestPeriodicReview'.gsub(/{.+?}/, '%s')
68
+ endpoint = endpoint.gsub(%r{^/}, '')
69
+ endpoint = format(endpoint, id)
70
+
71
+ action = { method: 'post', url: endpoint }
72
+ @client.call_adyen_api(@service, action, {}, headers, @version)
73
+ end
74
+
65
75
  # Update a legal entity
66
76
  def update_legal_entity(request, id, headers: {})
67
77
  endpoint = '/legalEntities/{id}'.gsub(/{.+?}/, '%s')
@@ -5,7 +5,7 @@ module Adyen
5
5
  # Ref: https://openapi-generator.tech
6
6
  #
7
7
  # Do not edit the class manually.
8
- class ModificationsApi < Service
8
+ class ClassicModificationsApi < Service
9
9
  attr_accessor :service, :version
10
10
 
11
11
  def initialize(client, version = DEFAULT_VERSION)
@@ -5,7 +5,7 @@ module Adyen
5
5
  # Ref: https://openapi-generator.tech
6
6
  #
7
7
  # Do not edit the class manually.
8
- class PaymentsApi < Service
8
+ class ClassicPaymentsApi < Service
9
9
  attr_accessor :service, :version
10
10
 
11
11
  def initialize(client, version = DEFAULT_VERSION)
@@ -18,11 +18,11 @@ module Adyen
18
18
  end
19
19
 
20
20
  def modifications_api
21
- @modifications_api ||= Adyen::ModificationsApi.new(@client, @version)
21
+ @modifications_api ||= Adyen::ClassicModificationsApi.new(@client, @version)
22
22
  end
23
23
 
24
24
  def payments_api
25
- @payments_api ||= Adyen::PaymentsApi.new(@client, @version)
25
+ @payments_api ||= Adyen::ClassicPaymentsApi.new(@client, @version)
26
26
  end
27
27
 
28
28
  end
@@ -5,7 +5,7 @@ module Adyen
5
5
  # Ref: https://openapi-generator.tech
6
6
  #
7
7
  # Do not edit the class manually.
8
- class RecurringApi < Service
8
+ class LegacyRecurringApi < Service
9
9
  attr_accessor :service, :version
10
10
 
11
11
  def initialize(client, version = DEFAULT_VERSION)
@@ -17,7 +17,7 @@ module Adyen
17
17
  end
18
18
 
19
19
  def recurring_api
20
- @recurring_api ||= Adyen::RecurringApi.new(@client, @version)
20
+ @recurring_api ||= Adyen::LegacyRecurringApi.new(@client, @version)
21
21
  end
22
22
 
23
23
  end
data/lib/adyen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Adyen
2
2
  NAME = 'adyen-ruby-api-library'.freeze
3
- VERSION = '11.0.0'.freeze
3
+ VERSION = '11.2.0'.freeze
4
4
  end
@@ -23,4 +23,5 @@ require_relative 'adyen/services/posMobile'
23
23
  require_relative 'adyen/services/openBanking'
24
24
  require_relative 'adyen/services/sessionAuthentication'
25
25
  require_relative 'adyen/services/balanceControl'
26
+ require_relative 'adyen/services/capital'
26
27
 
data/renovate.json CHANGED
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": ["config:base"],
3
+ "extends": [
4
+ "config:recommended"
5
+ ],
4
6
  "minimumReleaseAge": "21 days"
5
7
  }
@@ -0,0 +1,186 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ RSpec.describe Adyen::Capital do
5
+ let(:client) { create_client(:api_key) }
6
+ let(:service) { 'Capital' }
7
+ let(:version) { client.capital.version }
8
+
9
+ describe 'GrantAccountsApi' do
10
+ it 'gets grant account information' do
11
+ response_body = json_from_file('mocks/responses/Capital/get-grant-account-success.json')
12
+ grant_account_id = 'CG00000000000000000000001'
13
+
14
+ url = client.service_url(service, "grantAccounts/#{grant_account_id}", version)
15
+
16
+ WebMock.stub_request(:get, url)
17
+ .with(headers: { 'x-api-key' => client.api_key })
18
+ .to_return(body: response_body)
19
+
20
+ result = client.capital.grant_accounts_api.get_grant_account_information(grant_account_id)
21
+
22
+ expect(result.status).to eq(200)
23
+ expect(result.response).to eq(JSON.parse(response_body))
24
+ expect(result.response).to be_a(Adyen::HashWithAccessors)
25
+ expect(result.response).to be_a(Hash)
26
+ end
27
+ end
28
+
29
+ describe 'GrantOffersApi' do
30
+ it 'gets all grant offers with query params' do
31
+ response_body = json_from_file('mocks/responses/Capital/grant-offers-success.json')
32
+ account_holder_id = 'AH00000000000000000000001'
33
+
34
+ url = client.service_url(service, 'grantOffers', version)
35
+
36
+ WebMock.stub_request(:get, url)
37
+ .with(
38
+ query: { 'accountHolderId' => account_holder_id },
39
+ headers: { 'x-api-key' => client.api_key }
40
+ )
41
+ .to_return(body: response_body)
42
+
43
+ result = client.capital.grant_offers_api.get_all_grant_offers(query_params: { 'accountHolderId' => account_holder_id })
44
+
45
+ expect(result.status).to eq(200)
46
+ expect(result.response).to eq(JSON.parse(response_body))
47
+ end
48
+
49
+ it 'gets all grant offers without query params' do
50
+ response_body = json_from_file('mocks/responses/Capital/grant-offers-success.json')
51
+
52
+ url = client.service_url(service, 'grantOffers', version)
53
+
54
+ WebMock.stub_request(:get, url)
55
+ .with(headers: { 'x-api-key' => client.api_key })
56
+ .to_return(body: response_body)
57
+
58
+ result = client.capital.grant_offers_api.get_all_grant_offers
59
+
60
+ expect(result.status).to eq(200)
61
+ expect(result.response).to eq(JSON.parse(response_body))
62
+ end
63
+
64
+ it 'gets a specific grant offer' do
65
+ response_body = json_from_file('mocks/responses/Capital/get-grant-offer-success.json')
66
+ id = 'GO00000000000000000000001'
67
+
68
+ url = client.service_url(service, "grantOffers/#{id}", version)
69
+
70
+ WebMock.stub_request(:get, url)
71
+ .with(headers: { 'x-api-key' => client.api_key })
72
+ .to_return(body: response_body)
73
+
74
+ result = client.capital.grant_offers_api.get_grant_offer(id)
75
+
76
+ expect(result.status).to eq(200)
77
+ expect(result.response).to eq(JSON.parse(response_body))
78
+ end
79
+ end
80
+
81
+ describe 'GrantsApi' do
82
+ it 'gets a specific grant' do
83
+ response_body = json_from_file('mocks/responses/Capital/get-grant-success.json')
84
+ id = 'GR00000000000000000000001'
85
+
86
+ url = client.service_url(service, "grants/#{id}", version)
87
+
88
+ WebMock.stub_request(:get, url)
89
+ .with(headers: { 'x-api-key' => client.api_key })
90
+ .to_return(body: response_body)
91
+
92
+ result = client.capital.grants_api.get_grant(id)
93
+
94
+ expect(result.status).to eq(200)
95
+ expect(result.response).to eq(JSON.parse(response_body))
96
+ end
97
+
98
+ it 'gets all grants' do
99
+ response_body = json_from_file('mocks/responses/Capital/grants-success.json')
100
+
101
+ url = client.service_url(service, 'grants', version)
102
+
103
+ WebMock.stub_request(:get, url)
104
+ .with(headers: { 'x-api-key' => client.api_key })
105
+ .to_return(body: response_body)
106
+
107
+ result = client.capital.grants_api.get_all_grants
108
+
109
+ expect(result.status).to eq(200)
110
+ expect(result.response).to eq(JSON.parse(response_body))
111
+ end
112
+
113
+ it 'requests a grant' do
114
+ request_payload = { "grantAccountId" => "GR00000000000000000000001" }
115
+ response_body = json_from_file('mocks/responses/Capital/request-grant.json')
116
+
117
+ url = client.service_url(service, 'grants', version)
118
+
119
+ WebMock.stub_request(:post, url)
120
+ .with(
121
+ body: request_payload,
122
+ headers: { 'x-api-key' => client.api_key }
123
+ )
124
+ .to_return(body: response_body)
125
+
126
+ result = client.capital.grants_api.request_grant(request_payload)
127
+
128
+ expect(result.status).to eq(200)
129
+ expect(result.response).to eq(JSON.parse(response_body))
130
+ end
131
+
132
+ it 'gets a grant disbursement' do
133
+ response_body = json_from_file('mocks/responses/Capital/get-grant-disbursement-success.json')
134
+ grant_id = 'GR00000000000000000000001'
135
+ disbursement_id = 'DI00000000000000000000001'
136
+
137
+ url = client.service_url(service, "grants/#{grant_id}/disbursements/#{disbursement_id}", version)
138
+
139
+ WebMock.stub_request(:get, url)
140
+ .with(headers: { 'x-api-key' => client.api_key })
141
+ .to_return(body: response_body)
142
+
143
+ result = client.capital.grants_api.get_grant_disbursement(grant_id, disbursement_id)
144
+
145
+ expect(result.status).to eq(200)
146
+ expect(result.response).to eq(JSON.parse(response_body))
147
+ end
148
+
149
+ it 'gets all grant disbursements' do
150
+ response_body = json_from_file('mocks/responses/Capital/get-grant-disbursements-success.json')
151
+ grant_id = 'GR00000000000000000000001'
152
+
153
+ url = client.service_url(service, "grants/#{grant_id}/disbursements", version)
154
+
155
+ WebMock.stub_request(:get, url)
156
+ .with(headers: { 'x-api-key' => client.api_key })
157
+ .to_return(body: response_body)
158
+
159
+ result = client.capital.grants_api.get_all_grant_disbursements(grant_id)
160
+
161
+ expect(result.status).to eq(200)
162
+ expect(result.response).to eq(JSON.parse(response_body))
163
+ end
164
+
165
+ it 'updates a grant disbursement' do
166
+ response_body = json_from_file('mocks/responses/Capital/update-grant-disbursement-success.json')
167
+ grant_id = 'GR00000000000000000000001'
168
+ disbursement_id = 'DI00000000000000000000001'
169
+ request_payload = {}
170
+
171
+ url = client.service_url(service, "grants/#{grant_id}/disbursements/#{disbursement_id}", version)
172
+
173
+ WebMock.stub_request(:patch, url)
174
+ .with(
175
+ body: request_payload,
176
+ headers: { 'x-api-key' => client.api_key }
177
+ )
178
+ .to_return(body: response_body)
179
+
180
+ result = client.capital.grants_api.update_grant_disbursement(request_payload, grant_id, disbursement_id)
181
+
182
+ expect(result.status).to eq(200)
183
+ expect(result.response).to eq(JSON.parse(response_body))
184
+ end
185
+ end
186
+ end
@@ -8,6 +8,19 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
8
8
  service: 'Checkout'
9
9
  }
10
10
  end
11
+
12
+ it 'uses the correct PaymentsApi for the Checkout service' do
13
+ # Load both API files to ensure there's no conflict after the fix.
14
+ load File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__)
15
+ load File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__)
16
+
17
+ checkout = Adyen::Checkout.new(@shared_values[:client])
18
+ payments_api = checkout.payments_api
19
+
20
+ # Verify that the Checkout facade uses the correct PaymentsApi class.
21
+ expect(payments_api.class.name).to eq('Adyen::PaymentsApi')
22
+ expect(payments_api.service).to eq('Checkout')
23
+ end
11
24
 
12
25
  # must be created manually because every field in the response is an array
13
26
  it 'makes a payment_methods call' do