From 6f6b5fb8be67c6e0c880cd032346308ccae7faff Mon Sep 17 00:00:00 2001 From: Robot Date: Fri, 25 Jul 2025 14:51:34 +0000 Subject: [PATCH 1/9] Changes from gocardless/gocardless-pro-ruby-template@e25b52725d4b4d2c44f10d0316ab5c4b7ecd93a6 --- .../creditor_bank_accounts_service.rb | 35 ++++++++ spec/resources/creditor_bank_account_spec.rb | 73 ++++++++++++++++ .../creditor_bank_accounts_service_spec.rb | 84 +++++++++++++++++++ 3 files changed, 192 insertions(+) diff --git a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb index aefd047..885f138 100644 --- a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +++ b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb @@ -139,6 +139,41 @@ def disable(identity, options = {}) Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) end + # Validate bank details without creating a creditor bank account + # Example URL: /creditor_bank_accounts/validate + # @param options [Hash] parameters as a hash, under a params key. + def validate(options = {}) + path = '/creditor_bank_accounts/validate' + + params = options.delete(:params) || {} + options[:params] = {} + options[:params]['data'] = params + + options[:retry_failures] = false + + begin + response = make_request(:post, path, options) + + # Response doesn't raise any errors until #body is called + response.tap(&:body) + rescue InvalidStateError => e + if e.idempotent_creation_conflict? + case @api_service.on_idempotency_conflict + when :raise + raise IdempotencyConflict, e.error + when :fetch + return get(e.conflicting_resource_id) + end + end + + raise e + end + + return if response.body.nil? + + Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) + end + private # Unenvelope the response of the body using the service's `envelope_key` diff --git a/spec/resources/creditor_bank_account_spec.rb b/spec/resources/creditor_bank_account_spec.rb index 8dbe288..f526571 100644 --- a/spec/resources/creditor_bank_account_spec.rb +++ b/spec/resources/creditor_bank_account_spec.rb @@ -484,4 +484,77 @@ end end end + + describe '#validate' do + subject(:post_response) { client.creditor_bank_accounts.validate } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + + headers: response_headers + ) + end + + it 'wraps the response and calls the right endpoint' do + expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) + + expect(stub).to have_been_requested + end + + context 'when the request needs a body and custom header' do + subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .with( + body: { foo: 'bar' }, + headers: { 'Foo' => 'Bar' } + ).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + headers: response_headers + ) + end + end + end end diff --git a/spec/services/creditor_bank_accounts_service_spec.rb b/spec/services/creditor_bank_accounts_service_spec.rb index dc2eae6..a1009ac 100644 --- a/spec/services/creditor_bank_accounts_service_spec.rb +++ b/spec/services/creditor_bank_accounts_service_spec.rb @@ -741,4 +741,88 @@ end end end + + describe '#validate' do + subject(:post_response) { client.creditor_bank_accounts.validate } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + + headers: response_headers + ) + end + + it 'wraps the response and calls the right endpoint' do + expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) + + expect(stub).to have_been_requested + end + + describe 'retry behaviour' do + it "doesn't retry errors" do + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .to_timeout + + expect { post_response }.to raise_error(Faraday::ConnectionFailed) + expect(stub).to have_been_requested + end + end + + context 'when the request needs a body and custom header' do + subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .with( + body: { foo: 'bar' }, + headers: { 'Foo' => 'Bar' } + ).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + headers: response_headers + ) + end + end + end end From 2bf569a41c0af00ef552a7abcdaa5238d2c5095d Mon Sep 17 00:00:00 2001 From: Robot Date: Mon, 28 Jul 2025 13:18:42 +0000 Subject: [PATCH 2/9] Changes from gocardless/gocardless-pro-ruby-template@9e72a7bf0250b46188bb82cce86854a52a420c65 --- lib/gocardless_pro/services/scenario_simulators_service.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/gocardless_pro/services/scenario_simulators_service.rb b/lib/gocardless_pro/services/scenario_simulators_service.rb index 0b7e946..abe9802 100644 --- a/lib/gocardless_pro/services/scenario_simulators_service.rb +++ b/lib/gocardless_pro/services/scenario_simulators_service.rb @@ -132,6 +132,12 @@ class ScenarioSimulatorsService < BaseService # `failed`. The billing request must be in the `pending` state, with all # actions completed except for `bank_authorisation`. Only billing requests # with a `payment_request` are supported. + #
  • `billing_request_fulfilled_and_payment_confirmed_to_failed`: + # Authorises the billing request, fulfils it, moves the associated payment + # to `confirmed` and then moves it to `failed`. The billing request must + # be in the `pending` state, with all actions completed except for + # `bank_authorisation`. Only billing requests with a `payment_request` are + # supported.
  • #
  • `billing_request_fulfilled_and_payment_paid_out`: Authorises the # billing request, fulfils it, and moves the associated payment to # `paid_out`. The billing request must be in the `pending` state, with all From ac35400851bcd559d435829cd4efd448b566997b Mon Sep 17 00:00:00 2001 From: Robot Date: Mon, 18 Aug 2025 09:15:39 +0000 Subject: [PATCH 3/9] Changes from gocardless/gocardless-pro-ruby-template@fc93c9ab92cb3c11e2bfbd3d91e6b683a1f3df2d --- lib/gocardless_pro/resources/payment.rb | 3 ++- spec/resources/payment_spec.rb | 17 +++++++++++++++++ spec/services/payments_service_spec.rb | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/gocardless_pro/resources/payment.rb b/lib/gocardless_pro/resources/payment.rb index 56a82cd..2cf595d 100644 --- a/lib/gocardless_pro/resources/payment.rb +++ b/lib/gocardless_pro/resources/payment.rb @@ -19,7 +19,7 @@ module Resources # the state of a payment changes. class Payment attr_reader :amount, :amount_refunded, :charge_date, :created_at, :currency, :description, :faster_ach, :fx, :id, - :metadata, :reference, :retry_if_possible, :status + :metadata, :reference, :retry_if_possible, :scheme, :status # Initialize a payment resource instance # @param object [Hash] an object returned from the API @@ -39,6 +39,7 @@ def initialize(object, response = nil) @metadata = object['metadata'] @reference = object['reference'] @retry_if_possible = object['retry_if_possible'] + @scheme = object['scheme'] @status = object['status'] @response = response end diff --git a/spec/resources/payment_spec.rb b/spec/resources/payment_spec.rb index 4dbdfac..c005c17 100644 --- a/spec/resources/payment_spec.rb +++ b/spec/resources/payment_spec.rb @@ -28,6 +28,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } end @@ -51,6 +52,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } } @@ -74,6 +76,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } @@ -130,6 +133,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } end @@ -176,6 +180,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -213,6 +218,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -253,6 +259,8 @@ expect(get_list_response.records.first.retry_if_possible).to eq('retry_if_possible-input') + expect(get_list_response.records.first.scheme).to eq('scheme-input') + expect(get_list_response.records.first.status).to eq('status-input') end @@ -284,6 +292,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -313,6 +322,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -358,6 +368,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -397,6 +408,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -458,6 +470,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -497,6 +510,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -542,6 +556,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -576,6 +591,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -621,6 +637,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, diff --git a/spec/services/payments_service_spec.rb b/spec/services/payments_service_spec.rb index c0a6908..689852c 100644 --- a/spec/services/payments_service_spec.rb +++ b/spec/services/payments_service_spec.rb @@ -28,6 +28,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } end @@ -51,6 +52,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } } @@ -74,6 +76,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } @@ -153,6 +156,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } end @@ -199,6 +203,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -251,6 +256,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -296,6 +302,8 @@ expect(get_list_response.records.first.retry_if_possible).to eq('retry_if_possible-input') + expect(get_list_response.records.first.scheme).to eq('scheme-input') + expect(get_list_response.records.first.status).to eq('status-input') end @@ -350,6 +358,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -379,6 +388,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -417,6 +427,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -446,6 +457,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -480,6 +492,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -512,6 +525,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' }], meta: { @@ -557,6 +571,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -596,6 +611,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -712,6 +728,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -776,6 +793,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -832,6 +850,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -866,6 +885,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, @@ -922,6 +942,7 @@ 'metadata' => 'metadata-input', 'reference' => 'reference-input', 'retry_if_possible' => 'retry_if_possible-input', + 'scheme' => 'scheme-input', 'status' => 'status-input' } }.to_json, From be256c7bedfe0e76434c701e1175393e33e13bdc Mon Sep 17 00:00:00 2001 From: Robot Date: Tue, 26 Aug 2025 14:19:13 +0000 Subject: [PATCH 4/9] Changes from gocardless/gocardless-pro-ruby-template@84e052fbe4f9520df5de050a5529032610382235 --- lib/gocardless_pro.rb | 3 + lib/gocardless_pro/client.rb | 5 ++ .../creditor_bank_account_validate.rb | 50 +++++++++++ ...creditor_bank_account_validates_service.rb | 47 +++++++++++ .../creditor_bank_accounts_service.rb | 35 -------- spec/resources/creditor_bank_account_spec.rb | 73 ---------------- .../creditor_bank_account_validate_spec.rb | 68 +++++++++++++++ ...tor_bank_account_validates_service_spec.rb | 79 +++++++++++++++++ .../creditor_bank_accounts_service_spec.rb | 84 ------------------- 9 files changed, 252 insertions(+), 192 deletions(-) create mode 100644 lib/gocardless_pro/resources/creditor_bank_account_validate.rb create mode 100644 lib/gocardless_pro/services/creditor_bank_account_validates_service.rb create mode 100644 spec/resources/creditor_bank_account_validate_spec.rb create mode 100644 spec/services/creditor_bank_account_validates_service_spec.rb diff --git a/lib/gocardless_pro.rb b/lib/gocardless_pro.rb index 0f372d3..3d60870 100644 --- a/lib/gocardless_pro.rb +++ b/lib/gocardless_pro.rb @@ -72,6 +72,9 @@ module GoCardlessPro require_relative 'gocardless_pro/resources/creditor_bank_account' require_relative 'gocardless_pro/services/creditor_bank_accounts_service' +require_relative 'gocardless_pro/resources/creditor_bank_account_validate' +require_relative 'gocardless_pro/services/creditor_bank_account_validates_service' + require_relative 'gocardless_pro/resources/currency_exchange_rate' require_relative 'gocardless_pro/services/currency_exchange_rates_service' diff --git a/lib/gocardless_pro/client.rb b/lib/gocardless_pro/client.rb index 9f49d77..7f032e2 100644 --- a/lib/gocardless_pro/client.rb +++ b/lib/gocardless_pro/client.rb @@ -58,6 +58,11 @@ def creditor_bank_accounts @creditor_bank_accounts ||= Services::CreditorBankAccountsService.new(@api_service) end + # Access to the service for creditor_bank_account_validate to make API calls + def creditor_bank_account_validates + @creditor_bank_account_validates ||= Services::CreditorBankAccountValidatesService.new(@api_service) + end + # Access to the service for currency_exchange_rate to make API calls def currency_exchange_rates @currency_exchange_rates ||= Services::CurrencyExchangeRatesService.new(@api_service) diff --git a/lib/gocardless_pro/resources/creditor_bank_account_validate.rb b/lib/gocardless_pro/resources/creditor_bank_account_validate.rb new file mode 100644 index 0000000..243a361 --- /dev/null +++ b/lib/gocardless_pro/resources/creditor_bank_account_validate.rb @@ -0,0 +1,50 @@ +# +# This client is automatically generated from a template and JSON schema definition. +# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing. +# + +require 'uri' + +module GoCardlessPro + # A module containing classes for each of the resources in the GC Api + module Resources + # Represents an instance of a creditor_bank_account_validate resource returned from the API + + # Creditor Bank Accounts hold the bank details of a + # [creditor](#core-endpoints-creditors). These are the bank accounts which + # your [payouts](#core-endpoints-payouts) will be sent to. + # + # When all locale details and Iban are supplied validates creditor bank + # details without creating a creditor bank account and also provdes bank + # details such as name and icon url. When partial details are are provided + # the endpoint will only provide bank details such as name and icon url but + # will not be able to determine if the provided details are valid. + # + #

    Restricted: This API is not + # available for partner integrations.

    + class CreditorBankAccountValidate + attr_reader :bank_name, :icon_url, :invalid_reasons, :is_valid + + # Initialize a creditor_bank_account_validate resource instance + # @param object [Hash] an object returned from the API + def initialize(object, response = nil) + @object = object + + @bank_name = object['bank_name'] + @icon_url = object['icon_url'] + @invalid_reasons = object['invalid_reasons'] + @is_valid = object['is_valid'] + @response = response + end + + def api_response + ApiResponse.new(@response) + end + + # Provides the creditor_bank_account_validate resource as a hash of all its readable attributes + def to_h + @object + end + end + end +end diff --git a/lib/gocardless_pro/services/creditor_bank_account_validates_service.rb b/lib/gocardless_pro/services/creditor_bank_account_validates_service.rb new file mode 100644 index 0000000..4604fe1 --- /dev/null +++ b/lib/gocardless_pro/services/creditor_bank_account_validates_service.rb @@ -0,0 +1,47 @@ +require_relative './base_service' + +# encoding: utf-8 +# +# This client is automatically generated from a template and JSON schema definition. +# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing. +# + +module GoCardlessPro + module Services + # Service for making requests to the CreditorBankAccountValidate endpoints + class CreditorBankAccountValidatesService < BaseService + # Validate bank details without creating a creditor bank account + # Example URL: /creditor_bank_accounts/validate + # @param options [Hash] parameters as a hash, under a params key. + def validate(options = {}) + path = '/creditor_bank_accounts/validate' + + params = options.delete(:params) || {} + options[:params] = {} + options[:params]['data'] = params + + options[:retry_failures] = false + + response = make_request(:post, path, options) + + return if response.body.nil? + + Resources::CreditorBankAccountValidate.new(unenvelope_body(response.body), response) + end + + private + + # Unenvelope the response of the body using the service's `envelope_key` + # + # @param body [Hash] + def unenvelope_body(body) + body[envelope_key] || body['data'] + end + + # return the key which API responses will envelope data under + def envelope_key + 'creditor_bank_accounts' + end + end + end +end diff --git a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb index 885f138..aefd047 100644 --- a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +++ b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb @@ -139,41 +139,6 @@ def disable(identity, options = {}) Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) end - # Validate bank details without creating a creditor bank account - # Example URL: /creditor_bank_accounts/validate - # @param options [Hash] parameters as a hash, under a params key. - def validate(options = {}) - path = '/creditor_bank_accounts/validate' - - params = options.delete(:params) || {} - options[:params] = {} - options[:params]['data'] = params - - options[:retry_failures] = false - - begin - response = make_request(:post, path, options) - - # Response doesn't raise any errors until #body is called - response.tap(&:body) - rescue InvalidStateError => e - if e.idempotent_creation_conflict? - case @api_service.on_idempotency_conflict - when :raise - raise IdempotencyConflict, e.error - when :fetch - return get(e.conflicting_resource_id) - end - end - - raise e - end - - return if response.body.nil? - - Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) - end - private # Unenvelope the response of the body using the service's `envelope_key` diff --git a/spec/resources/creditor_bank_account_spec.rb b/spec/resources/creditor_bank_account_spec.rb index f526571..8dbe288 100644 --- a/spec/resources/creditor_bank_account_spec.rb +++ b/spec/resources/creditor_bank_account_spec.rb @@ -484,77 +484,4 @@ end end end - - describe '#validate' do - subject(:post_response) { client.creditor_bank_accounts.validate } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - - headers: response_headers - ) - end - - it 'wraps the response and calls the right endpoint' do - expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) - - expect(stub).to have_been_requested - end - - context 'when the request needs a body and custom header' do - subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/) - .with( - body: { foo: 'bar' }, - headers: { 'Foo' => 'Bar' } - ).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - headers: response_headers - ) - end - end - end end diff --git a/spec/resources/creditor_bank_account_validate_spec.rb b/spec/resources/creditor_bank_account_validate_spec.rb new file mode 100644 index 0000000..f5f6be8 --- /dev/null +++ b/spec/resources/creditor_bank_account_validate_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper' + +describe GoCardlessPro::Resources::CreditorBankAccountValidate do + let(:client) do + GoCardlessPro::Client.new( + access_token: 'SECRET_TOKEN' + ) + end + + let(:response_headers) { { 'Content-Type' => 'application/json' } } + + describe '#validate' do + subject(:post_response) { client.creditor_bank_account_validates.validate } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( + body: { + 'creditor_bank_accounts' => { + + 'bank_name' => 'bank_name-input', + 'icon_url' => 'icon_url-input', + 'invalid_reasons' => 'invalid_reasons-input', + 'is_valid' => 'is_valid-input' + } + }.to_json, + + headers: response_headers + ) + end + + it 'wraps the response and calls the right endpoint' do + expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccountValidate) + + expect(stub).to have_been_requested + end + + context 'when the request needs a body and custom header' do + subject(:post_response) { client.creditor_bank_account_validates.validate(body, headers) } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .with( + body: { foo: 'bar' }, + headers: { 'Foo' => 'Bar' } + ).to_return( + body: { + 'creditor_bank_accounts' => { + + 'bank_name' => 'bank_name-input', + 'icon_url' => 'icon_url-input', + 'invalid_reasons' => 'invalid_reasons-input', + 'is_valid' => 'is_valid-input' + } + }.to_json, + headers: response_headers + ) + end + end + end +end diff --git a/spec/services/creditor_bank_account_validates_service_spec.rb b/spec/services/creditor_bank_account_validates_service_spec.rb new file mode 100644 index 0000000..4dff1b5 --- /dev/null +++ b/spec/services/creditor_bank_account_validates_service_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' + +describe GoCardlessPro::Services::CreditorBankAccountValidatesService do + let(:client) do + GoCardlessPro::Client.new( + access_token: 'SECRET_TOKEN' + ) + end + + let(:response_headers) { { 'Content-Type' => 'application/json' } } + + describe '#validate' do + subject(:post_response) { client.creditor_bank_account_validates.validate } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( + body: { + 'creditor_bank_accounts' => { + + 'bank_name' => 'bank_name-input', + 'icon_url' => 'icon_url-input', + 'invalid_reasons' => 'invalid_reasons-input', + 'is_valid' => 'is_valid-input' + } + }.to_json, + + headers: response_headers + ) + end + + it 'wraps the response and calls the right endpoint' do + expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccountValidate) + + expect(stub).to have_been_requested + end + + describe 'retry behaviour' do + it "doesn't retry errors" do + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .to_timeout + + expect { post_response }.to raise_error(Faraday::ConnectionFailed) + expect(stub).to have_been_requested + end + end + + context 'when the request needs a body and custom header' do + subject(:post_response) { client.creditor_bank_account_validates.validate(body, headers) } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .with( + body: { foo: 'bar' }, + headers: { 'Foo' => 'Bar' } + ).to_return( + body: { + 'creditor_bank_accounts' => { + + 'bank_name' => 'bank_name-input', + 'icon_url' => 'icon_url-input', + 'invalid_reasons' => 'invalid_reasons-input', + 'is_valid' => 'is_valid-input' + } + }.to_json, + headers: response_headers + ) + end + end + end +end diff --git a/spec/services/creditor_bank_accounts_service_spec.rb b/spec/services/creditor_bank_accounts_service_spec.rb index a1009ac..dc2eae6 100644 --- a/spec/services/creditor_bank_accounts_service_spec.rb +++ b/spec/services/creditor_bank_accounts_service_spec.rb @@ -741,88 +741,4 @@ end end end - - describe '#validate' do - subject(:post_response) { client.creditor_bank_accounts.validate } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - - headers: response_headers - ) - end - - it 'wraps the response and calls the right endpoint' do - expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) - - expect(stub).to have_been_requested - end - - describe 'retry behaviour' do - it "doesn't retry errors" do - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/) - .to_timeout - - expect { post_response }.to raise_error(Faraday::ConnectionFailed) - expect(stub).to have_been_requested - end - end - - context 'when the request needs a body and custom header' do - subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/) - .with( - body: { foo: 'bar' }, - headers: { 'Foo' => 'Bar' } - ).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - headers: response_headers - ) - end - end - end end From de443ad724f5f54236a2da23ab812a64863459b1 Mon Sep 17 00:00:00 2001 From: Robot Date: Wed, 27 Aug 2025 10:48:35 +0000 Subject: [PATCH 5/9] Changes from gocardless/gocardless-pro-ruby-template@fedf3f94c535f57b2090e829d20630dc748c83dc --- lib/gocardless_pro.rb | 3 - lib/gocardless_pro/client.rb | 5 -- .../creditor_bank_accounts_service.rb | 35 ++++++++ spec/resources/creditor_bank_account_spec.rb | 73 ++++++++++++++++ .../creditor_bank_accounts_service_spec.rb | 84 +++++++++++++++++++ 5 files changed, 192 insertions(+), 8 deletions(-) diff --git a/lib/gocardless_pro.rb b/lib/gocardless_pro.rb index 3d60870..0f372d3 100644 --- a/lib/gocardless_pro.rb +++ b/lib/gocardless_pro.rb @@ -72,9 +72,6 @@ module GoCardlessPro require_relative 'gocardless_pro/resources/creditor_bank_account' require_relative 'gocardless_pro/services/creditor_bank_accounts_service' -require_relative 'gocardless_pro/resources/creditor_bank_account_validate' -require_relative 'gocardless_pro/services/creditor_bank_account_validates_service' - require_relative 'gocardless_pro/resources/currency_exchange_rate' require_relative 'gocardless_pro/services/currency_exchange_rates_service' diff --git a/lib/gocardless_pro/client.rb b/lib/gocardless_pro/client.rb index 7f032e2..9f49d77 100644 --- a/lib/gocardless_pro/client.rb +++ b/lib/gocardless_pro/client.rb @@ -58,11 +58,6 @@ def creditor_bank_accounts @creditor_bank_accounts ||= Services::CreditorBankAccountsService.new(@api_service) end - # Access to the service for creditor_bank_account_validate to make API calls - def creditor_bank_account_validates - @creditor_bank_account_validates ||= Services::CreditorBankAccountValidatesService.new(@api_service) - end - # Access to the service for currency_exchange_rate to make API calls def currency_exchange_rates @currency_exchange_rates ||= Services::CurrencyExchangeRatesService.new(@api_service) diff --git a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb index aefd047..885f138 100644 --- a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +++ b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb @@ -139,6 +139,41 @@ def disable(identity, options = {}) Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) end + # Validate bank details without creating a creditor bank account + # Example URL: /creditor_bank_accounts/validate + # @param options [Hash] parameters as a hash, under a params key. + def validate(options = {}) + path = '/creditor_bank_accounts/validate' + + params = options.delete(:params) || {} + options[:params] = {} + options[:params]['data'] = params + + options[:retry_failures] = false + + begin + response = make_request(:post, path, options) + + # Response doesn't raise any errors until #body is called + response.tap(&:body) + rescue InvalidStateError => e + if e.idempotent_creation_conflict? + case @api_service.on_idempotency_conflict + when :raise + raise IdempotencyConflict, e.error + when :fetch + return get(e.conflicting_resource_id) + end + end + + raise e + end + + return if response.body.nil? + + Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) + end + private # Unenvelope the response of the body using the service's `envelope_key` diff --git a/spec/resources/creditor_bank_account_spec.rb b/spec/resources/creditor_bank_account_spec.rb index 8dbe288..f526571 100644 --- a/spec/resources/creditor_bank_account_spec.rb +++ b/spec/resources/creditor_bank_account_spec.rb @@ -484,4 +484,77 @@ end end end + + describe '#validate' do + subject(:post_response) { client.creditor_bank_accounts.validate } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + + headers: response_headers + ) + end + + it 'wraps the response and calls the right endpoint' do + expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) + + expect(stub).to have_been_requested + end + + context 'when the request needs a body and custom header' do + subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .with( + body: { foo: 'bar' }, + headers: { 'Foo' => 'Bar' } + ).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + headers: response_headers + ) + end + end + end end diff --git a/spec/services/creditor_bank_accounts_service_spec.rb b/spec/services/creditor_bank_accounts_service_spec.rb index dc2eae6..a1009ac 100644 --- a/spec/services/creditor_bank_accounts_service_spec.rb +++ b/spec/services/creditor_bank_accounts_service_spec.rb @@ -741,4 +741,88 @@ end end end + + describe '#validate' do + subject(:post_response) { client.creditor_bank_accounts.validate } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + + headers: response_headers + ) + end + + it 'wraps the response and calls the right endpoint' do + expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) + + expect(stub).to have_been_requested + end + + describe 'retry behaviour' do + it "doesn't retry errors" do + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .to_timeout + + expect { post_response }.to raise_error(Faraday::ConnectionFailed) + expect(stub).to have_been_requested + end + end + + context 'when the request needs a body and custom header' do + subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } + + let(:resource_id) { 'ABC123' } + + let!(:stub) do + # /creditor_bank_accounts/validate + stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) + stub_request(:post, /.*api.gocardless.com#{stub_url}/) + .with( + body: { foo: 'bar' }, + headers: { 'Foo' => 'Bar' } + ).to_return( + body: { + 'creditor_bank_accounts' => { + + 'account_holder_name' => 'account_holder_name-input', + 'account_number_ending' => 'account_number_ending-input', + 'account_type' => 'account_type-input', + 'bank_name' => 'bank_name-input', + 'country_code' => 'country_code-input', + 'created_at' => 'created_at-input', + 'currency' => 'currency-input', + 'enabled' => 'enabled-input', + 'id' => 'id-input', + 'links' => 'links-input', + 'metadata' => 'metadata-input', + 'verification_status' => 'verification_status-input' + } + }.to_json, + headers: response_headers + ) + end + end + end end From 2f72fd5ad15dd493cad40446bef965bb0129520f Mon Sep 17 00:00:00 2001 From: Robot Date: Wed, 27 Aug 2025 12:08:57 +0000 Subject: [PATCH 6/9] Changes from gocardless/gocardless-pro-ruby-template@761a6ec4ea9cb867ab6b98a2179137fe85e56d5a --- .../creditor_bank_accounts_service.rb | 35 -------- spec/resources/creditor_bank_account_spec.rb | 73 ---------------- .../creditor_bank_accounts_service_spec.rb | 84 ------------------- 3 files changed, 192 deletions(-) diff --git a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb index 885f138..aefd047 100644 --- a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +++ b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb @@ -139,41 +139,6 @@ def disable(identity, options = {}) Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) end - # Validate bank details without creating a creditor bank account - # Example URL: /creditor_bank_accounts/validate - # @param options [Hash] parameters as a hash, under a params key. - def validate(options = {}) - path = '/creditor_bank_accounts/validate' - - params = options.delete(:params) || {} - options[:params] = {} - options[:params]['data'] = params - - options[:retry_failures] = false - - begin - response = make_request(:post, path, options) - - # Response doesn't raise any errors until #body is called - response.tap(&:body) - rescue InvalidStateError => e - if e.idempotent_creation_conflict? - case @api_service.on_idempotency_conflict - when :raise - raise IdempotencyConflict, e.error - when :fetch - return get(e.conflicting_resource_id) - end - end - - raise e - end - - return if response.body.nil? - - Resources::CreditorBankAccount.new(unenvelope_body(response.body), response) - end - private # Unenvelope the response of the body using the service's `envelope_key` diff --git a/spec/resources/creditor_bank_account_spec.rb b/spec/resources/creditor_bank_account_spec.rb index f526571..8dbe288 100644 --- a/spec/resources/creditor_bank_account_spec.rb +++ b/spec/resources/creditor_bank_account_spec.rb @@ -484,77 +484,4 @@ end end end - - describe '#validate' do - subject(:post_response) { client.creditor_bank_accounts.validate } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - - headers: response_headers - ) - end - - it 'wraps the response and calls the right endpoint' do - expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) - - expect(stub).to have_been_requested - end - - context 'when the request needs a body and custom header' do - subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/) - .with( - body: { foo: 'bar' }, - headers: { 'Foo' => 'Bar' } - ).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - headers: response_headers - ) - end - end - end end diff --git a/spec/services/creditor_bank_accounts_service_spec.rb b/spec/services/creditor_bank_accounts_service_spec.rb index a1009ac..dc2eae6 100644 --- a/spec/services/creditor_bank_accounts_service_spec.rb +++ b/spec/services/creditor_bank_accounts_service_spec.rb @@ -741,88 +741,4 @@ end end end - - describe '#validate' do - subject(:post_response) { client.creditor_bank_accounts.validate } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - - headers: response_headers - ) - end - - it 'wraps the response and calls the right endpoint' do - expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount) - - expect(stub).to have_been_requested - end - - describe 'retry behaviour' do - it "doesn't retry errors" do - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/) - .to_timeout - - expect { post_response }.to raise_error(Faraday::ConnectionFailed) - expect(stub).to have_been_requested - end - end - - context 'when the request needs a body and custom header' do - subject(:post_response) { client.creditor_bank_accounts.validate(body, headers) } - - let(:resource_id) { 'ABC123' } - - let!(:stub) do - # /creditor_bank_accounts/validate - stub_url = '/creditor_bank_accounts/validate'.gsub(':identity', resource_id) - stub_request(:post, /.*api.gocardless.com#{stub_url}/) - .with( - body: { foo: 'bar' }, - headers: { 'Foo' => 'Bar' } - ).to_return( - body: { - 'creditor_bank_accounts' => { - - 'account_holder_name' => 'account_holder_name-input', - 'account_number_ending' => 'account_number_ending-input', - 'account_type' => 'account_type-input', - 'bank_name' => 'bank_name-input', - 'country_code' => 'country_code-input', - 'created_at' => 'created_at-input', - 'currency' => 'currency-input', - 'enabled' => 'enabled-input', - 'id' => 'id-input', - 'links' => 'links-input', - 'metadata' => 'metadata-input', - 'verification_status' => 'verification_status-input' - } - }.to_json, - headers: response_headers - ) - end - end - end end From c8f531db0cfe01b67ffd3025097ac648565237cb Mon Sep 17 00:00:00 2001 From: Robot Date: Tue, 2 Sep 2025 08:21:47 +0000 Subject: [PATCH 7/9] Changes from gocardless/gocardless-pro-ruby-template@143c1d7df76aea8e8883f6ae9f82a0587e031984 --- lib/gocardless_pro/resources/event.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/gocardless_pro/resources/event.rb b/lib/gocardless_pro/resources/event.rb index fb543c6..fb556b3 100644 --- a/lib/gocardless_pro/resources/event.rb +++ b/lib/gocardless_pro/resources/event.rb @@ -88,6 +88,10 @@ def mandate @links['mandate'] end + def mandate_request + @links['mandate_request'] + end + def mandate_request_mandate @links['mandate_request_mandate'] end From d7e823b84342f016df7c023bc9b82aa99b2e502a Mon Sep 17 00:00:00 2001 From: Robot Date: Wed, 3 Sep 2025 15:27:16 +0000 Subject: [PATCH 8/9] Changes from gocardless/gocardless-pro-ruby-template@08b05e23ef14877ae466dfe2187a9a763e630b74 --- Gemfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Gemfile b/Gemfile index df630a9..851fabc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,2 @@ source 'https://rubygems.org' gemspec - -# We support both pre-1.x and post-1.x Faraday versions, but to ensure compatibility we -# pin this gem against each in separate runs of CI, using the FARADAY_VERSION env var. For -# more details on the values, see .github/workflows/tests.yml in the gocardless-pro-ruby -# repository. -if ENV.key?("FARADAY_VERSION") - gem 'faraday', "~> #{ENV["FARADAY_VERSION"]}" -end From 275c28be68a315e18c0af67a328e22f5d146d0d8 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:26:22 +0000 Subject: [PATCH 9/9] Changes generated by 02be21976ddb2bea6445004da39a5ec293501199 This commit was automatically created from gocardless/gocardless-pro-ruby-template@02be21976ddb2bea6445004da39a5ec293501199 by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-ruby-template/actions/runs/17439713229 --- tmp-push-files-checkout | 1 + 1 file changed, 1 insertion(+) create mode 160000 tmp-push-files-checkout diff --git a/tmp-push-files-checkout b/tmp-push-files-checkout new file mode 160000 index 0000000..d7e823b --- /dev/null +++ b/tmp-push-files-checkout @@ -0,0 +1 @@ +Subproject commit d7e823b84342f016df7c023bc9b82aa99b2e502a