Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/adyen/services/balancePlatform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative 'balancePlatform/balances_api'
require_relative 'balancePlatform/bank_account_validation_api'
require_relative 'balancePlatform/card_orders_api'
require_relative 'balancePlatform/direct_debit_mandates_api'
require_relative 'balancePlatform/grant_accounts_api'
require_relative 'balancePlatform/grant_offers_api'
require_relative 'balancePlatform/manage_card_pin_api'
Expand Down Expand Up @@ -59,6 +60,10 @@ def card_orders_api
@card_orders_api ||= Adyen::CardOrdersApi.new(@client, @version)
end

def direct_debit_mandates_api
@direct_debit_mandates_api ||= Adyen::DirectDebitMandatesApi.new(@client, @version)
end

def grant_accounts_api
@grant_accounts_api ||= Adyen::GrantAccountsApi.new(@client, @version)
end
Expand Down
10 changes: 10 additions & 0 deletions lib/adyen/services/balancePlatform/account_holders_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ def get_tax_form(id, headers: {}, query_params: {})
@client.call_adyen_api(@service, action, {}, headers, @version)
end

# Get summary of tax forms for an account holder
def get_tax_form_summary(id, headers: {}, query_params: {})
endpoint = '/accountHolders/{id}/taxFormSummary'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint, id)
Comment thread
gcatanese marked this conversation as resolved.
endpoint += create_query_string(query_params)
Comment thread
gcatanese marked this conversation as resolved.
action = { method: 'get', url: endpoint }
@client.call_adyen_api(@service, action, {}, headers, @version)
end

# Update an account holder
def update_account_holder(request, id, headers: {})
endpoint = '/accountHolders/{id}'.gsub(/{.+?}/, '%s')
Expand Down
56 changes: 56 additions & 0 deletions lib/adyen/services/balancePlatform/direct_debit_mandates_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require_relative '../service'
module Adyen

# NOTE: This class is auto generated by OpenAPI Generator
# Ref: https://openapi-generator.tech
#
# Do not edit the class manually.
class DirectDebitMandatesApi < Service
attr_accessor :service, :version

def initialize(client, version = DEFAULT_VERSION)
super(client, version, 'BalancePlatform')
end

# Cancel a mandate
def cancel_mandate(mandate_id, headers: {})
endpoint = '/mandates/{mandateId}/cancel'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint, mandate_id)

action = { method: 'post', url: endpoint }
@client.call_adyen_api(@service, action, {}, headers, @version)
end

# Get a list of mandates
def get_list_of_mandates(headers: {}, query_params: {})
endpoint = '/mandates'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint)
endpoint += create_query_string(query_params)
action = { method: 'get', url: endpoint }
@client.call_adyen_api(@service, action, {}, headers, @version)
end

# Get a specific mandate
def get_mandate_by_id(mandate_id, headers: {})
endpoint = '/mandates/{mandateId}'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint, mandate_id)

action = { method: 'get', url: endpoint }
@client.call_adyen_api(@service, action, {}, headers, @version)
end

# Amend a mandate
def update_mandate(request, mandate_id, headers: {})
endpoint = '/mandates/{mandateId}'.gsub(/{.+?}/, '%s')
endpoint = endpoint.gsub(%r{^/}, '')
endpoint = format(endpoint, mandate_id)

action = { method: 'patch', url: endpoint }
@client.call_adyen_api(@service, action, request, headers, @version)
end

end
end
8 changes: 8 additions & 0 deletions sdk-generation-log/balanceplatform.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"service": "balanceplatform",
"project": "ruby",
"generatedAt": "2026-04-15T07:56:05Z",
"openapiCommitSha": "3550ecd3f320efaad6bee55ffed5122cb9ba09d5",
"automationCommitSha": "1ceda93a33430aa189b6141d5f6ea2e61051c7fd",
"libraryCommitSha": "ec1c835aada9f1a2fd35cd40bd3ef58f72156799"
}
111 changes: 111 additions & 0 deletions spec/balance_platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,117 @@
expect(response_hash).to be_a_kind_of Hash
end

it 'makes a get_tax_form_summary GET call' do
response_body = json_from_file('mocks/responses/BalancePlatform/get_tax_form_summary.json')
account_holder_id = 'AH3227C223222C5GKR23686TF'

url = @shared_values[:client].service_url(
@shared_values[:service],
"accountHolders/#{account_holder_id}/taxFormSummary",
@shared_values[:client].balance_platform.version
)
WebMock.stub_request(:get, url)
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
.to_return(body: response_body)

result = @shared_values[:client].balance_platform.account_holders_api
.get_tax_form_summary(account_holder_id)
response_hash = result.response

expect(result.status).to eq(200)
expect(response_hash).to eq(JSON.parse(response_body))
expect(response_hash).to be_a Adyen::HashWithAccessors
expect(response_hash).to be_a_kind_of Hash
end

## directDebitMandates
it 'makes a get_list_of_mandates GET call' do
response_body = json_from_file('mocks/responses/BalancePlatform/get_list_of_mandates.json')

url = @shared_values[:client].service_url(
@shared_values[:service],
'mandates',
@shared_values[:client].balance_platform.version
)
WebMock.stub_request(:get, url)
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
.to_return(body: response_body)

result = @shared_values[:client].balance_platform.direct_debit_mandates_api.get_list_of_mandates
response_hash = result.response

expect(result.status).to eq(200)
expect(response_hash).to eq(JSON.parse(response_body))
expect(response_hash).to be_a Adyen::HashWithAccessors
expect(response_hash).to be_a_kind_of Hash
end

it 'makes a get_mandate_by_id GET call' do
response_body = json_from_file('mocks/responses/BalancePlatform/get_mandate_by_id.json')
mandate_id = 'MNDT7QXPLKT9R333640TX334709E'

url = @shared_values[:client].service_url(
@shared_values[:service],
"mandates/#{mandate_id}",
@shared_values[:client].balance_platform.version
)
WebMock.stub_request(:get, url)
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
.to_return(body: response_body)

result = @shared_values[:client].balance_platform.direct_debit_mandates_api.get_mandate_by_id(mandate_id)
response_hash = result.response

expect(result.status).to eq(200)
expect(response_hash).to eq(JSON.parse(response_body))
expect(response_hash).to be_a Adyen::HashWithAccessors
expect(response_hash).to be_a_kind_of Hash
end

it 'makes a cancel_mandate POST call' do
mandate_id = 'MNDT7QXPLKT9R333640TX334709E'

url = @shared_values[:client].service_url(
@shared_values[:service],
"mandates/#{mandate_id}/cancel",
@shared_values[:client].balance_platform.version
)
WebMock.stub_request(:post, url)
.with(headers: { 'x-api-key' => @shared_values[:client].api_key })
.to_return(status: 202, body: '')

result = @shared_values[:client].balance_platform.direct_debit_mandates_api.cancel_mandate(mandate_id)

expect(result.status).to eq(202)
end

it 'makes an update_mandate PATCH call' do
request_body = JSON.parse(json_from_file('mocks/requests/BalancePlatform/update_mandate.json'))
response_body = json_from_file('mocks/responses/BalancePlatform/get_mandate_by_id.json')
mandate_id = 'MNDT7QXPLKT9R333640TX334709E'

url = @shared_values[:client].service_url(
@shared_values[:service],
"mandates/#{mandate_id}",
@shared_values[:client].balance_platform.version
)
WebMock.stub_request(:patch, url)
.with(
body: request_body,
headers: { 'x-api-key' => @shared_values[:client].api_key }
)
.to_return(body: response_body)

result = @shared_values[:client].balance_platform.direct_debit_mandates_api
.update_mandate(request_body, mandate_id)
response_hash = result.response

expect(result.status).to eq(200)
expect(response_hash).to eq(JSON.parse(response_body))
expect(response_hash).to be_a Adyen::HashWithAccessors
expect(response_hash).to be_a_kind_of Hash
end

## authorisedCardUsers
it 'makes a get_all_authorised_card_users GET call' do
response_body = json_from_file('mocks/responses/BalancePlatform/get_all_authorised_card_users.json')
Expand Down
14 changes: 14 additions & 0 deletions spec/mocks/requests/BalancePlatform/update_mandate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "MNDT7QXPLKT9R333640TX334709E",
"type": "bacs",
"balanceAccountId": "BA43EKD334339T6N8X655DW77",
"paymentInstrumentId": "PI43EKK334339T6N8X65688CS",
"status": "approved",
"counterparty": {
"accountHolder": {
"fullName": "Example Merchant Ltd"
}
},
"createdAt": "2026-02-23T13:04:15.683Z",
"updatedAt": "2026-02-23T13:04:15.683Z"
}
19 changes: 19 additions & 0 deletions spec/mocks/responses/BalancePlatform/get_list_of_mandates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"mandates": [
{
"id": "MNDT7QXPLKT9R333640TX334709E",
"type": "bacs",
"balanceAccountId": "BA43EKD334339T6N8X655DW77",
"paymentInstrumentId": "PI43EKK334339T6N8X65688CS",
"status": "approved",
"counterparty": {
"accountHolder": {
"fullName": "Example Merchant Ltd"
}
},
"createdAt": "2026-02-23T13:04:15.683Z",
"updatedAt": "2026-02-23T13:04:15.683Z"
}
],
"itemsTotal": 1
}
14 changes: 14 additions & 0 deletions spec/mocks/responses/BalancePlatform/get_mandate_by_id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "MNDT7QXPLKT9R333640TX334709E",
"type": "bacs",
"balanceAccountId": "BA43EKD334339T6N8X655DW77",
"paymentInstrumentId": "PI43EKK334339T6N8X65688CS",
"status": "approved",
"counterparty": {
"accountHolder": {
"fullName": "Example Merchant Ltd"
}
},
"createdAt": "2026-02-23T13:04:15.683Z",
"updatedAt": "2026-02-23T13:04:15.683Z"
}
17 changes: 17 additions & 0 deletions spec/mocks/responses/BalancePlatform/get_tax_form_summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": [
{
"legalEntityId": "LE123",
"taxYears": [
2023
]
},
{
"legalEntityId": "LE987",
"taxYears": [
2024,
2025
]
}
]
}
Loading