diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index cf9d6cda..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-language: ruby
-
-rvm:
- - 2.3.0
- - 2.0.0
-
-sudo: false
-
-script:
- - bundle exec rspec spec
diff --git a/Gemfile b/Gemfile
index df630a94..851fabc2 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
diff --git a/README.md b/README.md
index cd3fbc05..c5e1f620 100644
--- a/README.md
+++ b/README.md
@@ -260,18 +260,6 @@ OAuth simply provides a means by which you obtain an access token - once you hav
We recommend using the [oauth2](https://github.com/intridea/oauth2) gem to handle the authorisation process and gain a token. For an example of this in action, see our [open-source OAuth demo app](https://github.com/gocardless/oauth-demo/blob/master/app.rb#L46).
-## Supporting Ruby < 2.0.0
-The client only supports Ruby >= 2.0.0 out of the box due to our use of
-Enumerable::Lazy for lazy loading of paginated API resources.
-
-If you wish to use this gem with a previous ruby version, you should be able to
-do so with the [backports](https://github.com/marcandre/backports) gem:
-
-1. Add backports to your Gemfile
- ```gem 'backports'```
-2. Require lazy enumerables
- ```require 'backports/2.0.0/enumerable/lazy.rb'```
-
## Contributing
This client is auto-generated from Crank, a toolchain that we hope to open source soon. For now, issues should be reported on this repository. __Please do not modify the source code yourself, your changes will be overriden!__
diff --git a/lib/gocardless_pro.rb b/lib/gocardless_pro.rb
index 0f372d30..4258c51e 100644
--- a/lib/gocardless_pro.rb
+++ b/lib/gocardless_pro.rb
@@ -45,6 +45,9 @@ module GoCardlessPro
require_relative 'gocardless_pro/resources/bank_account_detail'
require_relative 'gocardless_pro/services/bank_account_details_service'
+require_relative 'gocardless_pro/resources/bank_account_holder_verification'
+require_relative 'gocardless_pro/services/bank_account_holder_verifications_service'
+
require_relative 'gocardless_pro/resources/bank_authorisation'
require_relative 'gocardless_pro/services/bank_authorisations_service'
@@ -90,6 +93,9 @@ module GoCardlessPro
require_relative 'gocardless_pro/resources/export'
require_relative 'gocardless_pro/services/exports_service'
+require_relative 'gocardless_pro/resources/funds_availability'
+require_relative 'gocardless_pro/services/funds_availabilities_service'
+
require_relative 'gocardless_pro/resources/instalment_schedule'
require_relative 'gocardless_pro/services/instalment_schedules_service'
@@ -126,6 +132,12 @@ module GoCardlessPro
require_relative 'gocardless_pro/resources/payment'
require_relative 'gocardless_pro/services/payments_service'
+require_relative 'gocardless_pro/resources/payment_account'
+require_relative 'gocardless_pro/services/payment_accounts_service'
+
+require_relative 'gocardless_pro/resources/payment_account_transaction'
+require_relative 'gocardless_pro/services/payment_account_transactions_service'
+
require_relative 'gocardless_pro/resources/payout'
require_relative 'gocardless_pro/services/payouts_service'
diff --git a/lib/gocardless_pro/client.rb b/lib/gocardless_pro/client.rb
index 9f49d77f..deb88080 100644
--- a/lib/gocardless_pro/client.rb
+++ b/lib/gocardless_pro/client.rb
@@ -13,6 +13,11 @@ def bank_account_details
@bank_account_details ||= Services::BankAccountDetailsService.new(@api_service)
end
+ # Access to the service for bank_account_holder_verification to make API calls
+ def bank_account_holder_verifications
+ @bank_account_holder_verifications ||= Services::BankAccountHolderVerificationsService.new(@api_service)
+ end
+
# Access to the service for bank_authorisation to make API calls
def bank_authorisations
@bank_authorisations ||= Services::BankAuthorisationsService.new(@api_service)
@@ -88,6 +93,11 @@ def exports
@exports ||= Services::ExportsService.new(@api_service)
end
+ # Access to the service for funds_availability to make API calls
+ def funds_availabilities
+ @funds_availabilities ||= Services::FundsAvailabilitiesService.new(@api_service)
+ end
+
# Access to the service for instalment_schedule to make API calls
def instalment_schedules
@instalment_schedules ||= Services::InstalmentSchedulesService.new(@api_service)
@@ -148,6 +158,16 @@ def payments
@payments ||= Services::PaymentsService.new(@api_service)
end
+ # Access to the service for payment_account to make API calls
+ def payment_accounts
+ @payment_accounts ||= Services::PaymentAccountsService.new(@api_service)
+ end
+
+ # Access to the service for payment_account_transaction to make API calls
+ def payment_account_transactions
+ @payment_account_transactions ||= Services::PaymentAccountTransactionsService.new(@api_service)
+ end
+
# Access to the service for payout to make API calls
def payouts
@payouts ||= Services::PayoutsService.new(@api_service)
@@ -253,8 +273,8 @@ def default_options
'User-Agent' => "#{user_agent}",
'Content-Type' => 'application/json',
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
- 'GoCardless-Client-Version' => '4.2.0'
- }
+ 'GoCardless-Client-Version' => '4.2.1',
+ },
}
end
@@ -274,7 +294,7 @@ def user_agent
comment = [
"#{ruby_engine}/#{ruby_version}",
"#{RUBY_ENGINE}/#{interpreter_version}",
- "#{RUBY_PLATFORM}"
+ "#{RUBY_PLATFORM}",
]
comment << "faraday/#{Faraday::VERSION}"
"#{gem_info} #{comment.join(' ')}"
diff --git a/lib/gocardless_pro/error.rb b/lib/gocardless_pro/error.rb
index 8cf2bb74..11ea393c 100644
--- a/lib/gocardless_pro/error.rb
+++ b/lib/gocardless_pro/error.rb
@@ -23,9 +23,9 @@ def message
def to_s
if errors.any?
- errors
- .map { |err| "#{err['field']} #{err['message']}" }
- .join(', ')
+ errors.
+ map { |err| "#{err['field']} #{err['message']}" }.
+ join(', ')
else
@error['message']
end
diff --git a/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb b/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb
index 38f7a184..fc691458 100644
--- a/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb
+++ b/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb
@@ -13,6 +13,13 @@ def on_complete(env)
return unless CLIENT_ERROR_STATUSES.include?(env.status)
json_body ||= JSON.parse(env.body) unless env.body.empty?
+ if json_body['error'].is_a?(String)
+ # Some errors are returned as string rather than objects, wrap in standard format
+ json_body['error'] = {
+ 'message' => json_body['error'],
+ 'status' => env.status,
+ }
+ end
error_type = json_body['error']['type']
error_class = error_class_for_status(env.status) || error_class_for_type(error_type)
@@ -24,9 +31,10 @@ def on_complete(env)
def error_class_for_status(code)
{
+ 400 => GoCardlessPro::InvalidApiUsageError,
401 => GoCardlessPro::AuthenticationError,
403 => GoCardlessPro::PermissionError,
- 429 => GoCardlessPro::RateLimitError
+ 429 => GoCardlessPro::RateLimitError,
}.fetch(code, nil)
end
@@ -35,7 +43,7 @@ def error_class_for_type(type)
validation_failed: GoCardlessPro::ValidationError,
gocardless: GoCardlessPro::GoCardlessError,
invalid_api_usage: GoCardlessPro::InvalidApiUsageError,
- invalid_state: GoCardlessPro::InvalidStateError
+ invalid_state: GoCardlessPro::InvalidStateError,
}.fetch(type.to_sym)
end
@@ -45,7 +53,7 @@ def generate_error_data(env)
"code: #{env.status}\n" \
"headers: #{env.response_headers}\n" \
"body: #{env.body}",
- 'code' => env.status
+ 'code' => env.status,
}
end
diff --git a/lib/gocardless_pro/paginator.rb b/lib/gocardless_pro/paginator.rb
index 492460f3..933ef33b 100644
--- a/lib/gocardless_pro/paginator.rb
+++ b/lib/gocardless_pro/paginator.rb
@@ -8,6 +8,7 @@ class Paginator
def initialize(options = {})
@service = options.fetch(:service)
@options = options.fetch(:options)
+ @uri_params = options.reject { |k, _| %i[service options].include?(k) }
end
# Get a lazy enumerable for listing data from the API
@@ -22,7 +23,7 @@ def enumerator
@options[:params] ||= {}
@options[:params] = @options[:params].merge(after: after_cursor)
- response = @service.list(@options.merge(after: after_cursor))
+ response = @service.list(*@uri_params.values, @options.merge(after: after_cursor))
end
end.lazy
end
@@ -30,7 +31,7 @@ def enumerator
private
def get_initial_response
- @initial_response ||= @service.list(@options)
+ @initial_response ||= @service.list(*@uri_params.values, @options)
end
end
end
diff --git a/lib/gocardless_pro/resources/balance.rb b/lib/gocardless_pro/resources/balance.rb
index 3b02f634..d2445e18 100644
--- a/lib/gocardless_pro/resources/balance.rb
+++ b/lib/gocardless_pro/resources/balance.rb
@@ -18,7 +18,10 @@ module Resources
# likely won’t match what’s shown in the dashboard as the dashboard balances
# are updated much less frequently (once per day).
class Balance
- attr_reader :amount, :balance_type, :currency, :last_updated_at
+ attr_reader :amount
+ attr_reader :balance_type
+ attr_reader :currency
+ attr_reader :last_updated_at
# Initialize a balance resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/bank_account_detail.rb b/lib/gocardless_pro/resources/bank_account_detail.rb
index 59ff4049..e9564052 100644
--- a/lib/gocardless_pro/resources/bank_account_detail.rb
+++ b/lib/gocardless_pro/resources/bank_account_detail.rb
@@ -12,7 +12,11 @@ module Resources
# Retrieve bank account details in JWE encrypted format
class BankAccountDetail
- attr_reader :ciphertext, :encrypted_key, :iv, :protected, :tag
+ attr_reader :ciphertext
+ attr_reader :encrypted_key
+ attr_reader :iv
+ attr_reader :protected
+ attr_reader :tag
# Initialize a bank_account_detail resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/bank_account_holder_verification.rb b/lib/gocardless_pro/resources/bank_account_holder_verification.rb
new file mode 100644
index 00000000..ed2963fe
--- /dev/null
+++ b/lib/gocardless_pro/resources/bank_account_holder_verification.rb
@@ -0,0 +1,44 @@
+#
+# 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 bank_account_holder_verification resource returned from the API
+
+ # Create a bank account holder verification for a bank account.
+ class BankAccountHolderVerification
+ attr_reader :actual_account_name
+ attr_reader :id
+ attr_reader :result
+ attr_reader :status
+ attr_reader :type
+
+ # Initialize a bank_account_holder_verification resource instance
+ # @param object [Hash] an object returned from the API
+ def initialize(object, response = nil)
+ @object = object
+
+ @actual_account_name = object['actual_account_name']
+ @id = object['id']
+ @result = object['result']
+ @status = object['status']
+ @type = object['type']
+ @response = response
+ end
+
+ def api_response
+ ApiResponse.new(@response)
+ end
+
+ # Provides the bank_account_holder_verification resource as a hash of all its readable attributes
+ def to_h
+ @object
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/resources/bank_authorisation.rb b/lib/gocardless_pro/resources/bank_authorisation.rb
index 465a3495..d7d9d1f0 100644
--- a/lib/gocardless_pro/resources/bank_authorisation.rb
+++ b/lib/gocardless_pro/resources/bank_authorisation.rb
@@ -21,8 +21,15 @@ module Resources
# (see Billing Request Flows) to ensure we meet regulatory requirements for
# checkout flows.
class BankAuthorisation
- attr_reader :authorisation_type, :authorised_at, :created_at, :expires_at, :id, :last_visited_at, :qr_code_url,
- :redirect_uri, :url
+ attr_reader :authorisation_type
+ attr_reader :authorised_at
+ attr_reader :created_at
+ attr_reader :expires_at
+ attr_reader :id
+ attr_reader :last_visited_at
+ attr_reader :qr_code_url
+ attr_reader :redirect_uri
+ attr_reader :url
# Initialize a bank_authorisation resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/bank_details_lookup.rb b/lib/gocardless_pro/resources/bank_details_lookup.rb
index ca35e155..664113e1 100644
--- a/lib/gocardless_pro/resources/bank_details_lookup.rb
+++ b/lib/gocardless_pro/resources/bank_details_lookup.rb
@@ -12,7 +12,9 @@ module Resources
# Look up the name and reachability of a bank account.
class BankDetailsLookup
- attr_reader :available_debit_schemes, :bank_name, :bic
+ attr_reader :available_debit_schemes
+ attr_reader :bank_name
+ attr_reader :bic
# Initialize a bank_details_lookup resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/billing_request.rb b/lib/gocardless_pro/resources/billing_request.rb
index fb813eb3..d4261e76 100644
--- a/lib/gocardless_pro/resources/billing_request.rb
+++ b/lib/gocardless_pro/resources/billing_request.rb
@@ -22,8 +22,21 @@ module Resources
# `subscription_request` and `instalment_schedule_request` are only
# supported for ACH and PAD schemes.
class BillingRequest
- attr_reader :actions, :created_at, :fallback_enabled, :fallback_occurred, :id, :instalment_schedule_request,
- :mandate_request, :metadata, :payment_request, :purpose_code, :resources, :status, :subscription_request
+ attr_reader :actions
+ attr_reader :created_at
+ attr_reader :fallback_enabled
+ attr_reader :fallback_occurred
+ attr_reader :id
+ attr_reader :instalment_schedule_request
+ attr_reader :mandate_request
+ attr_reader :metadata
+ attr_reader :payment_context_code
+ attr_reader :payment_purpose_code
+ attr_reader :payment_request
+ attr_reader :purpose_code
+ attr_reader :resources
+ attr_reader :status
+ attr_reader :subscription_request
# Initialize a billing_request resource instance
# @param object [Hash] an object returned from the API
@@ -39,6 +52,8 @@ def initialize(object, response = nil)
@links = object['links']
@mandate_request = object['mandate_request']
@metadata = object['metadata']
+ @payment_context_code = object['payment_context_code']
+ @payment_purpose_code = object['payment_purpose_code']
@payment_request = object['payment_request']
@purpose_code = object['purpose_code']
@resources = object['resources']
diff --git a/lib/gocardless_pro/resources/billing_request_flow.rb b/lib/gocardless_pro/resources/billing_request_flow.rb
index 62a3546b..ccc471e0 100644
--- a/lib/gocardless_pro/resources/billing_request_flow.rb
+++ b/lib/gocardless_pro/resources/billing_request_flow.rb
@@ -14,8 +14,24 @@ module Resources
# payment created for a scheme with strong payer
# authorisation (such as open banking single payments).
class BillingRequestFlow
- attr_reader :authorisation_url, :auto_fulfil, :created_at, :customer_details_captured, :exit_uri, :expires_at,
- :id, :language, :lock_bank_account, :lock_currency, :lock_customer_details, :prefilled_bank_account, :prefilled_customer, :redirect_uri, :session_token, :show_redirect_buttons, :show_success_redirect_button, :skip_success_screen
+ attr_reader :authorisation_url
+ attr_reader :auto_fulfil
+ attr_reader :created_at
+ attr_reader :customer_details_captured
+ attr_reader :exit_uri
+ attr_reader :expires_at
+ attr_reader :id
+ attr_reader :language
+ attr_reader :lock_bank_account
+ attr_reader :lock_currency
+ attr_reader :lock_customer_details
+ attr_reader :prefilled_bank_account
+ attr_reader :prefilled_customer
+ attr_reader :redirect_uri
+ attr_reader :session_token
+ attr_reader :show_redirect_buttons
+ attr_reader :show_success_redirect_button
+ attr_reader :skip_success_screen
# Initialize a billing_request_flow resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/billing_request_template.rb b/lib/gocardless_pro/resources/billing_request_template.rb
index 18280b59..6e435a6f 100644
--- a/lib/gocardless_pro/resources/billing_request_template.rb
+++ b/lib/gocardless_pro/resources/billing_request_template.rb
@@ -26,8 +26,24 @@ module Resources
# for single-use and is designed to cater to the unique needs of individual
# customers.
class BillingRequestTemplate
- attr_reader :authorisation_url, :created_at, :id, :mandate_request_constraints, :mandate_request_currency,
- :mandate_request_description, :mandate_request_metadata, :mandate_request_scheme, :mandate_request_verify, :metadata, :name, :payment_request_amount, :payment_request_currency, :payment_request_description, :payment_request_metadata, :payment_request_scheme, :redirect_uri, :updated_at
+ attr_reader :authorisation_url
+ attr_reader :created_at
+ attr_reader :id
+ attr_reader :mandate_request_constraints
+ attr_reader :mandate_request_currency
+ attr_reader :mandate_request_description
+ attr_reader :mandate_request_metadata
+ attr_reader :mandate_request_scheme
+ attr_reader :mandate_request_verify
+ attr_reader :metadata
+ attr_reader :name
+ attr_reader :payment_request_amount
+ attr_reader :payment_request_currency
+ attr_reader :payment_request_description
+ attr_reader :payment_request_metadata
+ attr_reader :payment_request_scheme
+ attr_reader :redirect_uri
+ attr_reader :updated_at
# Initialize a billing_request_template resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/billing_request_with_action.rb b/lib/gocardless_pro/resources/billing_request_with_action.rb
index 5db985be..d7cd1556 100644
--- a/lib/gocardless_pro/resources/billing_request_with_action.rb
+++ b/lib/gocardless_pro/resources/billing_request_with_action.rb
@@ -19,7 +19,8 @@ module Resources
# Overview](https://developer.gocardless.com/getting-started/billing-requests/overview/)
# for how-to's, explanations and tutorials.
class BillingRequestWithAction
- attr_reader :bank_authorisations, :billing_requests
+ attr_reader :bank_authorisations
+ attr_reader :billing_requests
# Initialize a billing_request_with_action resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/block.rb b/lib/gocardless_pro/resources/block.rb
index a5bc08f0..33d9236e 100644
--- a/lib/gocardless_pro/resources/block.rb
+++ b/lib/gocardless_pro/resources/block.rb
@@ -49,8 +49,14 @@ module Resources
# would like to use this API.
#
class Block
- attr_reader :active, :block_type, :created_at, :id, :reason_description, :reason_type, :resource_reference,
- :updated_at
+ attr_reader :active
+ attr_reader :block_type
+ attr_reader :created_at
+ attr_reader :id
+ attr_reader :reason_description
+ attr_reader :reason_type
+ attr_reader :resource_reference
+ attr_reader :updated_at
# Initialize a block resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/creditor.rb b/lib/gocardless_pro/resources/creditor.rb
index c747fd14..15121362 100644
--- a/lib/gocardless_pro/resources/creditor.rb
+++ b/lib/gocardless_pro/resources/creditor.rb
@@ -18,8 +18,26 @@ module Resources
# Currently, for Anti Money Laundering reasons, any creditors you add must
# be directly related to your organisation.
class Creditor
- attr_reader :address_line1, :address_line2, :address_line3, :bank_reference_prefix, :can_create_refunds, :city,
- :country_code, :created_at, :creditor_type, :custom_payment_pages_enabled, :fx_payout_currency, :id, :logo_url, :mandate_imports_enabled, :merchant_responsible_for_notifications, :name, :postal_code, :region, :scheme_identifiers, :verification_status
+ attr_reader :address_line1
+ attr_reader :address_line2
+ attr_reader :address_line3
+ attr_reader :bank_reference_prefix
+ attr_reader :can_create_refunds
+ attr_reader :city
+ attr_reader :country_code
+ attr_reader :created_at
+ attr_reader :creditor_type
+ attr_reader :custom_payment_pages_enabled
+ attr_reader :fx_payout_currency
+ attr_reader :id
+ attr_reader :logo_url
+ attr_reader :mandate_imports_enabled
+ attr_reader :merchant_responsible_for_notifications
+ attr_reader :name
+ attr_reader :postal_code
+ attr_reader :region
+ attr_reader :scheme_identifiers
+ attr_reader :verification_status
# Initialize a creditor resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/creditor_bank_account.rb b/lib/gocardless_pro/resources/creditor_bank_account.rb
index 9cf19aee..277d10c7 100644
--- a/lib/gocardless_pro/resources/creditor_bank_account.rb
+++ b/lib/gocardless_pro/resources/creditor_bank_account.rb
@@ -23,8 +23,17 @@ module Resources
# Restricted: This API is not
# available for partner integrations.
class CreditorBankAccount
- attr_reader :account_holder_name, :account_number_ending, :account_type, :bank_name, :country_code, :created_at,
- :currency, :enabled, :id, :metadata, :verification_status
+ attr_reader :account_holder_name
+ attr_reader :account_number_ending
+ attr_reader :account_type
+ attr_reader :bank_name
+ attr_reader :country_code
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :enabled
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :verification_status
# Initialize a creditor_bank_account resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/currency_exchange_rate.rb b/lib/gocardless_pro/resources/currency_exchange_rate.rb
index 80674827..cae5cf1e 100644
--- a/lib/gocardless_pro/resources/currency_exchange_rate.rb
+++ b/lib/gocardless_pro/resources/currency_exchange_rate.rb
@@ -12,7 +12,10 @@ module Resources
# Currency exchange rates from our foreign exchange provider.
class CurrencyExchangeRate
- attr_reader :rate, :source, :target, :time
+ attr_reader :rate
+ attr_reader :source
+ attr_reader :target
+ attr_reader :time
# Initialize a currency_exchange_rate resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/customer.rb b/lib/gocardless_pro/resources/customer.rb
index 5a264309..ea5f0f7e 100644
--- a/lib/gocardless_pro/resources/customer.rb
+++ b/lib/gocardless_pro/resources/customer.rb
@@ -15,8 +15,24 @@ module Resources
# accounts](#core-endpoints-customer-bank-accounts), which in turn can have
# several Direct Debit [mandates](#core-endpoints-mandates).
class Customer
- attr_reader :address_line1, :address_line2, :address_line3, :city, :company_name, :country_code, :created_at,
- :danish_identity_number, :email, :family_name, :given_name, :id, :language, :metadata, :phone_number, :postal_code, :region, :swedish_identity_number
+ attr_reader :address_line1
+ attr_reader :address_line2
+ attr_reader :address_line3
+ attr_reader :city
+ attr_reader :company_name
+ attr_reader :country_code
+ attr_reader :created_at
+ attr_reader :danish_identity_number
+ attr_reader :email
+ attr_reader :family_name
+ attr_reader :given_name
+ attr_reader :id
+ attr_reader :language
+ attr_reader :metadata
+ attr_reader :phone_number
+ attr_reader :postal_code
+ attr_reader :region
+ attr_reader :swedish_identity_number
# Initialize a customer resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/customer_bank_account.rb b/lib/gocardless_pro/resources/customer_bank_account.rb
index 31fef05e..5f706aef 100644
--- a/lib/gocardless_pro/resources/customer_bank_account.rb
+++ b/lib/gocardless_pro/resources/customer_bank_account.rb
@@ -28,8 +28,17 @@ module Resources
# [bank_details_lookups](#bank-details-lookups-perform-a-bank-details-lookup),
# before proceeding with creating the accounts
class CustomerBankAccount
- attr_reader :account_holder_name, :account_number_ending, :account_type, :bank_account_token, :bank_name,
- :country_code, :created_at, :currency, :enabled, :id, :metadata
+ attr_reader :account_holder_name
+ attr_reader :account_number_ending
+ attr_reader :account_type
+ attr_reader :bank_account_token
+ attr_reader :bank_name
+ attr_reader :country_code
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :enabled
+ attr_reader :id
+ attr_reader :metadata
# Initialize a customer_bank_account resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/customer_notification.rb b/lib/gocardless_pro/resources/customer_notification.rb
index 522d670d..ea318509 100644
--- a/lib/gocardless_pro/resources/customer_notification.rb
+++ b/lib/gocardless_pro/resources/customer_notification.rb
@@ -25,7 +25,11 @@ module Resources
# href="mailto:help@gocardless.com">get in touch if you would like to
# use this API.
class CustomerNotification
- attr_reader :action_taken, :action_taken_at, :action_taken_by, :id, :type
+ attr_reader :action_taken
+ attr_reader :action_taken_at
+ attr_reader :action_taken_by
+ attr_reader :id
+ attr_reader :type
# Initialize a customer_notification resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/event.rb b/lib/gocardless_pro/resources/event.rb
index fb543c68..a742f061 100644
--- a/lib/gocardless_pro/resources/event.rb
+++ b/lib/gocardless_pro/resources/event.rb
@@ -15,10 +15,17 @@ module Resources
# mandate which has been transferred. Event creation is an asynchronous
# process, so it can take some time between an action occurring and its
# corresponding event getting included in API responses. See
- # [here](#event-actions) for a complete list of event types.
+ # [here](#event-types) for a complete list of event types.
class Event
- attr_reader :action, :created_at, :customer_notifications, :details, :id, :metadata, :resource_metadata,
- :resource_type
+ attr_reader :action
+ attr_reader :created_at
+ attr_reader :customer_notifications
+ attr_reader :details
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :resource_metadata
+ attr_reader :resource_type
+ attr_reader :source
# Initialize a event resource instance
# @param object [Hash] an object returned from the API
@@ -34,6 +41,7 @@ def initialize(object, response = nil)
@metadata = object['metadata']
@resource_metadata = object['resource_metadata']
@resource_type = object['resource_type']
+ @source = object['source']
@response = response
end
@@ -88,6 +96,10 @@ def mandate
@links['mandate']
end
+ def mandate_request
+ @links['mandate_request']
+ end
+
def mandate_request_mandate
@links['mandate_request_mandate']
end
@@ -104,6 +116,10 @@ def organisation
@links['organisation']
end
+ def outbound_payment
+ @links['outbound_payment']
+ end
+
def parent_event
@links['parent_event']
end
diff --git a/lib/gocardless_pro/resources/export.rb b/lib/gocardless_pro/resources/export.rb
index 69a96ab6..d1f59ea9 100644
--- a/lib/gocardless_pro/resources/export.rb
+++ b/lib/gocardless_pro/resources/export.rb
@@ -12,7 +12,11 @@ module Resources
# File-based exports of data
class Export
- attr_reader :created_at, :currency, :download_url, :export_type, :id
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :download_url
+ attr_reader :export_type
+ attr_reader :id
# Initialize a export resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/funds_availability.rb b/lib/gocardless_pro/resources/funds_availability.rb
new file mode 100644
index 00000000..aeeb0041
--- /dev/null
+++ b/lib/gocardless_pro/resources/funds_availability.rb
@@ -0,0 +1,38 @@
+#
+# 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 funds_availability resource returned from the API
+
+ # Checks if the payer's current balance is sufficient to cover the amount
+ # the merchant wants to charge within the consent parameters defined on the
+ # mandate.
+ class FundsAvailability
+ attr_reader :available
+
+ # Initialize a funds_availability resource instance
+ # @param object [Hash] an object returned from the API
+ def initialize(object, response = nil)
+ @object = object
+
+ @available = object['available']
+ @response = response
+ end
+
+ def api_response
+ ApiResponse.new(@response)
+ end
+
+ # Provides the funds_availability resource as a hash of all its readable attributes
+ def to_h
+ @object
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/resources/instalment_schedule.rb b/lib/gocardless_pro/resources/instalment_schedule.rb
index 80c31981..0f530ff5 100644
--- a/lib/gocardless_pro/resources/instalment_schedule.rb
+++ b/lib/gocardless_pro/resources/instalment_schedule.rb
@@ -28,7 +28,14 @@ module Resources
# of collection.
#
class InstalmentSchedule
- attr_reader :created_at, :currency, :id, :metadata, :name, :payment_errors, :status, :total_amount
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :name
+ attr_reader :payment_errors
+ attr_reader :status
+ attr_reader :total_amount
# Initialize a instalment_schedule resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/institution.rb b/lib/gocardless_pro/resources/institution.rb
index 29bbfc82..420dc830 100644
--- a/lib/gocardless_pro/resources/institution.rb
+++ b/lib/gocardless_pro/resources/institution.rb
@@ -17,7 +17,14 @@ module Resources
# Not all institutions support both Payment Initiation (PIS) and Account
# Information (AIS) services.
class Institution
- attr_reader :autocompletes_collect_bank_account, :country_code, :icon_url, :id, :limits, :logo_url, :name, :status
+ attr_reader :autocompletes_collect_bank_account
+ attr_reader :country_code
+ attr_reader :icon_url
+ attr_reader :id
+ attr_reader :limits
+ attr_reader :logo_url
+ attr_reader :name
+ attr_reader :status
# Initialize a institution resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/mandate.rb b/lib/gocardless_pro/resources/mandate.rb
index 6a6892d7..5ff71f12 100644
--- a/lib/gocardless_pro/resources/mandate.rb
+++ b/lib/gocardless_pro/resources/mandate.rb
@@ -16,8 +16,20 @@ module Resources
# GoCardless will notify you via a [webhook](#appendix-webhooks) whenever
# the status of a mandate changes.
class Mandate
- attr_reader :authorisation_source, :consent_parameters, :consent_type, :created_at, :funds_settlement, :id,
- :metadata, :next_possible_charge_date, :next_possible_standard_ach_charge_date, :payments_require_approval, :reference, :scheme, :status, :verified_at
+ attr_reader :authorisation_source
+ attr_reader :consent_parameters
+ attr_reader :consent_type
+ attr_reader :created_at
+ attr_reader :funds_settlement
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :next_possible_charge_date
+ attr_reader :next_possible_standard_ach_charge_date
+ attr_reader :payments_require_approval
+ attr_reader :reference
+ attr_reader :scheme
+ attr_reader :status
+ attr_reader :verified_at
# Initialize a mandate resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/mandate_import.rb b/lib/gocardless_pro/resources/mandate_import.rb
index 98d08d9d..8dd94ed5 100644
--- a/lib/gocardless_pro/resources/mandate_import.rb
+++ b/lib/gocardless_pro/resources/mandate_import.rb
@@ -53,7 +53,10 @@ module Resources
# href="mailto:help@gocardless.com">get in touch if you would like to
# use this API.
class MandateImport
- attr_reader :created_at, :id, :scheme, :status
+ attr_reader :created_at
+ attr_reader :id
+ attr_reader :scheme
+ attr_reader :status
# Initialize a mandate_import resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/mandate_import_entry.rb b/lib/gocardless_pro/resources/mandate_import_entry.rb
index bb9e7f92..e485c9aa 100644
--- a/lib/gocardless_pro/resources/mandate_import_entry.rb
+++ b/lib/gocardless_pro/resources/mandate_import_entry.rb
@@ -41,7 +41,9 @@ module Resources
# href="mailto:help@gocardless.com">get in touch if you would like to
# use this API.
class MandateImportEntry
- attr_reader :created_at, :processing_errors, :record_identifier
+ attr_reader :created_at
+ attr_reader :processing_errors
+ attr_reader :record_identifier
# Initialize a mandate_import_entry resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/mandate_pdf.rb b/lib/gocardless_pro/resources/mandate_pdf.rb
index bd5428f4..2293032b 100644
--- a/lib/gocardless_pro/resources/mandate_pdf.rb
+++ b/lib/gocardless_pro/resources/mandate_pdf.rb
@@ -14,7 +14,8 @@ module Resources
# compliant](#appendix-compliance-requirements) Direct Debit mandates to
# your customers.
class MandatePdf
- attr_reader :expires_at, :url
+ attr_reader :expires_at
+ attr_reader :url
# Initialize a mandate_pdf resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/negative_balance_limit.rb b/lib/gocardless_pro/resources/negative_balance_limit.rb
index 167e8046..e51e1495 100644
--- a/lib/gocardless_pro/resources/negative_balance_limit.rb
+++ b/lib/gocardless_pro/resources/negative_balance_limit.rb
@@ -16,7 +16,10 @@ module Resources
# changed on a per-creditor basis.
#
class NegativeBalanceLimit
- attr_reader :balance_limit, :created_at, :currency, :id
+ attr_reader :balance_limit
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :id
# Initialize a negative_balance_limit resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/outbound_payment.rb b/lib/gocardless_pro/resources/outbound_payment.rb
index fafe8c3e..f68a8fb5 100644
--- a/lib/gocardless_pro/resources/outbound_payment.rb
+++ b/lib/gocardless_pro/resources/outbound_payment.rb
@@ -14,17 +14,31 @@ module Resources
# [creditors](#core-endpoints-creditors).
#
# GoCardless will notify you via a [webhook](#appendix-webhooks) when the
- # status of the outbound payment [changes](#event-actions-outbound-payment).
+ # status of the outbound payment [changes](#event-types-outbound-payment).
#
- # Restricted: Outbound
- # Payments are currently in Early Access and available only to a limited
- # list of organisations. If you are interested in using this feature, please
- # stay tuned for our public launch announcement. We are actively testing and
- # refining our API to ensure it meets your needs and provides the best
- # experience.
+ # ####Rate limiting
+ #
+ # Two rate limits apply to the Outbound Payments APIs:
+ # - All POST Outbound Payment endpoints (create, withdraw, approve, cancel
+ # and etc.) share a single rate-limit group of 300 requests per minute. As
+ # initiating a payment typically requires two API calls (one to create the
+ # payment and one to approve it), this allows you to add approximately 150
+ # outbound payments per minute.
+ # - All remaining Outbound Payment endpoints are limited to 500 requests per
+ # minute.
class OutboundPayment
- attr_reader :amount, :created_at, :currency, :description, :execution_date, :id, :is_withdrawal, :metadata,
- :reference, :scheme, :status, :verifications
+ attr_reader :amount
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :description
+ attr_reader :execution_date
+ attr_reader :id
+ attr_reader :is_withdrawal
+ attr_reader :metadata
+ attr_reader :reference
+ attr_reader :scheme
+ attr_reader :status
+ attr_reader :verifications
# Initialize a outbound_payment resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/payer_authorisation.rb b/lib/gocardless_pro/resources/payer_authorisation.rb
index 923dc340..79cce40c 100644
--- a/lib/gocardless_pro/resources/payer_authorisation.rb
+++ b/lib/gocardless_pro/resources/payer_authorisation.rb
@@ -69,7 +69,13 @@ module Resources
# your servers.
#
class PayerAuthorisation
- attr_reader :bank_account, :created_at, :customer, :id, :incomplete_fields, :mandate, :status
+ attr_reader :bank_account
+ attr_reader :created_at
+ attr_reader :customer
+ attr_reader :id
+ attr_reader :incomplete_fields
+ attr_reader :mandate
+ attr_reader :status
# Initialize a payer_authorisation resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/payment.rb b/lib/gocardless_pro/resources/payment.rb
index 56a82cdc..52addea2 100644
--- a/lib/gocardless_pro/resources/payment.rb
+++ b/lib/gocardless_pro/resources/payment.rb
@@ -18,8 +18,20 @@ module Resources
# GoCardless will notify you via a [webhook](#appendix-webhooks) whenever
# 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
+ attr_reader :amount
+ attr_reader :amount_refunded
+ attr_reader :charge_date
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :description
+ attr_reader :faster_ach
+ attr_reader :fx
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :reference
+ attr_reader :retry_if_possible
+ attr_reader :scheme
+ attr_reader :status
# Initialize a payment resource instance
# @param object [Hash] an object returned from the API
@@ -39,6 +51,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/lib/gocardless_pro/resources/payment_account.rb b/lib/gocardless_pro/resources/payment_account.rb
new file mode 100644
index 00000000..335d08ab
--- /dev/null
+++ b/lib/gocardless_pro/resources/payment_account.rb
@@ -0,0 +1,63 @@
+#
+# 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 payment_account resource returned from the API
+
+ # Access the details of bank accounts provided for you by GoCardless that
+ # are used to fund [Outbound Payments](#core-endpoints-outbound-payments).
+ class PaymentAccount
+ attr_reader :account_balance
+ attr_reader :account_holder_name
+ attr_reader :account_number_ending
+ attr_reader :bank_name
+ attr_reader :currency
+ attr_reader :id
+
+ # Initialize a payment_account resource instance
+ # @param object [Hash] an object returned from the API
+ def initialize(object, response = nil)
+ @object = object
+
+ @account_balance = object['account_balance']
+ @account_holder_name = object['account_holder_name']
+ @account_number_ending = object['account_number_ending']
+ @bank_name = object['bank_name']
+ @currency = object['currency']
+ @id = object['id']
+ @links = object['links']
+ @response = response
+ end
+
+ def api_response
+ ApiResponse.new(@response)
+ end
+
+ # Return the links that the resource has
+ def links
+ @payment_account_links ||= Links.new(@links)
+ end
+
+ # Provides the payment_account resource as a hash of all its readable attributes
+ def to_h
+ @object
+ end
+
+ class Links
+ def initialize(links)
+ @links = links || {}
+ end
+
+ def creditor
+ @links['creditor']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/resources/payment_account_transaction.rb b/lib/gocardless_pro/resources/payment_account_transaction.rb
new file mode 100644
index 00000000..eaf880fd
--- /dev/null
+++ b/lib/gocardless_pro/resources/payment_account_transaction.rb
@@ -0,0 +1,78 @@
+#
+# 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 payment_account_transaction resource returned from the API
+
+ # Payment account transactions represent movements of funds on a given
+ # payment account. The payment account is provisioned by GoCardless and is
+ # used to fund [outbound payments](#core-endpoints-outbound-payments).
+ class PaymentAccountTransaction
+ attr_reader :amount
+ attr_reader :balance_after_transaction
+ attr_reader :counterparty_name
+ attr_reader :currency
+ attr_reader :description
+ attr_reader :direction
+ attr_reader :id
+ attr_reader :reference
+ attr_reader :value_date
+
+ # Initialize a payment_account_transaction resource instance
+ # @param object [Hash] an object returned from the API
+ def initialize(object, response = nil)
+ @object = object
+
+ @amount = object['amount']
+ @balance_after_transaction = object['balance_after_transaction']
+ @counterparty_name = object['counterparty_name']
+ @currency = object['currency']
+ @description = object['description']
+ @direction = object['direction']
+ @id = object['id']
+ @links = object['links']
+ @reference = object['reference']
+ @value_date = object['value_date']
+ @response = response
+ end
+
+ def api_response
+ ApiResponse.new(@response)
+ end
+
+ # Return the links that the resource has
+ def links
+ @payment_account_transaction_links ||= Links.new(@links)
+ end
+
+ # Provides the payment_account_transaction resource as a hash of all its readable attributes
+ def to_h
+ @object
+ end
+
+ class Links
+ def initialize(links)
+ @links = links || {}
+ end
+
+ def outbound_payment
+ @links['outbound_payment']
+ end
+
+ def payment_bank_account
+ @links['payment_bank_account']
+ end
+
+ def payout
+ @links['payout']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/resources/payout.rb b/lib/gocardless_pro/resources/payout.rb
index 484d5ef7..b51aea41 100644
--- a/lib/gocardless_pro/resources/payout.rb
+++ b/lib/gocardless_pro/resources/payout.rb
@@ -17,8 +17,18 @@ module Resources
# Payouts are created automatically after a payment has been successfully
# collected.
class Payout
- attr_reader :amount, :arrival_date, :created_at, :currency, :deducted_fees, :fx, :id, :metadata, :payout_type,
- :reference, :status, :tax_currency
+ attr_reader :amount
+ attr_reader :arrival_date
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :deducted_fees
+ attr_reader :fx
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :payout_type
+ attr_reader :reference
+ attr_reader :status
+ attr_reader :tax_currency
# Initialize a payout resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/payout_item.rb b/lib/gocardless_pro/resources/payout_item.rb
index edf120df..d1bdd68e 100644
--- a/lib/gocardless_pro/resources/payout_item.rb
+++ b/lib/gocardless_pro/resources/payout_item.rb
@@ -33,7 +33,9 @@ module Resources
# 410 Gone.
#
class PayoutItem
- attr_reader :amount, :taxes, :type
+ attr_reader :amount
+ attr_reader :taxes
+ attr_reader :type
# Initialize a payout_item resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/redirect_flow.rb b/lib/gocardless_pro/resources/redirect_flow.rb
index c4525a49..1b0737f5 100644
--- a/lib/gocardless_pro/resources/redirect_flow.rb
+++ b/lib/gocardless_pro/resources/redirect_flow.rb
@@ -49,8 +49,16 @@ module Resources
# complete an expired redirect flow. For an integrator this is shorter and
# they will expire after 10 minutes.
class RedirectFlow
- attr_reader :confirmation_url, :created_at, :description, :id, :mandate_reference, :metadata, :redirect_url,
- :scheme, :session_token, :success_redirect_url
+ attr_reader :confirmation_url
+ attr_reader :created_at
+ attr_reader :description
+ attr_reader :id
+ attr_reader :mandate_reference
+ attr_reader :metadata
+ attr_reader :redirect_url
+ attr_reader :scheme
+ attr_reader :session_token
+ attr_reader :success_redirect_url
# Initialize a redirect_flow resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/refund.rb b/lib/gocardless_pro/resources/refund.rb
index 7f243f38..244c5b18 100644
--- a/lib/gocardless_pro/resources/refund.rb
+++ b/lib/gocardless_pro/resources/refund.rb
@@ -18,7 +18,14 @@ module Resources
# refund is created, and will update the `amount_refunded` property of the
# payment.
class Refund
- attr_reader :amount, :created_at, :currency, :fx, :id, :metadata, :reference, :status
+ attr_reader :amount
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :fx
+ attr_reader :id
+ attr_reader :metadata
+ attr_reader :reference
+ attr_reader :status
# Initialize a refund resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/scheme_identifier.rb b/lib/gocardless_pro/resources/scheme_identifier.rb
index 787052ce..7a638f27 100644
--- a/lib/gocardless_pro/resources/scheme_identifier.rb
+++ b/lib/gocardless_pro/resources/scheme_identifier.rb
@@ -15,8 +15,24 @@ module Resources
# on customers' bank statements.
#
class SchemeIdentifier
- attr_reader :address_line1, :address_line2, :address_line3, :can_specify_mandate_reference, :city, :country_code,
- :created_at, :currency, :email, :id, :minimum_advance_notice, :name, :phone_number, :postal_code, :reference, :region, :scheme, :status
+ attr_reader :address_line1
+ attr_reader :address_line2
+ attr_reader :address_line3
+ attr_reader :can_specify_mandate_reference
+ attr_reader :city
+ attr_reader :country_code
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :email
+ attr_reader :id
+ attr_reader :minimum_advance_notice
+ attr_reader :name
+ attr_reader :phone_number
+ attr_reader :postal_code
+ attr_reader :reference
+ attr_reader :region
+ attr_reader :scheme
+ attr_reader :status
# Initialize a scheme_identifier resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/subscription.rb b/lib/gocardless_pro/resources/subscription.rb
index 1f39e7eb..9a9badc9 100644
--- a/lib/gocardless_pro/resources/subscription.rb
+++ b/lib/gocardless_pro/resources/subscription.rb
@@ -68,8 +68,26 @@ module Resources
# - otherwise the charge date will be rolled __forwards__ to the next
# business day.
class Subscription
- attr_reader :amount, :app_fee, :count, :created_at, :currency, :day_of_month, :earliest_charge_date_after_resume,
- :end_date, :id, :interval, :interval_unit, :metadata, :month, :name, :parent_plan_paused, :payment_reference, :retry_if_possible, :start_date, :status, :upcoming_payments
+ attr_reader :amount
+ attr_reader :app_fee
+ attr_reader :count
+ attr_reader :created_at
+ attr_reader :currency
+ attr_reader :day_of_month
+ attr_reader :earliest_charge_date_after_resume
+ attr_reader :end_date
+ attr_reader :id
+ attr_reader :interval
+ attr_reader :interval_unit
+ attr_reader :metadata
+ attr_reader :month
+ attr_reader :name
+ attr_reader :parent_plan_paused
+ attr_reader :payment_reference
+ attr_reader :retry_if_possible
+ attr_reader :start_date
+ attr_reader :status
+ attr_reader :upcoming_payments
# Initialize a subscription resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/tax_rate.rb b/lib/gocardless_pro/resources/tax_rate.rb
index 6df5171f..a727b65f 100644
--- a/lib/gocardless_pro/resources/tax_rate.rb
+++ b/lib/gocardless_pro/resources/tax_rate.rb
@@ -15,7 +15,12 @@ module Resources
# We also maintain a [static list of the tax rates for each
# jurisdiction](#appendix-tax-rates).
class TaxRate
- attr_reader :end_date, :id, :jurisdiction, :percentage, :start_date, :type
+ attr_reader :end_date
+ attr_reader :id
+ attr_reader :jurisdiction
+ attr_reader :percentage
+ attr_reader :start_date
+ attr_reader :type
# Initialize a tax_rate resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/transferred_mandate.rb b/lib/gocardless_pro/resources/transferred_mandate.rb
index d67fd1dd..55b437ae 100644
--- a/lib/gocardless_pro/resources/transferred_mandate.rb
+++ b/lib/gocardless_pro/resources/transferred_mandate.rb
@@ -12,7 +12,9 @@ module Resources
# Mandates that have been transferred using Current Account Switch Service
class TransferredMandate
- attr_reader :encrypted_customer_bank_details, :encrypted_decryption_key, :public_key_id
+ attr_reader :encrypted_customer_bank_details
+ attr_reader :encrypted_decryption_key
+ attr_reader :public_key_id
# Initialize a transferred_mandate resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/verification_detail.rb b/lib/gocardless_pro/resources/verification_detail.rb
index 29e34dd0..df411dd6 100644
--- a/lib/gocardless_pro/resources/verification_detail.rb
+++ b/lib/gocardless_pro/resources/verification_detail.rb
@@ -22,8 +22,15 @@ module Resources
# your
# account.
class VerificationDetail
- attr_reader :address_line1, :address_line2, :address_line3, :city, :company_number, :description, :directors,
- :name, :postal_code
+ attr_reader :address_line1
+ attr_reader :address_line2
+ attr_reader :address_line3
+ attr_reader :city
+ attr_reader :company_number
+ attr_reader :description
+ attr_reader :directors
+ attr_reader :name
+ attr_reader :postal_code
# Initialize a verification_detail resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/resources/webhook.rb b/lib/gocardless_pro/resources/webhook.rb
index f7ca8cc8..691ae816 100644
--- a/lib/gocardless_pro/resources/webhook.rb
+++ b/lib/gocardless_pro/resources/webhook.rb
@@ -12,8 +12,19 @@ module Resources
# Basic description of a webhook
class Webhook
- attr_reader :created_at, :id, :is_test, :request_body, :request_headers, :response_body,
- :response_body_truncated, :response_code, :response_headers, :response_headers_content_truncated, :response_headers_count_truncated, :successful, :url
+ attr_reader :created_at
+ attr_reader :id
+ attr_reader :is_test
+ attr_reader :request_body
+ attr_reader :request_headers
+ attr_reader :response_body
+ attr_reader :response_body_truncated
+ attr_reader :response_code
+ attr_reader :response_headers
+ attr_reader :response_headers_content_truncated
+ attr_reader :response_headers_count_truncated
+ attr_reader :successful
+ attr_reader :url
# Initialize a webhook resource instance
# @param object [Hash] an object returned from the API
diff --git a/lib/gocardless_pro/services/bank_account_details_service.rb b/lib/gocardless_pro/services/bank_account_details_service.rb
index 173b9405..a9ddec76 100644
--- a/lib/gocardless_pro/services/bank_account_details_service.rb
+++ b/lib/gocardless_pro/services/bank_account_details_service.rb
@@ -11,14 +11,19 @@ module Services
# Service for making requests to the BankAccountDetail endpoints
class BankAccountDetailsService < BaseService
# Returns bank account details in the flattened JSON Web Encryption format
- # described in RFC 7516
+ # described in RFC 7516.
+ #
+ # You must specify a `Gc-Key-Id` header when using this endpoint. See [Public
+ # Key
+ # Setup](https://developer.gocardless.com/gc-embed/bank-details-access#public_key_setup)
+ # for more details.
# Example URL: /bank_account_details/:identity
#
# @param identity # Unique identifier, beginning with "BA".
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/bank_account_details/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
diff --git a/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb b/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb
new file mode 100644
index 00000000..8b5b8b5f
--- /dev/null
+++ b/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb
@@ -0,0 +1,86 @@
+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 BankAccountHolderVerification endpoints
+ class BankAccountHolderVerificationsService < BaseService
+ # Verify the account holder of the bank account. A complete verification can be
+ # attached when creating an outbound payment. This endpoint allows partner
+ # merchants to create Confirmation of Payee checks on customer bank accounts
+ # before sending outbound payments.
+ # Example URL: /bank_account_holder_verifications
+ # @param options [Hash] parameters as a hash, under a params key.
+ def create(options = {})
+ path = '/bank_account_holder_verifications'
+
+ params = options.delete(:params) || {}
+ options[:params] = {}
+ options[:params][envelope_key] = params
+
+ options[:retry_failures] = true
+
+ 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::BankAccountHolderVerification.new(unenvelope_body(response.body), response)
+ end
+
+ # Fetches a bank account holder verification by ID.
+ # Example URL: /bank_account_holder_verifications/:identity
+ #
+ # @param identity # The unique identifier for the bank account holder verification resource,
+ # e.g. "BAHV123".
+ # @param options [Hash] parameters as a hash, under a params key.
+ def get(identity, options = {})
+ path = sub_url('/bank_account_holder_verifications/:identity', {
+ 'identity' => identity,
+ })
+
+ options[:retry_failures] = true
+
+ response = make_request(:get, path, options)
+
+ return if response.body.nil?
+
+ Resources::BankAccountHolderVerification.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
+ 'bank_account_holder_verifications'
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/services/bank_authorisations_service.rb b/lib/gocardless_pro/services/bank_authorisations_service.rb
index 18ef3d42..8412f14c 100644
--- a/lib/gocardless_pro/services/bank_authorisations_service.rb
+++ b/lib/gocardless_pro/services/bank_authorisations_service.rb
@@ -52,7 +52,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/bank_authorisations/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
diff --git a/lib/gocardless_pro/services/billing_request_flows_service.rb b/lib/gocardless_pro/services/billing_request_flows_service.rb
index f4ac8f59..66c44119 100644
--- a/lib/gocardless_pro/services/billing_request_flows_service.rb
+++ b/lib/gocardless_pro/services/billing_request_flows_service.rb
@@ -38,7 +38,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def initialise(identity, options = {})
path = sub_url('/billing_request_flows/:identity/actions/initialise', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/billing_request_templates_service.rb b/lib/gocardless_pro/services/billing_request_templates_service.rb
index bab056c6..d368f5c4 100644
--- a/lib/gocardless_pro/services/billing_request_templates_service.rb
+++ b/lib/gocardless_pro/services/billing_request_templates_service.rb
@@ -46,7 +46,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/billing_request_templates/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -97,11 +97,11 @@ def create(options = {})
# Requests created by this template.
# Example URL: /billing_request_templates/:identity
#
- # @param identity # Unique identifier, beginning with "BRQ".
+ # @param identity # Unique identifier, beginning with "BRT".
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/billing_request_templates/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/billing_requests_service.rb b/lib/gocardless_pro/services/billing_requests_service.rb
index 4329974b..3b45d121 100644
--- a/lib/gocardless_pro/services/billing_requests_service.rb
+++ b/lib/gocardless_pro/services/billing_requests_service.rb
@@ -63,7 +63,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def collect_customer_details(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/collect_customer_details', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -124,7 +124,7 @@ def collect_customer_details(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def collect_bank_account(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/collect_bank_account', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -165,7 +165,7 @@ def collect_bank_account(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def confirm_payer_details(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/confirm_payer_details', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -205,7 +205,7 @@ def confirm_payer_details(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def fulfil(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/fulfil', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -245,7 +245,7 @@ def fulfil(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -313,7 +313,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/billing_requests/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -337,7 +337,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def notify(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/notify', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -377,7 +377,7 @@ def notify(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def fallback(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/fallback', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -422,7 +422,7 @@ def fallback(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def choose_currency(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/choose_currency', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -461,7 +461,7 @@ def choose_currency(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def select_institution(identity, options = {})
path = sub_url('/billing_requests/:identity/actions/select_institution', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/blocks_service.rb b/lib/gocardless_pro/services/blocks_service.rb
index eca428f8..8d57a98f 100644
--- a/lib/gocardless_pro/services/blocks_service.rb
+++ b/lib/gocardless_pro/services/blocks_service.rb
@@ -52,7 +52,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/blocks/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -100,7 +100,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def disable(identity, options = {})
path = sub_url('/blocks/:identity/actions/disable', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -139,7 +139,7 @@ def disable(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def enable(identity, options = {})
path = sub_url('/blocks/:identity/actions/enable', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb
index aefd047a..11becb96 100644
--- a/lib/gocardless_pro/services/creditor_bank_accounts_service.rb
+++ b/lib/gocardless_pro/services/creditor_bank_accounts_service.rb
@@ -81,7 +81,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/creditor_bank_accounts/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -107,7 +107,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def disable(identity, options = {})
path = sub_url('/creditor_bank_accounts/:identity/actions/disable', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/creditors_service.rb b/lib/gocardless_pro/services/creditors_service.rb
index 8fe0999d..f7b1d074 100644
--- a/lib/gocardless_pro/services/creditors_service.rb
+++ b/lib/gocardless_pro/services/creditors_service.rb
@@ -81,7 +81,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/creditors/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -101,7 +101,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/creditors/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/customer_bank_accounts_service.rb b/lib/gocardless_pro/services/customer_bank_accounts_service.rb
index 8c62dbe6..5dbf1673 100644
--- a/lib/gocardless_pro/services/customer_bank_accounts_service.rb
+++ b/lib/gocardless_pro/services/customer_bank_accounts_service.rb
@@ -93,7 +93,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/customer_bank_accounts/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -113,7 +113,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/customer_bank_accounts/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -142,7 +142,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def disable(identity, options = {})
path = sub_url('/customer_bank_accounts/:identity/actions/disable', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/customer_notifications_service.rb b/lib/gocardless_pro/services/customer_notifications_service.rb
index ac401752..e2423385 100644
--- a/lib/gocardless_pro/services/customer_notifications_service.rb
+++ b/lib/gocardless_pro/services/customer_notifications_service.rb
@@ -24,7 +24,7 @@ class CustomerNotificationsService < BaseService
# @param options [Hash] parameters as a hash, under a params key.
def handle(identity, options = {})
path = sub_url('/customer_notifications/:identity/actions/handle', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/customers_service.rb b/lib/gocardless_pro/services/customers_service.rb
index e176fa27..3aed5929 100644
--- a/lib/gocardless_pro/services/customers_service.rb
+++ b/lib/gocardless_pro/services/customers_service.rb
@@ -81,7 +81,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/customers/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -101,7 +101,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/customers/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -131,7 +131,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def remove(identity, options = {})
path = sub_url('/customers/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = false
diff --git a/lib/gocardless_pro/services/events_service.rb b/lib/gocardless_pro/services/events_service.rb
index 1f0ccb25..bea0c258 100644
--- a/lib/gocardless_pro/services/events_service.rb
+++ b/lib/gocardless_pro/services/events_service.rb
@@ -46,7 +46,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/events/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
diff --git a/lib/gocardless_pro/services/exports_service.rb b/lib/gocardless_pro/services/exports_service.rb
index 06acd6ed..c9584974 100644
--- a/lib/gocardless_pro/services/exports_service.rb
+++ b/lib/gocardless_pro/services/exports_service.rb
@@ -17,7 +17,7 @@ class ExportsService < BaseService
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/exports/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
diff --git a/lib/gocardless_pro/services/funds_availabilities_service.rb b/lib/gocardless_pro/services/funds_availabilities_service.rb
new file mode 100644
index 00000000..f87fb4a6
--- /dev/null
+++ b/lib/gocardless_pro/services/funds_availabilities_service.rb
@@ -0,0 +1,50 @@
+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 FundsAvailability endpoints
+ class FundsAvailabilitiesService < BaseService
+ # Checks if the payer's current balance is sufficient to cover the amount
+ # the merchant wants to charge within the consent parameters defined on the
+ # mandate.
+ # Example URL: /funds_availability/:identity
+ #
+ # @param identity # Unique identifier, beginning with "MD". Note that this prefix may not
+ # apply to mandates created before 2016.
+ # @param options [Hash] parameters as a hash, under a params key.
+ def check(identity, options = {})
+ path = sub_url('/funds_availability/:identity', {
+ 'identity' => identity,
+ })
+
+ options[:retry_failures] = false
+
+ response = make_request(:get, path, options)
+
+ return if response.body.nil?
+
+ Resources::FundsAvailability.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
+ 'funds_availability'
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/services/instalment_schedules_service.rb b/lib/gocardless_pro/services/instalment_schedules_service.rb
index 2f75dcec..8eab203c 100644
--- a/lib/gocardless_pro/services/instalment_schedules_service.rb
+++ b/lib/gocardless_pro/services/instalment_schedules_service.rb
@@ -147,7 +147,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/instalment_schedules/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -166,7 +166,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/instalment_schedules/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -193,7 +193,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/instalment_schedules/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/institutions_service.rb b/lib/gocardless_pro/services/institutions_service.rb
index 333b4d48..0a154a91 100644
--- a/lib/gocardless_pro/services/institutions_service.rb
+++ b/lib/gocardless_pro/services/institutions_service.rb
@@ -47,7 +47,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def list_for_billing_request(identity, options = {})
path = sub_url('/billing_requests/:identity/institutions', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = false
diff --git a/lib/gocardless_pro/services/mandate_imports_service.rb b/lib/gocardless_pro/services/mandate_imports_service.rb
index d52f6cf3..42476310 100644
--- a/lib/gocardless_pro/services/mandate_imports_service.rb
+++ b/lib/gocardless_pro/services/mandate_imports_service.rb
@@ -56,7 +56,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/mandate_imports/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -85,7 +85,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def submit(identity, options = {})
path = sub_url('/mandate_imports/:identity/actions/submit', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -130,7 +130,7 @@ def submit(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/mandate_imports/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/mandates_service.rb b/lib/gocardless_pro/services/mandates_service.rb
index 74a181fb..6b1cc0dc 100644
--- a/lib/gocardless_pro/services/mandates_service.rb
+++ b/lib/gocardless_pro/services/mandates_service.rb
@@ -82,7 +82,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/mandates/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -102,7 +102,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/mandates/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -131,7 +131,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/mandates/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -181,7 +181,7 @@ def cancel(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def reinstate(identity, options = {})
path = sub_url('/mandates/:identity/actions/reinstate', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/outbound_payments_service.rb b/lib/gocardless_pro/services/outbound_payments_service.rb
index 3df57cd6..a459cae1 100644
--- a/lib/gocardless_pro/services/outbound_payments_service.rb
+++ b/lib/gocardless_pro/services/outbound_payments_service.rb
@@ -91,7 +91,7 @@ def withdraw(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/outbound_payments/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -131,7 +131,7 @@ def cancel(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def approve(identity, options = {})
path = sub_url('/outbound_payments/:identity/actions/approve', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -170,7 +170,7 @@ def approve(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/outbound_payments/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -218,7 +218,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/outbound_payments/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -234,6 +234,21 @@ def update(identity, options = {})
Resources::OutboundPayment.new(unenvelope_body(response.body), response)
end
+ # Retrieve aggregate statistics on outbound payments.
+ # Example URL: /outbound_payments/stats
+ # @param options [Hash] parameters as a hash, under a params key.
+ def stats(options = {})
+ path = '/outbound_payments/stats'
+
+ options[:retry_failures] = false
+
+ response = make_request(:get, path, options)
+
+ return if response.body.nil?
+
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
+ end
+
private
# Unenvelope the response of the body using the service's `envelope_key`
diff --git a/lib/gocardless_pro/services/payer_authorisations_service.rb b/lib/gocardless_pro/services/payer_authorisations_service.rb
index 914aaa19..6322c445 100644
--- a/lib/gocardless_pro/services/payer_authorisations_service.rb
+++ b/lib/gocardless_pro/services/payer_authorisations_service.rb
@@ -18,7 +18,7 @@ class PayerAuthorisationsService < BaseService
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/payer_authorisations/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -85,7 +85,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/payer_authorisations/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -111,7 +111,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def submit(identity, options = {})
path = sub_url('/payer_authorisations/:identity/actions/submit', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -160,7 +160,7 @@ def submit(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def confirm(identity, options = {})
path = sub_url('/payer_authorisations/:identity/actions/confirm', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/payment_account_transactions_service.rb b/lib/gocardless_pro/services/payment_account_transactions_service.rb
new file mode 100644
index 00000000..d2f23b1e
--- /dev/null
+++ b/lib/gocardless_pro/services/payment_account_transactions_service.rb
@@ -0,0 +1,66 @@
+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 PaymentAccountTransaction endpoints
+ class PaymentAccountTransactionsService < BaseService
+ # List transactions for a given payment account.
+ # Example URL: /payment_accounts/:identity/transactions
+ #
+ # @param identity # The unique ID of the [bank
+ # account](#core-endpoints-creditor-bank-accounts) which happens to be the
+ # payment account.
+ # @param options [Hash] parameters as a hash, under a params key.
+ def list(identity, options = {})
+ path = sub_url('/payment_accounts/:identity/transactions', {
+ 'identity' => identity,
+ })
+
+ options[:retry_failures] = true
+
+ response = make_request(:get, path, options)
+
+ ListResponse.new(
+ response: response,
+ unenveloped_body: unenvelope_body(response.body),
+ resource_class: Resources::PaymentAccountTransaction
+ )
+ end
+
+ # Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
+ #
+ # @param identity # The unique ID of the [bank
+ # account](#core-endpoints-creditor-bank-accounts) which happens to be the
+ # payment account.
+ # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
+ # Otherwise they will be the body of the request.
+ def all(identity, options = {})
+ Paginator.new(
+ service: self,
+ options: options,
+ identity: identity
+ ).enumerator
+ 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
+ 'payment_account_transactions'
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/services/payment_accounts_service.rb b/lib/gocardless_pro/services/payment_accounts_service.rb
new file mode 100644
index 00000000..c586ad69
--- /dev/null
+++ b/lib/gocardless_pro/services/payment_accounts_service.rb
@@ -0,0 +1,76 @@
+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 PaymentAccount endpoints
+ class PaymentAccountsService < BaseService
+ # Retrieves the details of an existing payment account.
+ # Example URL: /payment_accounts/:identity
+ #
+ # @param identity # Unique identifier, beginning with "BA".
+ # @param options [Hash] parameters as a hash, under a params key.
+ def get(identity, options = {})
+ path = sub_url('/payment_accounts/:identity', {
+ 'identity' => identity,
+ })
+
+ options[:retry_failures] = true
+
+ response = make_request(:get, path, options)
+
+ return if response.body.nil?
+
+ Resources::PaymentAccount.new(unenvelope_body(response.body), response)
+ end
+
+ # Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your
+ # payment accounts.
+ # Example URL: /payment_accounts
+ # @param options [Hash] parameters as a hash, under a params key.
+ def list(options = {})
+ path = '/payment_accounts'
+
+ options[:retry_failures] = true
+
+ response = make_request(:get, path, options)
+
+ ListResponse.new(
+ response: response,
+ unenveloped_body: unenvelope_body(response.body),
+ resource_class: Resources::PaymentAccount
+ )
+ end
+
+ # Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
+ #
+ # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
+ # Otherwise they will be the body of the request.
+ def all(options = {})
+ Paginator.new(
+ service: self,
+ options: options
+ ).enumerator
+ 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
+ 'payment_accounts'
+ end
+ end
+ end
+end
diff --git a/lib/gocardless_pro/services/payments_service.rb b/lib/gocardless_pro/services/payments_service.rb
index 133b02e2..af97d5d0 100644
--- a/lib/gocardless_pro/services/payments_service.rb
+++ b/lib/gocardless_pro/services/payments_service.rb
@@ -86,7 +86,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/payments/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -105,7 +105,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/payments/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -133,7 +133,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/payments/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -181,7 +181,7 @@ def cancel(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def retry(identity, options = {})
path = sub_url('/payments/:identity/actions/retry', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/payouts_service.rb b/lib/gocardless_pro/services/payouts_service.rb
index 6a44e491..cf210a20 100644
--- a/lib/gocardless_pro/services/payouts_service.rb
+++ b/lib/gocardless_pro/services/payouts_service.rb
@@ -48,7 +48,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/payouts/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -67,7 +67,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/payouts/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/redirect_flows_service.rb b/lib/gocardless_pro/services/redirect_flows_service.rb
index 17c988fb..b200e2ac 100644
--- a/lib/gocardless_pro/services/redirect_flows_service.rb
+++ b/lib/gocardless_pro/services/redirect_flows_service.rb
@@ -53,7 +53,7 @@ def create(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/redirect_flows/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -81,7 +81,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def complete(identity, options = {})
path = sub_url('/redirect_flows/:identity/actions/complete', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/refunds_service.rb b/lib/gocardless_pro/services/refunds_service.rb
index 82b59d18..19303265 100644
--- a/lib/gocardless_pro/services/refunds_service.rb
+++ b/lib/gocardless_pro/services/refunds_service.rb
@@ -94,7 +94,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/refunds/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -113,7 +113,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/refunds/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/scenario_simulators_service.rb b/lib/gocardless_pro/services/scenario_simulators_service.rb
index 0b7e946b..43c98298 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
@@ -141,7 +147,7 @@ class ScenarioSimulatorsService < BaseService
# @param options [Hash] parameters as a hash, under a params key.
def run(identity, options = {})
path = sub_url('/scenario_simulators/:identity/actions/run', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/scheme_identifiers_service.rb b/lib/gocardless_pro/services/scheme_identifiers_service.rb
index 62f8719d..478cc4a7 100644
--- a/lib/gocardless_pro/services/scheme_identifiers_service.rb
+++ b/lib/gocardless_pro/services/scheme_identifiers_service.rb
@@ -120,7 +120,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/scheme_identifiers/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
diff --git a/lib/gocardless_pro/services/subscriptions_service.rb b/lib/gocardless_pro/services/subscriptions_service.rb
index fa98186c..938ff089 100644
--- a/lib/gocardless_pro/services/subscriptions_service.rb
+++ b/lib/gocardless_pro/services/subscriptions_service.rb
@@ -82,7 +82,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/subscriptions/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -124,7 +124,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def update(identity, options = {})
path = sub_url('/subscriptions/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -186,7 +186,7 @@ def update(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def pause(identity, options = {})
path = sub_url('/subscriptions/:identity/actions/pause', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -241,7 +241,7 @@ def pause(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def resume(identity, options = {})
path = sub_url('/subscriptions/:identity/actions/resume', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
@@ -285,7 +285,7 @@ def resume(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def cancel(identity, options = {})
path = sub_url('/subscriptions/:identity/actions/cancel', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/services/tax_rates_service.rb b/lib/gocardless_pro/services/tax_rates_service.rb
index 16fe9f2c..95b64583 100644
--- a/lib/gocardless_pro/services/tax_rates_service.rb
+++ b/lib/gocardless_pro/services/tax_rates_service.rb
@@ -46,7 +46,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/tax_rates/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
diff --git a/lib/gocardless_pro/services/transferred_mandates_service.rb b/lib/gocardless_pro/services/transferred_mandates_service.rb
index d9193932..6dac69d2 100644
--- a/lib/gocardless_pro/services/transferred_mandates_service.rb
+++ b/lib/gocardless_pro/services/transferred_mandates_service.rb
@@ -19,7 +19,7 @@ class TransferredMandatesService < BaseService
# @param options [Hash] parameters as a hash, under a params key.
def transferred_mandates(identity, options = {})
path = sub_url('/transferred_mandates/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = false
diff --git a/lib/gocardless_pro/services/webhooks_service.rb b/lib/gocardless_pro/services/webhooks_service.rb
index 9664be04..2de4cd6b 100644
--- a/lib/gocardless_pro/services/webhooks_service.rb
+++ b/lib/gocardless_pro/services/webhooks_service.rb
@@ -46,7 +46,7 @@ def all(options = {})
# @param options [Hash] parameters as a hash, under a params key.
def get(identity, options = {})
path = sub_url('/webhooks/:identity', {
- 'identity' => identity
+ 'identity' => identity,
})
options[:retry_failures] = true
@@ -65,7 +65,7 @@ def get(identity, options = {})
# @param options [Hash] parameters as a hash, under a params key.
def retry(identity, options = {})
path = sub_url('/webhooks/:identity/actions/retry', {
- 'identity' => identity
+ 'identity' => identity,
})
params = options.delete(:params) || {}
diff --git a/lib/gocardless_pro/version.rb b/lib/gocardless_pro/version.rb
index 9f6a1651..ee044f6e 100644
--- a/lib/gocardless_pro/version.rb
+++ b/lib/gocardless_pro/version.rb
@@ -3,5 +3,5 @@ module GoCardlessPro
module GoCardlessPro
# Current version of the GC gem
- VERSION = '4.2.0'
+ VERSION = '4.2.1'
end
diff --git a/spec/api_service_spec.rb b/spec/api_service_spec.rb
index d75827b8..697a1462 100644
--- a/spec/api_service_spec.rb
+++ b/spec/api_service_spec.rb
@@ -10,14 +10,14 @@
{
status: 200,
body: '{}',
- headers: { 'Content-Type' => 'application/json' }
+ headers: { 'Content-Type' => 'application/json' },
}
end
it 'uses basic auth' do
- stub = stub_request(:get, 'https://api.example.com/customers')
- .with(headers: { 'Authorization' => 'Bearer secret_token' })
- .to_return(default_response)
+ stub = stub_request(:get, 'https://api.example.com/customers').
+ with(headers: { 'Authorization' => 'Bearer secret_token' }).
+ to_return(default_response)
service.make_request(:get, '/customers')
expect(stub).to have_been_requested
@@ -25,17 +25,17 @@
describe 'making a get request without any parameters' do
it 'is expected to call the correct stub' do
- stub = stub_request(:get, %r{.*api.example.com/customers})
- .to_return(default_response)
+ stub = stub_request(:get, %r{.*api.example.com/customers}).
+ to_return(default_response)
service.make_request(:get, '/customers')
expect(stub).to have_been_requested
end
it "doesn't include an idempotency key" do
- stub = stub_request(:get, %r{.*api.example.com/customers})
- .with { |request| !request.headers.key?('Idempotency-Key') }
- .to_return(default_response)
+ stub = stub_request(:get, %r{.*api.example.com/customers}).
+ with { |request| !request.headers.key?('Idempotency-Key') }.
+ to_return(default_response)
service.make_request(:get, '/customers')
expect(stub).to have_been_requested
@@ -44,17 +44,17 @@
describe 'making a get request with query parameters' do
it 'correctly passes the query parameters' do
- stub = stub_request(:get, %r{.*api.example.com/customers\?a=1&b=2})
- .to_return(default_response)
+ stub = stub_request(:get, %r{.*api.example.com/customers\?a=1&b=2}).
+ to_return(default_response)
service.make_request(:get, '/customers', params: { a: 1, b: 2 })
expect(stub).to have_been_requested
end
it "doesn't include an idempotency key" do
- stub = stub_request(:get, %r{.*api.example.com/customers\?a=1&b=2})
- .with { |request| !request.headers.key?('Idempotency-Key') }
- .to_return(default_response)
+ stub = stub_request(:get, %r{.*api.example.com/customers\?a=1&b=2}).
+ with { |request| !request.headers.key?('Idempotency-Key') }.
+ to_return(default_response)
service.make_request(:get, '/customers', params: { a: 1, b: 2 })
expect(stub).to have_been_requested
@@ -63,13 +63,13 @@
describe 'making a post request with some data' do
it 'passes the data in as the post body' do
- stub = stub_request(:post, %r{.*api.example.com/customers})
- .with(body: { given_name: 'Jack', family_name: 'Franklin' })
- .to_return(default_response)
+ stub = stub_request(:post, %r{.*api.example.com/customers}).
+ with(body: { given_name: 'Jack', family_name: 'Franklin' }).
+ to_return(default_response)
service.make_request(:post, '/customers', params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
})
expect(stub).to have_been_requested
end
@@ -77,16 +77,16 @@
it 'generates a random idempotency key' do
allow(SecureRandom).to receive(:uuid).and_return('random-uuid')
- stub = stub_request(:post, %r{.*api.example.com/customers})
- .with(
+ stub = stub_request(:post, %r{.*api.example.com/customers}).
+ with(
body: { given_name: 'Jack', family_name: 'Franklin' },
headers: { 'Idempotency-Key' => 'random-uuid' }
- )
- .to_return(default_response)
+ ).
+ to_return(default_response)
service.make_request(:post, '/customers', params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
})
expect(stub).to have_been_requested
end
@@ -94,21 +94,21 @@
describe 'making a post request with data and custom header' do
it 'passes the data in as the post body' do
- stub = stub_request(:post, %r{.*api.example.com/customers})
- .with(
+ stub = stub_request(:post, %r{.*api.example.com/customers}).
+ with(
body: { given_name: 'Jack', family_name: 'Franklin' },
headers: { 'Foo' => 'Bar' }
- )
- .to_return(default_response)
+ ).
+ to_return(default_response)
service.make_request(:post, '/customers', {
params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
},
headers: {
- 'Foo' => 'Bar'
- }
+ 'Foo' => 'Bar',
+ },
})
expect(stub).to have_been_requested
end
@@ -116,42 +116,42 @@
it 'merges in a random idempotency key' do
allow(SecureRandom).to receive(:uuid).and_return('random-uuid')
- stub = stub_request(:post, %r{.*api.example.com/customers})
- .with(
+ stub = stub_request(:post, %r{.*api.example.com/customers}).
+ with(
body: { given_name: 'Jack', family_name: 'Franklin' },
headers: { 'Idempotency-Key' => 'random-uuid', 'Foo' => 'Bar' }
- )
- .to_return(default_response)
+ ).
+ to_return(default_response)
service.make_request(:post, '/customers', {
params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
},
headers: {
- 'Foo' => 'Bar'
- }
+ 'Foo' => 'Bar',
+ },
})
expect(stub).to have_been_requested
end
context 'with a custom idempotency key' do
it "doesn't replace it with a randomly-generated idempotency key" do
- stub = stub_request(:post, %r{.*api.example.com/customers})
- .with(
+ stub = stub_request(:post, %r{.*api.example.com/customers}).
+ with(
body: { given_name: 'Jack', family_name: 'Franklin' },
headers: { 'Idempotency-Key' => 'my-custom-idempotency-key' }
- )
- .to_return(default_response)
+ ).
+ to_return(default_response)
service.make_request(:post, '/customers', {
params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
},
headers: {
- 'Idempotency-Key' => 'my-custom-idempotency-key'
- }
+ 'Idempotency-Key' => 'my-custom-idempotency-key',
+ },
})
expect(stub).to have_been_requested
end
@@ -160,25 +160,25 @@
describe 'making a put request with some data' do
it 'passes the data in as the request body' do
- stub = stub_request(:put, %r{.*api.example.com/customers/CU123})
- .with(body: { given_name: 'Jack', family_name: 'Franklin' })
- .to_return(default_response)
+ stub = stub_request(:put, %r{.*api.example.com/customers/CU123}).
+ with(body: { given_name: 'Jack', family_name: 'Franklin' }).
+ to_return(default_response)
service.make_request(:put, '/customers/CU123', params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
})
expect(stub).to have_been_requested
end
it "doesn't include an idempotency key" do
- stub = stub_request(:put, %r{.*api.example.com/customers/CU123})
- .with { |request| !request.headers.key?('Idempotency-Key') }
- .to_return(default_response)
+ stub = stub_request(:put, %r{.*api.example.com/customers/CU123}).
+ with { |request| !request.headers.key?('Idempotency-Key') }.
+ to_return(default_response)
service.make_request(:put, '/customers/CU123', params: {
given_name: 'Jack',
- family_name: 'Franklin'
+ family_name: 'Franklin',
})
expect(stub).to have_been_requested
end
diff --git a/spec/client_spec.rb b/spec/client_spec.rb
index 36739074..67d98136 100644
--- a/spec/client_spec.rb
+++ b/spec/client_spec.rb
@@ -6,7 +6,7 @@
let(:options) do
{
environment: environment,
- token: token
+ token: token,
}
end
diff --git a/spec/error_spec.rb b/spec/error_spec.rb
index 4f0ce833..d7aee3a5 100644
--- a/spec/error_spec.rb
+++ b/spec/error_spec.rb
@@ -13,12 +13,12 @@
'errors' => [
{
'message' => 'must be a number',
- 'field' => 'branch_code'
+ 'field' => 'branch_code',
}, {
'message' => 'is the wrong length (should be 8 characters)',
- 'field' => 'branch_code'
+ 'field' => 'branch_code',
}
- ]
+ ],
}
end
@@ -28,8 +28,8 @@
specify { expect(error.message).to eq('Validation failed') }
specify do
- expect(error.to_s)
- .to eq('branch_code must be a number, '\
+ expect(error.to_s).
+ to eq('branch_code must be a number, '\
'branch_code is the wrong length (should be 8 characters)')
end
specify { expect(error.type).to eq('validation_failed') }
@@ -39,10 +39,10 @@
expect(error.errors).to eq([
{
'message' => 'must be a number',
- 'field' => 'branch_code'
+ 'field' => 'branch_code',
}, {
'message' => 'is the wrong length (should be 8 characters)',
- 'field' => 'branch_code'
+ 'field' => 'branch_code',
}
])
end
diff --git a/spec/middlewares/raise_gocardless_errors_spec.rb b/spec/middlewares/raise_gocardless_errors_spec.rb
index 3b9f8ef5..de1cfa2d 100644
--- a/spec/middlewares/raise_gocardless_errors_spec.rb
+++ b/spec/middlewares/raise_gocardless_errors_spec.rb
@@ -23,8 +23,8 @@
let(:status) { 514 }
it 'raises an error' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::ApiError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::ApiError)
end
end
@@ -32,8 +32,8 @@
let(:status) { 503 }
it 'raises an error' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::ApiError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::ApiError)
end
end
@@ -41,8 +41,8 @@
let(:status) { 200 }
it "doesn't raise an error" do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to_not raise_error(GoCardlessPro::ApiError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to_not raise_error(GoCardlessPro::ApiError)
end
end
@@ -59,8 +59,8 @@
let(:body) { { error: { type: 'validation_failed' } }.to_json }
it 'raises a ValidationError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::ValidationError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::ValidationError)
end
end
@@ -69,8 +69,8 @@
let(:body) { { error: { type: 'gocardless' } }.to_json }
it 'raises a GoCardlessError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::GoCardlessError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::GoCardlessError)
end
end
@@ -79,8 +79,8 @@
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
it 'raises a GoCardlessError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::PermissionError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::PermissionError)
end
end
@@ -89,8 +89,8 @@
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
it 'raises a GoCardlessError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::RateLimitError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::RateLimitError)
end
end
@@ -99,8 +99,8 @@
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
it 'raises a GoCardlessError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::AuthenticationError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::AuthenticationError)
end
end
@@ -109,8 +109,8 @@
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
it 'raises a InvalidApiUsageError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::InvalidApiUsageError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::InvalidApiUsageError)
end
end
@@ -119,8 +119,19 @@
let(:body) { { error: { type: 'invalid_state' } }.to_json }
it 'raises an InvalidStateError' do
- expect { connection.post('https://api.gocardless.com/widgets') }
- .to raise_error(GoCardlessPro::InvalidStateError)
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::InvalidStateError)
+ end
+ end
+
+ context 'for an unwrapped string error' do
+ let(:status) { 400 }
+ let(:body) { { error: 'unwrapped error' }.to_json }
+ it 'raises a wrapped error' do
+ expect { connection.post('https://api.gocardless.com/widgets') }.
+ to raise_error(GoCardlessPro::InvalidApiUsageError) do |error|
+ expect(error).to have_attributes({ message: 'unwrapped error' })
+ end
end
end
end
diff --git a/spec/paginator_spec.rb b/spec/paginator_spec.rb
new file mode 100644
index 00000000..70d09b08
--- /dev/null
+++ b/spec/paginator_spec.rb
@@ -0,0 +1,137 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Paginator do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe 'with URI parameters' do
+ it 'passes URI parameters through to list method on initial request' do
+ payment_account_id = 'BA123'
+
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts/#{payment_account_id}/transactions$}).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+ 'id' => 'PT001',
+ 'amount' => '100',
+ }],
+ meta: {
+ cursors: {},
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ results = client.payment_account_transactions.all(payment_account_id).to_a
+
+ expect(results.length).to eq(1)
+ expect(first_response_stub).to have_been_requested
+ end
+
+ it 'passes URI parameters through to list method on paginated requests' do
+ payment_account_id = 'BA123'
+
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts/#{payment_account_id}/transactions$}).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+ 'id' => 'PT001',
+ 'amount' => '100',
+ }],
+ meta: {
+ cursors: { after: 'cursor123' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts/#{payment_account_id}/transactions\?after=cursor123}).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+ 'id' => 'PT002',
+ 'amount' => '200',
+ }],
+ meta: {
+ cursors: {},
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ results = client.payment_account_transactions.all(payment_account_id).to_a
+
+ expect(results.length).to eq(2)
+ expect(results[0].id).to eq('PT001')
+ expect(results[1].id).to eq('PT002')
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested
+ end
+
+ it 'handles query parameters alongside URI parameters' do
+ payment_account_id = 'BA123'
+
+ stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts/#{payment_account_id}/transactions\?.*limit=5}).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+ 'id' => 'PT001',
+ 'amount' => '100',
+ }],
+ meta: {
+ cursors: {},
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ results = client.payment_account_transactions.all(payment_account_id, params: { limit: 5 }).to_a
+
+ expect(results.length).to eq(1)
+ expect(stub).to have_been_requested
+ end
+ end
+
+ describe 'without URI parameters' do
+ it 'works correctly for endpoints without URI parameters' do
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payments$}).to_return(
+ body: {
+ 'payments' => [{
+ 'id' => 'PM001',
+ 'amount' => '100',
+ }],
+ meta: {
+ cursors: { after: 'cursor123' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payments\?after=cursor123}).to_return(
+ body: {
+ 'payments' => [{
+ 'id' => 'PM002',
+ 'amount' => '200',
+ }],
+ meta: {
+ cursors: {},
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ results = client.payments.all.to_a
+
+ expect(results.length).to eq(2)
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested
+ end
+ end
+end
diff --git a/spec/resources/balance_spec.rb b/spec/resources/balance_spec.rb
index 97d833b2..7a4de851 100644
--- a/spec/resources/balance_spec.rb
+++ b/spec/resources/balance_spec.rb
@@ -22,14 +22,14 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -66,12 +66,12 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -86,12 +86,12 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/bank_account_detail_spec.rb b/spec/resources/bank_account_detail_spec.rb
index b62624fe..8f25d4bb 100644
--- a/spec/resources/bank_account_detail_spec.rb
+++ b/spec/resources/bank_account_detail_spec.rb
@@ -17,9 +17,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/bank_account_details/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'bank_account_details' => {
@@ -27,8 +27,8 @@
'encrypted_key' => 'encrypted_key-input',
'iv' => 'iv-input',
'protected' => 'protected-input',
- 'tag' => 'tag-input'
- }
+ 'tag' => 'tag-input',
+ },
}.to_json,
headers: response_headers
)
@@ -36,7 +36,7 @@
subject(:get_response) do
client.bank_account_details.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -57,8 +57,8 @@
'encrypted_key' => 'encrypted_key-input',
'iv' => 'iv-input',
'protected' => 'protected-input',
- 'tag' => 'tag-input'
- }
+ 'tag' => 'tag-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/bank_account_holder_verification_spec.rb b/spec/resources/bank_account_holder_verification_spec.rb
new file mode 100644
index 00000000..c6c1f275
--- /dev/null
+++ b/spec/resources/bank_account_holder_verification_spec.rb
@@ -0,0 +1,231 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Resources::BankAccountHolderVerification do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#create' do
+ subject(:post_create_response) { client.bank_account_holder_verifications.create(params: new_resource) }
+ context 'with a valid request' do
+ let(:new_resource) do
+ {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ }
+ end
+
+ before do
+ stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).
+ with(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }
+ ).
+ to_return(
+ body: {
+ 'bank_account_holder_verifications' =>
+
+ {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'creates and returns the resource' do
+ expect(post_create_response).to be_a(GoCardlessPro::Resources::BankAccountHolderVerification)
+ end
+ end
+
+ context 'with a request that returns a validation error' do
+ let(:new_resource) { {} }
+
+ before do
+ stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).to_return(
+ body: {
+ error: {
+ type: 'validation_failed',
+ code: 422,
+ errors: [
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
+ }.to_json,
+ headers: response_headers,
+ status: 422
+ )
+ end
+
+ it 'throws the correct error' do
+ expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
+ end
+ end
+
+ context 'with a request that returns an idempotent creation conflict error' do
+ let(:id) { 'ID123' }
+
+ let(:new_resource) do
+ {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ }
+ end
+
+ let!(:post_stub) do
+ stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).to_return(
+ body: {
+ error: {
+ type: 'invalid_state',
+ code: 409,
+ errors: [
+ {
+ message: 'A resource has already been created with this idempotency key',
+ reason: 'idempotent_creation_conflict',
+ links: {
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
+ }.to_json,
+ headers: response_headers,
+ status: 409
+ )
+ end
+
+ let!(:get_stub) do
+ stub_url = "/bank_account_holder_verifications/#{id}"
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'fetches the already-created resource' do
+ post_create_response
+ expect(post_stub).to have_been_requested
+ expect(get_stub).to have_been_requested
+ end
+ end
+ end
+
+ describe '#get' do
+ let(:id) { 'ID123' }
+
+ subject(:get_response) { client.bank_account_holder_verifications.get(id) }
+
+ context 'passing in a custom header' do
+ let!(:stub) do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ subject(:get_response) do
+ client.bank_account_holder_verifications.get(id, headers: {
+ 'Foo' => 'Bar',
+ })
+ end
+
+ it 'includes the header' do
+ get_response
+ expect(stub).to have_been_requested
+ end
+ end
+
+ context 'when there is a bank_account_holder_verification to return' do
+ before do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response in a resource' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::BankAccountHolderVerification)
+ end
+ end
+
+ context 'when nothing is returned' do
+ before do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: '',
+ headers: response_headers
+ )
+ end
+
+ it 'returns nil' do
+ expect(get_response).to be_nil
+ end
+ end
+
+ context "when an ID is specified which can't be included in a valid URI" do
+ let(:id) { '`' }
+
+ it "doesn't raise an error" do
+ expect { get_response }.to_not raise_error(/bad URI/)
+ end
+ end
+ end
+end
diff --git a/spec/resources/bank_authorisation_spec.rb b/spec/resources/bank_authorisation_spec.rb
index 5d30424a..04985753 100644
--- a/spec/resources/bank_authorisation_spec.rb
+++ b/spec/resources/bank_authorisation_spec.rb
@@ -24,13 +24,13 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/bank_authorisations})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/bank_authorisations}).
+ with(
body: {
'bank_authorisations' => {
@@ -43,11 +43,11 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'bank_authorisations' =>
@@ -62,8 +62,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
@@ -85,9 +85,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -114,7 +114,7 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
@@ -129,11 +129,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -142,8 +142,8 @@
let!(:get_stub) do
stub_url = "/bank_authorisations/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'bank_authorisations' => {
@@ -156,8 +156,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -179,9 +179,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/bank_authorisations/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'bank_authorisations' => {
@@ -194,8 +194,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -203,7 +203,7 @@
subject(:get_response) do
client.bank_authorisations.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -229,8 +229,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/bank_details_lookup_spec.rb b/spec/resources/bank_details_lookup_spec.rb
index 0b6d311a..384566ad 100644
--- a/spec/resources/bank_details_lookup_spec.rb
+++ b/spec/resources/bank_details_lookup_spec.rb
@@ -17,23 +17,23 @@
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
+ 'bic' => 'bic-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
+ with(
body: {
'bank_details_lookups' => {
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
- }
+ 'bic' => 'bic-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'bank_details_lookups' =>
@@ -41,8 +41,8 @@
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
- }
+ 'bic' => 'bic-input',
+ },
}.to_json,
headers: response_headers
@@ -64,9 +64,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -86,7 +86,7 @@
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
+ 'bic' => 'bic-input',
}
end
@@ -101,11 +101,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/resources/billing_request_flow_spec.rb b/spec/resources/billing_request_flow_spec.rb
index 5bf28cd0..47a1b29c 100644
--- a/spec/resources/billing_request_flow_spec.rb
+++ b/spec/resources/billing_request_flow_spec.rb
@@ -33,13 +33,13 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
+ 'skip_success_screen' => 'skip_success_screen-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_request_flows})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_request_flows}).
+ with(
body: {
'billing_request_flows' => {
@@ -61,11 +61,11 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_request_flows' =>
@@ -89,8 +89,8 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}.to_json,
headers: response_headers
@@ -112,9 +112,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -150,7 +150,7 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
+ 'skip_success_screen' => 'skip_success_screen-input',
}
end
@@ -165,11 +165,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -213,8 +213,8 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}.to_json,
headers: response_headers
@@ -237,8 +237,8 @@
let!(:stub) do
# /billing_request_flows/%v/actions/initialise
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -263,8 +263,8 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/billing_request_spec.rb b/spec/resources/billing_request_spec.rb
index cbf2150f..99085f6c 100644
--- a/spec/resources/billing_request_spec.rb
+++ b/spec/resources/billing_request_spec.rb
@@ -24,17 +24,19 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_requests})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_requests}).
+ with(
body: {
'billing_requests' => {
@@ -47,15 +49,17 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_requests' =>
@@ -70,12 +74,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -97,9 +103,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -126,11 +132,13 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}
end
@@ -145,11 +153,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -158,8 +166,8 @@
let!(:get_stub) do
stub_url = "/billing_requests/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'billing_requests' => {
@@ -172,12 +180,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -212,12 +222,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -240,8 +252,8 @@
let!(:stub) do
# /billing_requests/%v/actions/collect_customer_details
stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -257,12 +269,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -291,12 +305,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -319,8 +335,8 @@
let!(:stub) do
# /billing_requests/%v/actions/collect_bank_account
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -336,12 +352,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -370,12 +388,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -398,8 +418,8 @@
let!(:stub) do
# /billing_requests/%v/actions/confirm_payer_details
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -415,12 +435,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -449,12 +471,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -477,8 +501,8 @@
let!(:stub) do
# /billing_requests/%v/actions/fulfil
stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -494,12 +518,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -528,12 +554,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -556,8 +584,8 @@
let!(:stub) do
# /billing_requests/%v/actions/cancel
stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -573,12 +601,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -604,18 +634,20 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -642,6 +674,10 @@
expect(get_list_response.records.first.metadata).to eq('metadata-input')
+ expect(get_list_response.records.first.payment_context_code).to eq('payment_context_code-input')
+
+ expect(get_list_response.records.first.payment_purpose_code).to eq('payment_purpose_code-input')
+
expect(get_list_response.records.first.payment_request).to eq('payment_request-input')
expect(get_list_response.records.first.purpose_code).to eq('purpose_code-input')
@@ -677,16 +713,18 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -706,16 +744,18 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -736,9 +776,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'billing_requests' => {
@@ -751,12 +791,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -764,7 +806,7 @@
subject(:get_response) do
client.billing_requests.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -790,12 +832,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -850,12 +894,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -878,8 +924,8 @@
let!(:stub) do
# /billing_requests/%v/actions/notify
stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -895,12 +941,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -929,12 +977,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -957,8 +1007,8 @@
let!(:stub) do
# /billing_requests/%v/actions/fallback
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -974,12 +1024,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1008,12 +1060,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -1036,8 +1090,8 @@
let!(:stub) do
# /billing_requests/%v/actions/choose_currency
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1053,12 +1107,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1087,12 +1143,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -1115,8 +1173,8 @@
let!(:stub) do
# /billing_requests/%v/actions/select_institution
stub_url = '/billing_requests/:identity/actions/select_institution'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1132,12 +1190,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/billing_request_template_spec.rb b/spec/resources/billing_request_template_spec.rb
index c19b4d71..c052e662 100644
--- a/spec/resources/billing_request_template_spec.rb
+++ b/spec/resources/billing_request_template_spec.rb
@@ -35,14 +35,14 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -122,12 +122,12 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -155,12 +155,12 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -181,9 +181,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/billing_request_templates/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'billing_request_templates' => {
@@ -204,8 +204,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -213,7 +213,7 @@
subject(:get_response) do
client.billing_request_templates.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -247,8 +247,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -305,13 +305,13 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_request_templates})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_request_templates}).
+ with(
body: {
'billing_request_templates' => {
@@ -332,11 +332,11 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_request_templates' =>
@@ -359,8 +359,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -382,9 +382,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -419,7 +419,7 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
@@ -434,11 +434,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -447,8 +447,8 @@
let!(:get_stub) do
stub_url = "/billing_request_templates/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'billing_request_templates' => {
@@ -469,8 +469,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -514,8 +514,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/billing_request_with_action_spec.rb b/spec/resources/billing_request_with_action_spec.rb
index 9fe5b90b..cfa32662 100644
--- a/spec/resources/billing_request_with_action_spec.rb
+++ b/spec/resources/billing_request_with_action_spec.rb
@@ -16,30 +16,30 @@
{
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
+ 'billing_requests' => 'billing_requests-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions}).
+ with(
body: {
'billing_request_with_actions' => {
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
- }
+ 'billing_requests' => 'billing_requests-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_request_with_actions' =>
{
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
- }
+ 'billing_requests' => 'billing_requests-input',
+ },
}.to_json,
headers: response_headers
@@ -61,9 +61,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -82,7 +82,7 @@
{
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
+ 'billing_requests' => 'billing_requests-input',
}
end
@@ -97,11 +97,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/resources/block_spec.rb b/spec/resources/block_spec.rb
index b9cb4ee0..a3a39401 100644
--- a/spec/resources/block_spec.rb
+++ b/spec/resources/block_spec.rb
@@ -22,13 +22,13 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/blocks})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/blocks}).
+ with(
body: {
'blocks' => {
@@ -39,11 +39,11 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'blocks' =>
@@ -56,8 +56,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -79,9 +79,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -106,7 +106,7 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
@@ -121,11 +121,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -134,8 +134,8 @@
let!(:get_stub) do
stub_url = "/blocks/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'blocks' => {
@@ -146,8 +146,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -169,9 +169,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/blocks/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'blocks' => {
@@ -182,8 +182,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -191,7 +191,7 @@
subject(:get_response) do
client.blocks.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -215,8 +215,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -266,14 +266,14 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -321,12 +321,12 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -344,12 +344,12 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -381,8 +381,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -405,8 +405,8 @@
let!(:stub) do
# /blocks/%v/actions/disable
stub_url = '/blocks/:identity/actions/disable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -420,8 +420,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -448,8 +448,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -472,8 +472,8 @@
let!(:stub) do
# /blocks/%v/actions/enable
stub_url = '/blocks/:identity/actions/enable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -487,8 +487,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -515,14 +515,14 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
@@ -548,8 +548,8 @@
let!(:stub) do
# /blocks/block_by_ref
stub_url = '/blocks/block_by_ref'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -563,8 +563,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/creditor_bank_account_spec.rb b/spec/resources/creditor_bank_account_spec.rb
index 8dbe2886..fb787d2d 100644
--- a/spec/resources/creditor_bank_account_spec.rb
+++ b/spec/resources/creditor_bank_account_spec.rb
@@ -26,13 +26,13 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).
+ with(
body: {
'creditor_bank_accounts' => {
@@ -47,11 +47,11 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'creditor_bank_accounts' =>
@@ -68,8 +68,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
@@ -91,9 +91,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -122,7 +122,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
@@ -137,11 +137,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -150,8 +150,8 @@
let!(:get_stub) do
stub_url = "/creditor_bank_accounts/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'creditor_bank_accounts' => {
@@ -166,8 +166,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -201,14 +201,14 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -268,12 +268,12 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -295,12 +295,12 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -321,9 +321,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'creditor_bank_accounts' => {
@@ -338,8 +338,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -347,7 +347,7 @@
subject(:get_response) do
client.creditor_bank_accounts.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -375,8 +375,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -433,8 +433,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
@@ -457,8 +457,8 @@
let!(:stub) do
# /creditor_bank_accounts/%v/actions/disable
stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -476,8 +476,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/creditor_spec.rb b/spec/resources/creditor_spec.rb
index 36a1c08f..ee69ab27 100644
--- a/spec/resources/creditor_spec.rb
+++ b/spec/resources/creditor_spec.rb
@@ -35,13 +35,13 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/creditors})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/creditors}).
+ with(
body: {
'creditors' => {
@@ -65,11 +65,11 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'creditors' =>
@@ -95,8 +95,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
@@ -118,9 +118,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -158,7 +158,7 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
@@ -173,11 +173,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -186,8 +186,8 @@
let!(:get_stub) do
stub_url = "/creditors/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'creditors' => {
@@ -211,8 +211,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -255,14 +255,14 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -347,12 +347,12 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -383,12 +383,12 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -409,9 +409,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/creditors/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'creditors' => {
@@ -435,8 +435,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -444,7 +444,7 @@
subject(:get_response) do
client.creditors.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -481,8 +481,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -549,8 +549,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/currency_exchange_rate_spec.rb b/spec/resources/currency_exchange_rate_spec.rb
index 64e4512a..d0f97eab 100644
--- a/spec/resources/currency_exchange_rate_spec.rb
+++ b/spec/resources/currency_exchange_rate_spec.rb
@@ -21,14 +21,14 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -66,12 +66,12 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -85,12 +85,12 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/customer_bank_account_spec.rb b/spec/resources/customer_bank_account_spec.rb
index c6b2a6d7..2ee9f7d2 100644
--- a/spec/resources/customer_bank_account_spec.rb
+++ b/spec/resources/customer_bank_account_spec.rb
@@ -26,13 +26,13 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
+ with(
body: {
'customer_bank_accounts' => {
@@ -47,11 +47,11 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'customer_bank_accounts' =>
@@ -68,8 +68,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
@@ -91,9 +91,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -122,7 +122,7 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}
end
@@ -137,11 +137,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -150,8 +150,8 @@
let!(:get_stub) do
stub_url = "/customer_bank_accounts/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'customer_bank_accounts' => {
@@ -166,8 +166,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -201,14 +201,14 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -268,12 +268,12 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -295,12 +295,12 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -321,9 +321,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'customer_bank_accounts' => {
@@ -338,8 +338,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -347,7 +347,7 @@
subject(:get_response) do
client.customer_bank_accounts.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -375,8 +375,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -434,8 +434,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -471,8 +471,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
@@ -495,8 +495,8 @@
let!(:stub) do
# /customer_bank_accounts/%v/actions/disable
stub_url = '/customer_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -514,8 +514,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/customer_notification_spec.rb b/spec/resources/customer_notification_spec.rb
index 31e4156c..8bf0d3d1 100644
--- a/spec/resources/customer_notification_spec.rb
+++ b/spec/resources/customer_notification_spec.rb
@@ -26,8 +26,8 @@
'action_taken_by' => 'action_taken_by-input',
'id' => 'id-input',
'links' => 'links-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
@@ -50,8 +50,8 @@
let!(:stub) do
# /customer_notifications/%v/actions/handle
stub_url = '/customer_notifications/:identity/actions/handle'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -63,8 +63,8 @@
'action_taken_by' => 'action_taken_by-input',
'id' => 'id-input',
'links' => 'links-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/customer_spec.rb b/spec/resources/customer_spec.rb
index 2c0154d8..6f866229 100644
--- a/spec/resources/customer_spec.rb
+++ b/spec/resources/customer_spec.rb
@@ -32,13 +32,13 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/customers})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/customers}).
+ with(
body: {
'customers' => {
@@ -59,11 +59,11 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'customers' =>
@@ -86,8 +86,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
@@ -109,9 +109,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -146,7 +146,7 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}
end
@@ -161,11 +161,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -174,8 +174,8 @@
let!(:get_stub) do
stub_url = "/customers/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'customers' => {
@@ -196,8 +196,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -237,14 +237,14 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -322,12 +322,12 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -355,12 +355,12 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -381,9 +381,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/customers/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'customers' => {
@@ -404,8 +404,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -413,7 +413,7 @@
subject(:get_response) do
client.customers.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -447,8 +447,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -512,8 +512,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -555,8 +555,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
@@ -579,8 +579,8 @@
let!(:stub) do
# /customers/%v
stub_url = '/customers/:identity'.gsub(':identity', resource_id)
- stub_request(:delete, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:delete, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -604,8 +604,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/event_spec.rb b/spec/resources/event_spec.rb
index 25721616..02a44975 100644
--- a/spec/resources/event_spec.rb
+++ b/spec/resources/event_spec.rb
@@ -26,14 +26,15 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -57,6 +58,8 @@
expect(get_list_response.records.first.resource_metadata).to eq('resource_metadata-input')
expect(get_list_response.records.first.resource_type).to eq('resource_type-input')
+
+ expect(get_list_response.records.first.source).to eq('source-input')
end
it 'exposes the cursors for before and after' do
@@ -82,12 +85,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -106,12 +110,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -132,9 +137,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/events/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'events' => {
@@ -146,8 +151,9 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
- }
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
+ },
}.to_json,
headers: response_headers
)
@@ -155,7 +161,7 @@
subject(:get_response) do
client.events.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -180,8 +186,9 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
- }
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/export_spec.rb b/spec/resources/export_spec.rb
index b54a7f29..701e942f 100644
--- a/spec/resources/export_spec.rb
+++ b/spec/resources/export_spec.rb
@@ -17,9 +17,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/exports/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'exports' => {
@@ -27,8 +27,8 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
)
@@ -36,7 +36,7 @@
subject(:get_response) do
client.exports.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -57,8 +57,8 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
)
@@ -105,14 +105,14 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -151,12 +151,12 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -171,12 +171,12 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/funds_availability_spec.rb b/spec/resources/funds_availability_spec.rb
new file mode 100644
index 00000000..c94bdce5
--- /dev/null
+++ b/spec/resources/funds_availability_spec.rb
@@ -0,0 +1,64 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Resources::FundsAvailability do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#check' do
+ subject(:get_response) { client.funds_availabilities.check(resource_id) }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /funds_availability/%v
+ stub_url = '/funds_availability/:identity'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'funds_availability' => {
+
+ 'available' => 'available-input',
+ },
+ }.to_json,
+
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response and calls the right endpoint' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::FundsAvailability)
+
+ expect(stub).to have_been_requested
+ end
+
+ context 'when the request needs a body and custom header' do
+ let(:body) { { foo: 'bar' } }
+ let(:headers) { { 'Foo' => 'Bar' } }
+ subject(:get_response) { client.funds_availabilities.check(resource_id, body, headers) }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /funds_availability/%v
+ stub_url = '/funds_availability/:identity'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
+ body: { foo: 'bar' },
+ headers: { 'Foo' => 'Bar' }
+ ).to_return(
+ body: {
+ 'funds_availability' => {
+
+ 'available' => 'available-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+ end
+ end
+end
diff --git a/spec/resources/instalment_schedule_spec.rb b/spec/resources/instalment_schedule_spec.rb
index b997690d..c7b40293 100644
--- a/spec/resources/instalment_schedule_spec.rb
+++ b/spec/resources/instalment_schedule_spec.rb
@@ -23,13 +23,13 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ with(
body: {
'instalment_schedules' => {
@@ -41,11 +41,11 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'instalment_schedules' =>
@@ -59,8 +59,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
@@ -82,9 +82,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -110,7 +110,7 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
@@ -125,11 +125,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -138,8 +138,8 @@
let!(:get_stub) do
stub_url = "/instalment_schedules/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'instalment_schedules' => {
@@ -151,8 +151,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -180,13 +180,13 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ with(
body: {
'instalment_schedules' => {
@@ -198,11 +198,11 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'instalment_schedules' =>
@@ -216,8 +216,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
@@ -239,9 +239,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -267,7 +267,7 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
@@ -282,11 +282,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -295,8 +295,8 @@
let!(:get_stub) do
stub_url = "/instalment_schedules/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'instalment_schedules' => {
@@ -308,8 +308,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -340,14 +340,14 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -398,12 +398,12 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -422,12 +422,12 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -448,9 +448,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'instalment_schedules' => {
@@ -462,8 +462,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -471,7 +471,7 @@
subject(:get_response) do
client.instalment_schedules.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -496,8 +496,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -552,8 +552,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -586,8 +586,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
@@ -610,8 +610,8 @@
let!(:stub) do
# /instalment_schedules/%v/actions/cancel
stub_url = '/instalment_schedules/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -626,8 +626,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/institution_spec.rb b/spec/resources/institution_spec.rb
index eb88a6d2..bb926067 100644
--- a/spec/resources/institution_spec.rb
+++ b/spec/resources/institution_spec.rb
@@ -25,14 +25,14 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -80,12 +80,12 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -103,12 +103,12 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -140,14 +140,14 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
@@ -175,8 +175,8 @@
let!(:stub) do
# /billing_requests/%v/institutions
stub_url = '/billing_requests/:identity/institutions'.gsub(':identity', resource_id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -190,8 +190,8 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/logo_spec.rb b/spec/resources/logo_spec.rb
index 289a2c80..4e20624b 100644
--- a/spec/resources/logo_spec.rb
+++ b/spec/resources/logo_spec.rb
@@ -15,28 +15,28 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/branding/logos})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/branding/logos}).
+ with(
body: {
'logos' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'logos' =>
{
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
@@ -58,9 +58,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -78,7 +78,7 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
@@ -93,11 +93,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/resources/mandate_import_entry_spec.rb b/spec/resources/mandate_import_entry_spec.rb
index 07dbc1a3..f4877a24 100644
--- a/spec/resources/mandate_import_entry_spec.rb
+++ b/spec/resources/mandate_import_entry_spec.rb
@@ -18,24 +18,24 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries}).
+ with(
body: {
'mandate_import_entries' => {
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
- }
+ 'record_identifier' => 'record_identifier-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandate_import_entries' =>
@@ -44,8 +44,8 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
- }
+ 'record_identifier' => 'record_identifier-input',
+ },
}.to_json,
headers: response_headers
@@ -67,9 +67,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -90,7 +90,7 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}
end
@@ -105,11 +105,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -135,14 +135,14 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -178,12 +178,12 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -197,12 +197,12 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/mandate_import_spec.rb b/spec/resources/mandate_import_spec.rb
index c86ba3f5..93322b44 100644
--- a/spec/resources/mandate_import_spec.rb
+++ b/spec/resources/mandate_import_spec.rb
@@ -19,13 +19,13 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandate_imports})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandate_imports}).
+ with(
body: {
'mandate_imports' => {
@@ -33,11 +33,11 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandate_imports' =>
@@ -47,8 +47,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -70,9 +70,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -94,7 +94,7 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -109,11 +109,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -122,8 +122,8 @@
let!(:get_stub) do
stub_url = "/mandate_imports/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'mandate_imports' => {
@@ -131,8 +131,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -154,9 +154,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/mandate_imports/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'mandate_imports' => {
@@ -164,8 +164,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -173,7 +173,7 @@
subject(:get_response) do
client.mandate_imports.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -194,8 +194,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -245,8 +245,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -269,8 +269,8 @@
let!(:stub) do
# /mandate_imports/%v/actions/submit
stub_url = '/mandate_imports/:identity/actions/submit'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -281,8 +281,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -306,8 +306,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -330,8 +330,8 @@
let!(:stub) do
# /mandate_imports/%v/actions/cancel
stub_url = '/mandate_imports/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -342,8 +342,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/mandate_pdf_spec.rb b/spec/resources/mandate_pdf_spec.rb
index 526cefaf..4d500f97 100644
--- a/spec/resources/mandate_pdf_spec.rb
+++ b/spec/resources/mandate_pdf_spec.rb
@@ -16,30 +16,30 @@
{
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
+ with(
body: {
'mandate_pdfs' => {
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandate_pdfs' =>
{
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
@@ -61,9 +61,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -82,7 +82,7 @@
{
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
@@ -97,11 +97,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/resources/mandate_spec.rb b/spec/resources/mandate_spec.rb
index 022be389..bba878a2 100644
--- a/spec/resources/mandate_spec.rb
+++ b/spec/resources/mandate_spec.rb
@@ -29,13 +29,13 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandates})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandates}).
+ with(
body: {
'mandates' => {
@@ -53,11 +53,11 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandates' =>
@@ -77,8 +77,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
@@ -100,9 +100,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -134,7 +134,7 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}
end
@@ -149,11 +149,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -162,8 +162,8 @@
let!(:get_stub) do
stub_url = "/mandates/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'mandates' => {
@@ -181,8 +181,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -219,14 +219,14 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -293,12 +293,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -323,12 +323,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -349,9 +349,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/mandates/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'mandates' => {
@@ -369,8 +369,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -378,7 +378,7 @@
subject(:get_response) do
client.mandates.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -409,8 +409,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -471,8 +471,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -511,8 +511,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
@@ -535,8 +535,8 @@
let!(:stub) do
# /mandates/%v/actions/cancel
stub_url = '/mandates/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -557,8 +557,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -592,8 +592,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
@@ -616,8 +616,8 @@
let!(:stub) do
# /mandates/%v/actions/reinstate
stub_url = '/mandates/:identity/actions/reinstate'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -638,8 +638,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/negative_balance_limit_spec.rb b/spec/resources/negative_balance_limit_spec.rb
index 7f0e321b..78d0f8e1 100644
--- a/spec/resources/negative_balance_limit_spec.rb
+++ b/spec/resources/negative_balance_limit_spec.rb
@@ -22,14 +22,14 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -68,12 +68,12 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -88,12 +88,12 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/outbound_payment_spec.rb b/spec/resources/outbound_payment_spec.rb
index bca96355..59b73238 100644
--- a/spec/resources/outbound_payment_spec.rb
+++ b/spec/resources/outbound_payment_spec.rb
@@ -27,13 +27,13 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/outbound_payments})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/outbound_payments}).
+ with(
body: {
'outbound_payments' => {
@@ -49,11 +49,11 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'outbound_payments' =>
@@ -71,8 +71,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -94,9 +94,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -126,7 +126,7 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}
end
@@ -141,11 +141,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -154,8 +154,8 @@
let!(:get_stub) do
stub_url = "/outbound_payments/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'outbound_payments' => {
@@ -171,8 +171,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -210,8 +210,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -232,8 +232,8 @@
let!(:stub) do
# /outbound_payments/withdrawal
stub_url = '/outbound_payments/withdrawal'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -252,8 +252,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -285,8 +285,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -309,8 +309,8 @@
let!(:stub) do
# /outbound_payments/%v/actions/cancel
stub_url = '/outbound_payments/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -329,8 +329,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -362,8 +362,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -386,8 +386,8 @@
let!(:stub) do
# /outbound_payments/%v/actions/approve
stub_url = '/outbound_payments/:identity/actions/approve'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -406,8 +406,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -423,9 +423,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/outbound_payments/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'outbound_payments' => {
@@ -441,8 +441,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -450,7 +450,7 @@
subject(:get_response) do
client.outbound_payments.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -479,8 +479,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -535,14 +535,14 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -605,12 +605,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -633,12 +633,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -676,8 +676,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -689,4 +689,79 @@
end
end
end
+
+ describe '#stats' do
+ subject(:get_response) { client.outbound_payments.stats }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /outbound_payments/stats
+ stub_url = '/outbound_payments/stats'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'outbound_payments' => {
+
+ 'amount' => 'amount-input',
+ 'created_at' => 'created_at-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'execution_date' => 'execution_date-input',
+ 'id' => 'id-input',
+ 'is_withdrawal' => 'is_withdrawal-input',
+ 'links' => 'links-input',
+ 'metadata' => 'metadata-input',
+ 'reference' => 'reference-input',
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ 'verifications' => 'verifications-input',
+ },
+ }.to_json,
+
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response and calls the right endpoint' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::OutboundPayment)
+
+ expect(stub).to have_been_requested
+ end
+
+ context 'when the request needs a body and custom header' do
+ subject(:get_response) { client.outbound_payments.stats(body, headers) }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /outbound_payments/stats
+ stub_url = '/outbound_payments/stats'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
+ body: { foo: 'bar' },
+ headers: { 'Foo' => 'Bar' }
+ ).to_return(
+ body: {
+ 'outbound_payments' => {
+
+ 'amount' => 'amount-input',
+ 'created_at' => 'created_at-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'execution_date' => 'execution_date-input',
+ 'id' => 'id-input',
+ 'is_withdrawal' => 'is_withdrawal-input',
+ 'links' => 'links-input',
+ 'metadata' => 'metadata-input',
+ 'reference' => 'reference-input',
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ 'verifications' => 'verifications-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+ end
+ end
end
diff --git a/spec/resources/payer_authorisation_spec.rb b/spec/resources/payer_authorisation_spec.rb
index 9c4c6214..d12f790e 100644
--- a/spec/resources/payer_authorisation_spec.rb
+++ b/spec/resources/payer_authorisation_spec.rb
@@ -17,9 +17,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/payer_authorisations/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'payer_authorisations' => {
@@ -30,8 +30,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -39,7 +39,7 @@
subject(:get_response) do
client.payer_authorisations.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -63,8 +63,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -111,13 +111,13 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/payer_authorisations})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/payer_authorisations}).
+ with(
body: {
'payer_authorisations' => {
@@ -128,11 +128,11 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'payer_authorisations' =>
@@ -145,8 +145,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -168,9 +168,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -195,7 +195,7 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -210,11 +210,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -223,8 +223,8 @@
let!(:get_stub) do
stub_url = "/payer_authorisations/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'payer_authorisations' => {
@@ -235,8 +235,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -270,8 +270,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -303,8 +303,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -327,8 +327,8 @@
let!(:stub) do
# /payer_authorisations/%v/actions/submit
stub_url = '/payer_authorisations/:identity/actions/submit'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -342,8 +342,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -370,8 +370,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -394,8 +394,8 @@
let!(:stub) do
# /payer_authorisations/%v/actions/confirm
stub_url = '/payer_authorisations/:identity/actions/confirm'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -409,8 +409,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/payer_theme_spec.rb b/spec/resources/payer_theme_spec.rb
index 5eec7d5f..f5d03815 100644
--- a/spec/resources/payer_theme_spec.rb
+++ b/spec/resources/payer_theme_spec.rb
@@ -15,28 +15,28 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes}).
+ with(
body: {
'payer_themes' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'payer_themes' =>
{
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
@@ -58,9 +58,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -78,7 +78,7 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
@@ -93,11 +93,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/resources/payment_account_spec.rb b/spec/resources/payment_account_spec.rb
new file mode 100644
index 00000000..b6654b54
--- /dev/null
+++ b/spec/resources/payment_account_spec.rb
@@ -0,0 +1,205 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Resources::PaymentAccount do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#get' do
+ let(:id) { 'ID123' }
+
+ subject(:get_response) { client.payment_accounts.get(id) }
+
+ context 'passing in a custom header' do
+ let!(:stub) do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
+ body: {
+ 'payment_accounts' => {
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ subject(:get_response) do
+ client.payment_accounts.get(id, headers: {
+ 'Foo' => 'Bar',
+ })
+ end
+
+ it 'includes the header' do
+ get_response
+ expect(stub).to have_been_requested
+ end
+ end
+
+ context 'when there is a payment_account to return' do
+ before do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'payment_accounts' => {
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response in a resource' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::PaymentAccount)
+ end
+ end
+
+ context 'when nothing is returned' do
+ before do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: '',
+ headers: response_headers
+ )
+ end
+
+ it 'returns nil' do
+ expect(get_response).to be_nil
+ end
+ end
+
+ context "when an ID is specified which can't be included in a valid URI" do
+ let(:id) { '`' }
+
+ it "doesn't raise an error" do
+ expect { get_response }.to_not raise_error(/bad URI/)
+ end
+ end
+ end
+
+ describe '#list' do
+ describe 'with no filters' do
+ subject(:get_list_response) { client.payment_accounts.list }
+
+ before do
+ stub_request(:get, %r{.*api.gocardless.com/payment_accounts}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ cursors: {
+ before: nil,
+ after: 'ABC123',
+ },
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps each item in the resource class' do
+ expect(get_list_response.records.map do |x|
+ x.class
+ end.uniq.first).to eq(GoCardlessPro::Resources::PaymentAccount)
+
+ expect(get_list_response.records.first.account_balance).to eq('account_balance-input')
+
+ expect(get_list_response.records.first.account_holder_name).to eq('account_holder_name-input')
+
+ expect(get_list_response.records.first.account_number_ending).to eq('account_number_ending-input')
+
+ expect(get_list_response.records.first.bank_name).to eq('bank_name-input')
+
+ expect(get_list_response.records.first.currency).to eq('currency-input')
+
+ expect(get_list_response.records.first.id).to eq('id-input')
+ end
+
+ it 'exposes the cursors for before and after' do
+ expect(get_list_response.before).to eq(nil)
+ expect(get_list_response.after).to eq('ABC123')
+ end
+
+ specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
+ end
+ end
+
+ describe '#all' do
+ let!(:first_response_stub) do
+ stub_request(:get, %r{.*api.gocardless.com/payment_accounts$}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ let!(:second_response_stub) do
+ stub_request(:get, %r{.*api.gocardless.com/payment_accounts\?after=AB345}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'automatically makes the extra requests' do
+ expect(client.payment_accounts.all.to_a.length).to eq(2)
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested
+ end
+ end
+end
diff --git a/spec/resources/payment_account_transaction_spec.rb b/spec/resources/payment_account_transaction_spec.rb
new file mode 100644
index 00000000..ed6601b4
--- /dev/null
+++ b/spec/resources/payment_account_transaction_spec.rb
@@ -0,0 +1,140 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Resources::PaymentAccountTransaction do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#list' do
+ describe 'with no filters' do
+ let(:identity) { 'ID123' }
+
+ subject(:get_list_response) { client.payment_account_transactions.list(identity) }
+
+ before do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ cursors: {
+ before: nil,
+ after: 'ABC123',
+ },
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps each item in the resource class' do
+ expect(get_list_response.records.map do |x|
+ x.class
+ end.uniq.first).to eq(GoCardlessPro::Resources::PaymentAccountTransaction)
+
+ expect(get_list_response.records.first.amount).to eq('amount-input')
+
+ expect(get_list_response.records.first.balance_after_transaction).to eq('balance_after_transaction-input')
+
+ expect(get_list_response.records.first.counterparty_name).to eq('counterparty_name-input')
+
+ expect(get_list_response.records.first.currency).to eq('currency-input')
+
+ expect(get_list_response.records.first.description).to eq('description-input')
+
+ expect(get_list_response.records.first.direction).to eq('direction-input')
+
+ expect(get_list_response.records.first.id).to eq('id-input')
+
+ expect(get_list_response.records.first.reference).to eq('reference-input')
+
+ expect(get_list_response.records.first.value_date).to eq('value_date-input')
+ end
+
+ it 'exposes the cursors for before and after' do
+ expect(get_list_response.before).to eq(nil)
+ expect(get_list_response.after).to eq('ABC123')
+ end
+
+ specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
+ end
+ end
+
+ describe '#all' do
+ let(:identity) { 'ID123' }
+
+ let!(:first_response_stub) do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}$/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ let!(:second_response_stub) do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}\?after=AB345/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'automatically makes the extra requests' do
+ expect(client.payment_account_transactions.all(identity).to_a.length).to eq(2)
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested
+ end
+ end
+end
diff --git a/spec/resources/payment_spec.rb b/spec/resources/payment_spec.rb
index 4dbdfac5..c3a518b6 100644
--- a/spec/resources/payment_spec.rb
+++ b/spec/resources/payment_spec.rb
@@ -28,13 +28,14 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/payments})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/payments}).
+ with(
body: {
'payments' => {
@@ -51,11 +52,12 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'payments' =>
@@ -74,8 +76,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -97,9 +100,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -130,7 +133,8 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}
end
@@ -145,11 +149,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -158,8 +162,8 @@
let!(:get_stub) do
stub_url = "/payments/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'payments' => {
@@ -176,8 +180,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -213,14 +218,15 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -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,12 +292,13 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -313,12 +322,13 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -339,9 +349,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/payments/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'payments' => {
@@ -358,8 +368,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -367,7 +378,7 @@
subject(:get_response) do
client.payments.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -397,8 +408,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -458,8 +470,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -497,8 +510,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -521,8 +535,8 @@
let!(:stub) do
# /payments/%v/actions/cancel
stub_url = '/payments/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -542,8 +556,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -576,8 +591,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -600,8 +616,8 @@
let!(:stub) do
# /payments/%v/actions/retry
stub_url = '/payments/:identity/actions/retry'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -621,8 +637,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/payout_item_spec.rb b/spec/resources/payout_item_spec.rb
index f6a79f6b..37c87182 100644
--- a/spec/resources/payout_item_spec.rb
+++ b/spec/resources/payout_item_spec.rb
@@ -21,14 +21,14 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -62,12 +62,12 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -81,12 +81,12 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/payout_spec.rb b/spec/resources/payout_spec.rb
index c2f9b8ff..bf01f263 100644
--- a/spec/resources/payout_spec.rb
+++ b/spec/resources/payout_spec.rb
@@ -30,14 +30,14 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -98,12 +98,12 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -126,12 +126,12 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -152,9 +152,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/payouts/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'payouts' => {
@@ -170,8 +170,8 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
- }
+ 'tax_currency' => 'tax_currency-input',
+ },
}.to_json,
headers: response_headers
)
@@ -179,7 +179,7 @@
subject(:get_response) do
client.payouts.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -208,8 +208,8 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
- }
+ 'tax_currency' => 'tax_currency-input',
+ },
}.to_json,
headers: response_headers
)
@@ -268,8 +268,8 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
- }
+ 'tax_currency' => 'tax_currency-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/redirect_flow_spec.rb b/spec/resources/redirect_flow_spec.rb
index 8c277bcd..620653c8 100644
--- a/spec/resources/redirect_flow_spec.rb
+++ b/spec/resources/redirect_flow_spec.rb
@@ -25,13 +25,13 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
+ 'success_redirect_url' => 'success_redirect_url-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/redirect_flows}).
+ with(
body: {
'redirect_flows' => {
@@ -45,11 +45,11 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'redirect_flows' =>
@@ -65,8 +65,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
@@ -88,9 +88,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -118,7 +118,7 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
+ 'success_redirect_url' => 'success_redirect_url-input',
}
end
@@ -133,11 +133,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -146,8 +146,8 @@
let!(:get_stub) do
stub_url = "/redirect_flows/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'redirect_flows' => {
@@ -161,8 +161,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -184,9 +184,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'redirect_flows' => {
@@ -200,8 +200,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -209,7 +209,7 @@
subject(:get_response) do
client.redirect_flows.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -236,8 +236,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -293,8 +293,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
@@ -317,8 +317,8 @@
let!(:stub) do
# /redirect_flows/%v/actions/complete
stub_url = '/redirect_flows/:identity/actions/complete'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -335,8 +335,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/refund_spec.rb b/spec/resources/refund_spec.rb
index 773714f9..e4ce1217 100644
--- a/spec/resources/refund_spec.rb
+++ b/spec/resources/refund_spec.rb
@@ -23,13 +23,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/refunds})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/refunds}).
+ with(
body: {
'refunds' => {
@@ -41,11 +41,11 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'refunds' =>
@@ -59,8 +59,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -82,9 +82,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -110,7 +110,7 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -125,11 +125,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -138,8 +138,8 @@
let!(:get_stub) do
stub_url = "/refunds/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'refunds' => {
@@ -151,8 +151,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -183,14 +183,14 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -239,12 +239,12 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -263,12 +263,12 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -289,9 +289,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/refunds/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'refunds' => {
@@ -303,8 +303,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -312,7 +312,7 @@
subject(:get_response) do
client.refunds.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -337,8 +337,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -393,8 +393,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/scenario_simulator_spec.rb b/spec/resources/scenario_simulator_spec.rb
index f5595e7f..1614879d 100644
--- a/spec/resources/scenario_simulator_spec.rb
+++ b/spec/resources/scenario_simulator_spec.rb
@@ -21,8 +21,8 @@
body: {
'scenario_simulators' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
@@ -45,16 +45,16 @@
let!(:stub) do
# /scenario_simulators/%v/actions/run
stub_url = '/scenario_simulators/:identity/actions/run'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'scenario_simulators' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/scheme_identifier_spec.rb b/spec/resources/scheme_identifier_spec.rb
index fc0beb4b..0d03264b 100644
--- a/spec/resources/scheme_identifier_spec.rb
+++ b/spec/resources/scheme_identifier_spec.rb
@@ -32,13 +32,13 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers}).
+ with(
body: {
'scheme_identifiers' => {
@@ -59,11 +59,11 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'scheme_identifiers' =>
@@ -86,8 +86,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -109,9 +109,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -146,7 +146,7 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -161,11 +161,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -174,8 +174,8 @@
let!(:get_stub) do
stub_url = "/scheme_identifiers/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'scheme_identifiers' => {
@@ -196,8 +196,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -237,14 +237,14 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -324,12 +324,12 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -357,12 +357,12 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -383,9 +383,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/scheme_identifiers/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'scheme_identifiers' => {
@@ -406,8 +406,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -415,7 +415,7 @@
subject(:get_response) do
client.scheme_identifiers.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -449,8 +449,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/subscription_spec.rb b/spec/resources/subscription_spec.rb
index dbb008a9..afeca8dc 100644
--- a/spec/resources/subscription_spec.rb
+++ b/spec/resources/subscription_spec.rb
@@ -35,13 +35,13 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/subscriptions})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/subscriptions}).
+ with(
body: {
'subscriptions' => {
@@ -65,11 +65,11 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'subscriptions' =>
@@ -95,8 +95,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -118,9 +118,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -158,7 +158,7 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}
end
@@ -173,11 +173,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -186,8 +186,8 @@
let!(:get_stub) do
stub_url = "/subscriptions/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'subscriptions' => {
@@ -211,8 +211,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -255,14 +255,14 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -347,12 +347,12 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -383,12 +383,12 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -409,9 +409,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/subscriptions/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'subscriptions' => {
@@ -435,8 +435,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -444,7 +444,7 @@
subject(:get_response) do
client.subscriptions.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -481,8 +481,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -549,8 +549,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -595,8 +595,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -619,8 +619,8 @@
let!(:stub) do
# /subscriptions/%v/actions/pause
stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -647,8 +647,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -688,8 +688,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -712,8 +712,8 @@
let!(:stub) do
# /subscriptions/%v/actions/resume
stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -740,8 +740,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -781,8 +781,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -805,8 +805,8 @@
let!(:stub) do
# /subscriptions/%v/actions/cancel
stub_url = '/subscriptions/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -833,8 +833,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/tax_rate_spec.rb b/spec/resources/tax_rate_spec.rb
index d3065541..0bb8e832 100644
--- a/spec/resources/tax_rate_spec.rb
+++ b/spec/resources/tax_rate_spec.rb
@@ -23,14 +23,14 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -72,12 +72,12 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -93,12 +93,12 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -119,9 +119,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/tax_rates/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'tax_rates' => {
@@ -130,8 +130,8 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
)
@@ -139,7 +139,7 @@
subject(:get_response) do
client.tax_rates.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -161,8 +161,8 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/transferred_mandate_spec.rb b/spec/resources/transferred_mandate_spec.rb
index 91f9d19f..54f75625 100644
--- a/spec/resources/transferred_mandate_spec.rb
+++ b/spec/resources/transferred_mandate_spec.rb
@@ -24,8 +24,8 @@
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
- 'public_key_id' => 'public_key_id-input'
- }
+ 'public_key_id' => 'public_key_id-input',
+ },
}.to_json,
headers: response_headers
@@ -48,8 +48,8 @@
let!(:stub) do
# /transferred_mandates/%v
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -59,8 +59,8 @@
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
- 'public_key_id' => 'public_key_id-input'
- }
+ 'public_key_id' => 'public_key_id-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/verification_detail_spec.rb b/spec/resources/verification_detail_spec.rb
index e4cf45db..bf3a507a 100644
--- a/spec/resources/verification_detail_spec.rb
+++ b/spec/resources/verification_detail_spec.rb
@@ -24,13 +24,13 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/verification_details})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/verification_details}).
+ with(
body: {
'verification_details' => {
@@ -43,11 +43,11 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
- }
+ 'postal_code' => 'postal_code-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'verification_details' =>
@@ -62,8 +62,8 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
- }
+ 'postal_code' => 'postal_code-input',
+ },
}.to_json,
headers: response_headers
@@ -85,9 +85,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -114,7 +114,7 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}
end
@@ -129,11 +129,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -165,14 +165,14 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -226,12 +226,12 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -251,12 +251,12 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/resources/webhook_spec.rb b/spec/resources/webhook_spec.rb
index 47cf7d13..8171013d 100644
--- a/spec/resources/webhook_spec.rb
+++ b/spec/resources/webhook_spec.rb
@@ -30,14 +30,14 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
)
@@ -100,12 +100,12 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -128,12 +128,12 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -154,9 +154,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/webhooks/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'webhooks' => {
@@ -172,8 +172,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -181,7 +181,7 @@
subject(:get_response) do
client.webhooks.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -210,8 +210,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -269,8 +269,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
@@ -293,8 +293,8 @@
let!(:stub) do
# /webhooks/%v/actions/retry
stub_url = '/webhooks/:identity/actions/retry'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -313,8 +313,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/balances_service_spec.rb b/spec/services/balances_service_spec.rb
index 24e4a458..76cbe1d0 100644
--- a/spec/services/balances_service_spec.rb
+++ b/spec/services/balances_service_spec.rb
@@ -21,14 +21,14 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -62,19 +62,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/balances})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/balances}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/balances})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/balances}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -93,12 +93,12 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -113,12 +113,12 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -142,19 +142,19 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/balances\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/balances\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'balances' => [{
@@ -162,12 +162,12 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -187,18 +187,18 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/balances\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/balances\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -210,12 +210,12 @@
'balance_type' => 'balance_type-input',
'currency' => 'currency-input',
'last_updated_at' => 'last_updated_at-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/bank_account_details_service_spec.rb b/spec/services/bank_account_details_service_spec.rb
index 0974aef0..709d65bf 100644
--- a/spec/services/bank_account_details_service_spec.rb
+++ b/spec/services/bank_account_details_service_spec.rb
@@ -17,9 +17,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/bank_account_details/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'bank_account_details' => {
@@ -27,8 +27,8 @@
'encrypted_key' => 'encrypted_key-input',
'iv' => 'iv-input',
'protected' => 'protected-input',
- 'tag' => 'tag-input'
- }
+ 'tag' => 'tag-input',
+ },
}.to_json,
headers: response_headers
)
@@ -36,7 +36,7 @@
subject(:get_response) do
client.bank_account_details.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -57,8 +57,8 @@
'encrypted_key' => 'encrypted_key-input',
'iv' => 'iv-input',
'protected' => 'protected-input',
- 'tag' => 'tag-input'
- }
+ 'tag' => 'tag-input',
+ },
}.to_json,
headers: response_headers
)
@@ -97,8 +97,8 @@
it 'retries timeouts' do
stub_url = '/bank_account_details/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -107,11 +107,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/bank_account_details/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -126,20 +126,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/bank_account_holder_verifications_service_spec.rb b/spec/services/bank_account_holder_verifications_service_spec.rb
new file mode 100644
index 00000000..c015e8e5
--- /dev/null
+++ b/spec/services/bank_account_holder_verifications_service_spec.rb
@@ -0,0 +1,325 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Services::BankAccountHolderVerificationsService do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#create' do
+ subject(:post_create_response) { client.bank_account_holder_verifications.create(params: new_resource) }
+ context 'with a valid request' do
+ let(:new_resource) do
+ {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ }
+ end
+
+ before do
+ stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).
+ with(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }
+ ).
+ to_return(
+ body: {
+ 'bank_account_holder_verifications' =>
+
+ {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'creates and returns the resource' do
+ expect(post_create_response).to be_a(GoCardlessPro::Resources::BankAccountHolderVerification)
+ end
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
+
+ post_create_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors' do
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
+
+ post_create_response
+ expect(stub).to have_been_requested.twice
+ end
+ end
+ end
+
+ context 'with a request that returns a validation error' do
+ let(:new_resource) { {} }
+
+ before do
+ stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).to_return(
+ body: {
+ error: {
+ type: 'validation_failed',
+ code: 422,
+ errors: [
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
+ }.to_json,
+ headers: response_headers,
+ status: 422
+ )
+ end
+
+ it 'throws the correct error' do
+ expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
+ end
+ end
+
+ context 'with a request that returns an idempotent creation conflict error' do
+ let(:id) { 'ID123' }
+
+ let(:new_resource) do
+ {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ }
+ end
+
+ let!(:post_stub) do
+ stub_request(:post, %r{.*api.gocardless.com/bank_account_holder_verifications}).to_return(
+ body: {
+ error: {
+ type: 'invalid_state',
+ code: 409,
+ errors: [
+ {
+ message: 'A resource has already been created with this idempotency key',
+ reason: 'idempotent_creation_conflict',
+ links: {
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
+ }.to_json,
+ headers: response_headers,
+ status: 409
+ )
+ end
+
+ let!(:get_stub) do
+ stub_url = "/bank_account_holder_verifications/#{id}"
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ context 'with default behaviour' do
+ it 'fetches the already-created resource' do
+ post_create_response
+ expect(post_stub).to have_been_requested
+ expect(get_stub).to have_been_requested
+ end
+ end
+
+ context 'with on_idempotency_conflict: :raise' do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN',
+ on_idempotency_conflict: :raise
+ )
+ end
+
+ it 'raises an IdempotencyConflict error' do
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
+ end
+ end
+ end
+ end
+
+ describe '#get' do
+ let(:id) { 'ID123' }
+
+ subject(:get_response) { client.bank_account_holder_verifications.get(id) }
+
+ context 'passing in a custom header' do
+ let!(:stub) do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ subject(:get_response) do
+ client.bank_account_holder_verifications.get(id, headers: {
+ 'Foo' => 'Bar',
+ })
+ end
+
+ it 'includes the header' do
+ get_response
+ expect(stub).to have_been_requested
+ end
+ end
+
+ context 'when there is a bank_account_holder_verification to return' do
+ before do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'bank_account_holder_verifications' => {
+
+ 'actual_account_name' => 'actual_account_name-input',
+ 'id' => 'id-input',
+ 'result' => 'result-input',
+ 'status' => 'status-input',
+ 'type' => 'type-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response in a resource' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::BankAccountHolderVerification)
+ end
+ end
+
+ context 'when nothing is returned' do
+ before do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: '',
+ headers: response_headers
+ )
+ end
+
+ it 'returns nil' do
+ expect(get_response).to be_nil
+ end
+ end
+
+ context "when an ID is specified which can't be included in a valid URI" do
+ let(:id) { '`' }
+
+ it "doesn't raise an error" do
+ expect { get_response }.to_not raise_error(/bad URI/)
+ end
+ end
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
+
+ get_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors, other than 500s' do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
+
+ get_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 500 errors returned by the API' do
+ stub_url = '/bank_account_holder_verifications/:identity'.gsub(':identity', id)
+
+ gocardless_error = {
+ 'error' => {
+ 'message' => 'Internal server error',
+ 'documentation_url' => 'https://developer.gocardless.com/#gocardless',
+ 'errors' => [{
+ 'message' => 'Internal server error',
+ 'reason' => 'internal_server_error',
+ }],
+ 'type' => 'gocardless',
+ 'code' => 500,
+ 'request_id' => 'dummy_request_id',
+ 'id' => 'dummy_exception_id',
+ },
+ }
+
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
+
+ get_response
+ expect(stub).to have_been_requested.twice
+ end
+ end
+ end
+end
diff --git a/spec/services/bank_authorisations_service_spec.rb b/spec/services/bank_authorisations_service_spec.rb
index f2da9c90..f80a3bb4 100644
--- a/spec/services/bank_authorisations_service_spec.rb
+++ b/spec/services/bank_authorisations_service_spec.rb
@@ -24,13 +24,13 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/bank_authorisations})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/bank_authorisations}).
+ with(
body: {
'bank_authorisations' => {
@@ -43,11 +43,11 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'bank_authorisations' =>
@@ -62,8 +62,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
@@ -78,19 +78,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/bank_authorisations})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_authorisations}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/bank_authorisations})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_authorisations}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -108,9 +108,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -137,7 +137,7 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
@@ -152,11 +152,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -165,8 +165,8 @@
let!(:get_stub) do
stub_url = "/bank_authorisations/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'bank_authorisations' => {
@@ -179,8 +179,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -203,8 +203,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -218,9 +218,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/bank_authorisations/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'bank_authorisations' => {
@@ -233,8 +233,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -242,7 +242,7 @@
subject(:get_response) do
client.bank_authorisations.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -268,8 +268,8 @@
'links' => 'links-input',
'qr_code_url' => 'qr_code_url-input',
'redirect_uri' => 'redirect_uri-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -308,8 +308,8 @@
it 'retries timeouts' do
stub_url = '/bank_authorisations/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -318,11 +318,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/bank_authorisations/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -337,20 +337,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/bank_details_lookups_service_spec.rb b/spec/services/bank_details_lookups_service_spec.rb
index 4fc1a81a..a5c166c9 100644
--- a/spec/services/bank_details_lookups_service_spec.rb
+++ b/spec/services/bank_details_lookups_service_spec.rb
@@ -17,23 +17,23 @@
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
+ 'bic' => 'bic-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
+ with(
body: {
'bank_details_lookups' => {
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
- }
+ 'bic' => 'bic-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'bank_details_lookups' =>
@@ -41,8 +41,8 @@
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
- }
+ 'bic' => 'bic-input',
+ },
}.to_json,
headers: response_headers
@@ -57,19 +57,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -87,9 +87,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -109,7 +109,7 @@
'available_debit_schemes' => 'available_debit_schemes-input',
'bank_name' => 'bank_name-input',
- 'bic' => 'bic-input'
+ 'bic' => 'bic-input',
}
end
@@ -124,11 +124,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/services/billing_request_flows_service_spec.rb b/spec/services/billing_request_flows_service_spec.rb
index bec481e7..55f25ab4 100644
--- a/spec/services/billing_request_flows_service_spec.rb
+++ b/spec/services/billing_request_flows_service_spec.rb
@@ -33,13 +33,13 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
+ 'skip_success_screen' => 'skip_success_screen-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_request_flows})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_request_flows}).
+ with(
body: {
'billing_request_flows' => {
@@ -61,11 +61,11 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_request_flows' =>
@@ -89,8 +89,8 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}.to_json,
headers: response_headers
@@ -105,19 +105,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_flows})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_flows}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_flows})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_flows}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -135,9 +135,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -173,7 +173,7 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
+ 'skip_success_screen' => 'skip_success_screen-input',
}
end
@@ -188,11 +188,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -236,8 +236,8 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}.to_json,
headers: response_headers
@@ -253,8 +253,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -271,8 +271,8 @@
let!(:stub) do
# /billing_request_flows/%v/actions/initialise
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -297,8 +297,8 @@
'session_token' => 'session_token-input',
'show_redirect_buttons' => 'show_redirect_buttons-input',
'show_success_redirect_button' => 'show_success_redirect_button-input',
- 'skip_success_screen' => 'skip_success_screen-input'
- }
+ 'skip_success_screen' => 'skip_success_screen-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/billing_request_templates_service_spec.rb b/spec/services/billing_request_templates_service_spec.rb
index c1bcec27..d35918e5 100644
--- a/spec/services/billing_request_templates_service_spec.rb
+++ b/spec/services/billing_request_templates_service_spec.rb
@@ -34,14 +34,14 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -105,19 +105,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -149,12 +149,12 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -182,12 +182,12 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -224,19 +224,19 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'billing_request_templates' => [{
@@ -257,12 +257,12 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -295,18 +295,18 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_request_templates\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -331,12 +331,12 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -357,9 +357,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/billing_request_templates/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'billing_request_templates' => {
@@ -380,8 +380,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -389,7 +389,7 @@
subject(:get_response) do
client.billing_request_templates.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -423,8 +423,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -463,8 +463,8 @@
it 'retries timeouts' do
stub_url = '/billing_request_templates/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -473,11 +473,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/billing_request_templates/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -492,20 +492,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -536,13 +536,13 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_request_templates})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_request_templates}).
+ with(
body: {
'billing_request_templates' => {
@@ -563,11 +563,11 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_request_templates' =>
@@ -590,8 +590,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -606,19 +606,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_templates})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_templates}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_templates})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_request_templates}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -636,9 +636,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -673,7 +673,7 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
@@ -688,11 +688,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -701,8 +701,8 @@
let!(:get_stub) do
stub_url = "/billing_request_templates/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'billing_request_templates' => {
@@ -723,8 +723,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -747,8 +747,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -784,8 +784,8 @@
'payment_request_metadata' => 'payment_request_metadata-input',
'payment_request_scheme' => 'payment_request_scheme-input',
'redirect_uri' => 'redirect_uri-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -801,8 +801,8 @@
it 'retries timeouts' do
stub_url = '/billing_request_templates/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -810,11 +810,11 @@
it 'retries 5XX errors' do
stub_url = '/billing_request_templates/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/billing_request_with_actions_service_spec.rb b/spec/services/billing_request_with_actions_service_spec.rb
index ab6e486d..5ad359ff 100644
--- a/spec/services/billing_request_with_actions_service_spec.rb
+++ b/spec/services/billing_request_with_actions_service_spec.rb
@@ -16,30 +16,30 @@
{
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
+ 'billing_requests' => 'billing_requests-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions}).
+ with(
body: {
'billing_request_with_actions' => {
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
- }
+ 'billing_requests' => 'billing_requests-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_request_with_actions' =>
{
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
- }
+ 'billing_requests' => 'billing_requests-input',
+ },
}.to_json,
headers: response_headers
@@ -54,19 +54,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests/create_with_actions}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -84,9 +84,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -105,7 +105,7 @@
{
'bank_authorisations' => 'bank_authorisations-input',
- 'billing_requests' => 'billing_requests-input'
+ 'billing_requests' => 'billing_requests-input',
}
end
@@ -120,11 +120,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/services/billing_requests_service_spec.rb b/spec/services/billing_requests_service_spec.rb
index 9619ea36..b995aa9f 100644
--- a/spec/services/billing_requests_service_spec.rb
+++ b/spec/services/billing_requests_service_spec.rb
@@ -24,17 +24,19 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/billing_requests})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/billing_requests}).
+ with(
body: {
'billing_requests' => {
@@ -47,15 +49,17 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'billing_requests' =>
@@ -70,12 +74,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -90,19 +96,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/billing_requests}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -120,9 +126,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -149,11 +155,13 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}
end
@@ -168,11 +176,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -181,8 +189,8 @@
let!(:get_stub) do
stub_url = "/billing_requests/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'billing_requests' => {
@@ -195,12 +203,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -223,8 +233,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -251,12 +261,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -272,8 +284,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -290,8 +302,8 @@
let!(:stub) do
# /billing_requests/%v/actions/collect_customer_details
stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -307,12 +319,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -341,12 +355,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -362,8 +378,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -380,8 +396,8 @@
let!(:stub) do
# /billing_requests/%v/actions/collect_bank_account
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -397,12 +413,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -431,12 +449,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -452,8 +472,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -470,8 +490,8 @@
let!(:stub) do
# /billing_requests/%v/actions/confirm_payer_details
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -487,12 +507,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -521,12 +543,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -542,8 +566,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -560,8 +584,8 @@
let!(:stub) do
# /billing_requests/%v/actions/fulfil
stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -577,12 +601,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -611,12 +637,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -632,8 +660,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -650,8 +678,8 @@
let!(:stub) do
# /billing_requests/%v/actions/cancel
stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -667,12 +695,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -697,18 +727,20 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -740,6 +772,10 @@
expect(get_list_response.records.first.metadata).to eq('metadata-input')
+ expect(get_list_response.records.first.payment_context_code).to eq('payment_context_code-input')
+
+ expect(get_list_response.records.first.payment_purpose_code).to eq('payment_purpose_code-input')
+
expect(get_list_response.records.first.payment_request).to eq('payment_request-input')
expect(get_list_response.records.first.purpose_code).to eq('purpose_code-input')
@@ -762,19 +798,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -798,16 +834,18 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -827,16 +865,18 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -865,23 +905,25 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'billing_requests' => [{
@@ -894,16 +936,18 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -928,22 +972,24 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/billing_requests\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -960,16 +1006,18 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
+ 'subscription_request' => 'subscription_request-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -990,9 +1038,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'billing_requests' => {
@@ -1005,12 +1053,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1018,7 +1068,7 @@
subject(:get_response) do
client.billing_requests.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -1044,12 +1094,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1088,8 +1140,8 @@
it 'retries timeouts' do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -1098,11 +1150,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -1117,20 +1169,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -1159,12 +1211,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -1180,8 +1234,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -1198,8 +1252,8 @@
let!(:stub) do
# /billing_requests/%v/actions/notify
stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1215,12 +1269,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1249,12 +1305,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -1270,8 +1328,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -1288,8 +1346,8 @@
let!(:stub) do
# /billing_requests/%v/actions/fallback
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1305,12 +1363,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1339,12 +1399,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -1360,8 +1422,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -1378,8 +1440,8 @@
let!(:stub) do
# /billing_requests/%v/actions/choose_currency
stub_url = '/billing_requests/:identity/actions/choose_currency'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1395,12 +1457,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1429,12 +1493,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
@@ -1450,8 +1516,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/actions/select_institution'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -1468,8 +1534,8 @@
let!(:stub) do
# /billing_requests/%v/actions/select_institution
stub_url = '/billing_requests/:identity/actions/select_institution'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1485,12 +1551,14 @@
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
+ 'payment_context_code' => 'payment_context_code-input',
+ 'payment_purpose_code' => 'payment_purpose_code-input',
'payment_request' => 'payment_request-input',
'purpose_code' => 'purpose_code-input',
'resources' => 'resources-input',
'status' => 'status-input',
- 'subscription_request' => 'subscription_request-input'
- }
+ 'subscription_request' => 'subscription_request-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/blocks_service_spec.rb b/spec/services/blocks_service_spec.rb
index 698858ab..422e0280 100644
--- a/spec/services/blocks_service_spec.rb
+++ b/spec/services/blocks_service_spec.rb
@@ -22,13 +22,13 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/blocks})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/blocks}).
+ with(
body: {
'blocks' => {
@@ -39,11 +39,11 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'blocks' =>
@@ -56,8 +56,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -72,19 +72,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/blocks})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/blocks}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/blocks})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/blocks}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -102,9 +102,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -129,7 +129,7 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}
end
@@ -144,11 +144,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -157,8 +157,8 @@
let!(:get_stub) do
stub_url = "/blocks/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'blocks' => {
@@ -169,8 +169,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -193,8 +193,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -208,9 +208,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/blocks/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'blocks' => {
@@ -221,8 +221,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -230,7 +230,7 @@
subject(:get_response) do
client.blocks.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -254,8 +254,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -294,8 +294,8 @@
it 'retries timeouts' do
stub_url = '/blocks/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -304,11 +304,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/blocks/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -323,20 +323,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -359,14 +359,14 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -408,19 +408,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/blocks})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/blocks}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/blocks})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/blocks}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -442,12 +442,12 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -465,12 +465,12 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -497,19 +497,19 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/blocks\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/blocks\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'blocks' => [{
@@ -520,12 +520,12 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -548,18 +548,18 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/blocks\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/blocks\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -574,12 +574,12 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -611,8 +611,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -628,8 +628,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/blocks/:identity/actions/disable'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -646,8 +646,8 @@
let!(:stub) do
# /blocks/%v/actions/disable
stub_url = '/blocks/:identity/actions/disable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -661,8 +661,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -689,8 +689,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
@@ -706,8 +706,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/blocks/:identity/actions/enable'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -724,8 +724,8 @@
let!(:stub) do
# /blocks/%v/actions/enable
stub_url = '/blocks/:identity/actions/enable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -739,8 +739,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -767,14 +767,14 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
+ 'updated_at' => 'updated_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
@@ -795,8 +795,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/blocks/block_by_ref'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -811,8 +811,8 @@
let!(:stub) do
# /blocks/block_by_ref
stub_url = '/blocks/block_by_ref'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -826,8 +826,8 @@
'reason_description' => 'reason_description-input',
'reason_type' => 'reason_type-input',
'resource_reference' => 'resource_reference-input',
- 'updated_at' => 'updated_at-input'
- }
+ 'updated_at' => 'updated_at-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/creditor_bank_accounts_service_spec.rb b/spec/services/creditor_bank_accounts_service_spec.rb
index dc2eae61..dcb788a8 100644
--- a/spec/services/creditor_bank_accounts_service_spec.rb
+++ b/spec/services/creditor_bank_accounts_service_spec.rb
@@ -26,13 +26,13 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).
+ with(
body: {
'creditor_bank_accounts' => {
@@ -47,11 +47,11 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'creditor_bank_accounts' =>
@@ -68,8 +68,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
@@ -84,19 +84,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -114,9 +114,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -145,7 +145,7 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
@@ -160,11 +160,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -173,8 +173,8 @@
let!(:get_stub) do
stub_url = "/creditor_bank_accounts/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'creditor_bank_accounts' => {
@@ -189,8 +189,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -213,8 +213,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -239,14 +239,14 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -296,19 +296,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -334,12 +334,12 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -361,12 +361,12 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -397,19 +397,19 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'creditor_bank_accounts' => [{
@@ -424,12 +424,12 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -456,18 +456,18 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -486,12 +486,12 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -512,9 +512,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'creditor_bank_accounts' => {
@@ -529,8 +529,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -538,7 +538,7 @@
subject(:get_response) do
client.creditor_bank_accounts.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -566,8 +566,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -606,8 +606,8 @@
it 'retries timeouts' do
stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -616,11 +616,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -635,20 +635,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -679,8 +679,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
@@ -696,8 +696,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -714,8 +714,8 @@
let!(:stub) do
# /creditor_bank_accounts/%v/actions/disable
stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -733,8 +733,8 @@
'id' => 'id-input',
'links' => 'links-input',
'metadata' => 'metadata-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/creditors_service_spec.rb b/spec/services/creditors_service_spec.rb
index 53e7f4d7..7a857a2c 100644
--- a/spec/services/creditors_service_spec.rb
+++ b/spec/services/creditors_service_spec.rb
@@ -35,13 +35,13 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/creditors})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/creditors}).
+ with(
body: {
'creditors' => {
@@ -65,11 +65,11 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'creditors' =>
@@ -95,8 +95,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
@@ -111,19 +111,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/creditors})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditors}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/creditors})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditors}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -141,9 +141,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -181,7 +181,7 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}
end
@@ -196,11 +196,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -209,8 +209,8 @@
let!(:get_stub) do
stub_url = "/creditors/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'creditors' => {
@@ -234,8 +234,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -258,8 +258,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -293,14 +293,14 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -366,19 +366,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/creditors})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditors}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/creditors})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditors}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -413,12 +413,12 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -449,12 +449,12 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -494,19 +494,19 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'creditors' => [{
@@ -530,12 +530,12 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -571,18 +571,18 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -610,12 +610,12 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
+ 'verification_status' => 'verification_status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -636,9 +636,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/creditors/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'creditors' => {
@@ -662,8 +662,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -671,7 +671,7 @@
subject(:get_response) do
client.creditors.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -708,8 +708,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -748,8 +748,8 @@
it 'retries timeouts' do
stub_url = '/creditors/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -758,11 +758,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/creditors/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -777,20 +777,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -831,8 +831,8 @@
'postal_code' => 'postal_code-input',
'region' => 'region-input',
'scheme_identifiers' => 'scheme_identifiers-input',
- 'verification_status' => 'verification_status-input'
- }
+ 'verification_status' => 'verification_status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -848,8 +848,8 @@
it 'retries timeouts' do
stub_url = '/creditors/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -857,11 +857,11 @@
it 'retries 5XX errors' do
stub_url = '/creditors/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/currency_exchange_rates_service_spec.rb b/spec/services/currency_exchange_rates_service_spec.rb
index 7544f15d..5b7c2108 100644
--- a/spec/services/currency_exchange_rates_service_spec.rb
+++ b/spec/services/currency_exchange_rates_service_spec.rb
@@ -20,14 +20,14 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -63,19 +63,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -93,12 +93,12 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -112,12 +112,12 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -140,31 +140,31 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'currency_exchange_rates' => [{
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -183,18 +183,18 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/currency_exchange_rates\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -205,12 +205,12 @@
'rate' => 'rate-input',
'source' => 'source-input',
'target' => 'target-input',
- 'time' => 'time-input'
+ 'time' => 'time-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/customer_bank_accounts_service_spec.rb b/spec/services/customer_bank_accounts_service_spec.rb
index 63b403e4..47599ee6 100644
--- a/spec/services/customer_bank_accounts_service_spec.rb
+++ b/spec/services/customer_bank_accounts_service_spec.rb
@@ -26,13 +26,13 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
+ with(
body: {
'customer_bank_accounts' => {
@@ -47,11 +47,11 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'customer_bank_accounts' =>
@@ -68,8 +68,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
@@ -84,19 +84,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -114,9 +114,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -145,7 +145,7 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}
end
@@ -160,11 +160,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -173,8 +173,8 @@
let!(:get_stub) do
stub_url = "/customer_bank_accounts/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'customer_bank_accounts' => {
@@ -189,8 +189,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -213,8 +213,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -239,14 +239,14 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -296,19 +296,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -334,12 +334,12 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -361,12 +361,12 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -397,19 +397,19 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'customer_bank_accounts' => [{
@@ -424,12 +424,12 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -456,18 +456,18 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -486,12 +486,12 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
+ 'metadata' => 'metadata-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -512,9 +512,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'customer_bank_accounts' => {
@@ -529,8 +529,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -538,7 +538,7 @@
subject(:get_response) do
client.customer_bank_accounts.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -566,8 +566,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -606,8 +606,8 @@
it 'retries timeouts' do
stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -616,11 +616,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -635,20 +635,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -680,8 +680,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
@@ -697,8 +697,8 @@
it 'retries timeouts' do
stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -706,11 +706,11 @@
it 'retries 5XX errors' do
stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -742,8 +742,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
@@ -759,8 +759,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/customer_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -777,8 +777,8 @@
let!(:stub) do
# /customer_bank_accounts/%v/actions/disable
stub_url = '/customer_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -796,8 +796,8 @@
'enabled' => 'enabled-input',
'id' => 'id-input',
'links' => 'links-input',
- 'metadata' => 'metadata-input'
- }
+ 'metadata' => 'metadata-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/customer_notifications_service_spec.rb b/spec/services/customer_notifications_service_spec.rb
index f4c17144..afc461d2 100644
--- a/spec/services/customer_notifications_service_spec.rb
+++ b/spec/services/customer_notifications_service_spec.rb
@@ -26,8 +26,8 @@
'action_taken_by' => 'action_taken_by-input',
'id' => 'id-input',
'links' => 'links-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
@@ -43,8 +43,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/customer_notifications/:identity/actions/handle'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -61,8 +61,8 @@
let!(:stub) do
# /customer_notifications/%v/actions/handle
stub_url = '/customer_notifications/:identity/actions/handle'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -74,8 +74,8 @@
'action_taken_by' => 'action_taken_by-input',
'id' => 'id-input',
'links' => 'links-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/customers_service_spec.rb b/spec/services/customers_service_spec.rb
index 96ead4f0..ab8f41f4 100644
--- a/spec/services/customers_service_spec.rb
+++ b/spec/services/customers_service_spec.rb
@@ -32,13 +32,13 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/customers})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/customers}).
+ with(
body: {
'customers' => {
@@ -59,11 +59,11 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'customers' =>
@@ -86,8 +86,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
@@ -102,19 +102,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/customers})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/customers}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/customers})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/customers}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -132,9 +132,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -169,7 +169,7 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}
end
@@ -184,11 +184,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -197,8 +197,8 @@
let!(:get_stub) do
stub_url = "/customers/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'customers' => {
@@ -219,8 +219,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -243,8 +243,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -275,14 +275,14 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -344,19 +344,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/customers})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/customers}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/customers})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/customers}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -388,12 +388,12 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -421,12 +421,12 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -463,19 +463,19 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'customers' => [{
@@ -496,12 +496,12 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -534,18 +534,18 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -570,12 +570,12 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
+ 'swedish_identity_number' => 'swedish_identity_number-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -596,9 +596,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/customers/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'customers' => {
@@ -619,8 +619,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -628,7 +628,7 @@
subject(:get_response) do
client.customers.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -662,8 +662,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -702,8 +702,8 @@
it 'retries timeouts' do
stub_url = '/customers/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -712,11 +712,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/customers/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -731,20 +731,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -782,8 +782,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
@@ -799,8 +799,8 @@
it 'retries timeouts' do
stub_url = '/customers/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -808,11 +808,11 @@
it 'retries 5XX errors' do
stub_url = '/customers/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -850,8 +850,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
@@ -867,8 +867,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/customers/:identity'.gsub(':identity', resource_id)
- stub = stub_request(:delete, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ stub = stub_request(:delete, /.*api.gocardless.com#{stub_url}/).
+ to_timeout
expect { delete_response }.to raise_error(Faraday::ConnectionFailed)
expect(stub).to have_been_requested
@@ -885,8 +885,8 @@
let!(:stub) do
# /customers/%v
stub_url = '/customers/:identity'.gsub(':identity', resource_id)
- stub_request(:delete, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:delete, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -910,8 +910,8 @@
'phone_number' => 'phone_number-input',
'postal_code' => 'postal_code-input',
'region' => 'region-input',
- 'swedish_identity_number' => 'swedish_identity_number-input'
- }
+ 'swedish_identity_number' => 'swedish_identity_number-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/events_service_spec.rb b/spec/services/events_service_spec.rb
index 828ea0b7..db1beb37 100644
--- a/spec/services/events_service_spec.rb
+++ b/spec/services/events_service_spec.rb
@@ -25,14 +25,15 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -61,6 +62,8 @@
expect(get_list_response.records.first.resource_metadata).to eq('resource_metadata-input')
expect(get_list_response.records.first.resource_type).to eq('resource_type-input')
+
+ expect(get_list_response.records.first.source).to eq('source-input')
end
it 'exposes the cursors for before and after' do
@@ -74,19 +77,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/events})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/events}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/events})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/events}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -109,12 +112,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -133,12 +137,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -166,19 +171,20 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'events' => [{
@@ -190,12 +196,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -219,18 +226,19 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -246,12 +254,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -272,9 +281,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/events/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'events' => {
@@ -286,8 +295,9 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
- }
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
+ },
}.to_json,
headers: response_headers
)
@@ -295,7 +305,7 @@
subject(:get_response) do
client.events.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -320,8 +330,9 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'resource_metadata' => 'resource_metadata-input',
- 'resource_type' => 'resource_type-input'
- }
+ 'resource_type' => 'resource_type-input',
+ 'source' => 'source-input',
+ },
}.to_json,
headers: response_headers
)
@@ -360,8 +371,8 @@
it 'retries timeouts' do
stub_url = '/events/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -370,11 +381,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/events/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -389,20 +400,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/exports_service_spec.rb b/spec/services/exports_service_spec.rb
index 239b8a62..081b4aa4 100644
--- a/spec/services/exports_service_spec.rb
+++ b/spec/services/exports_service_spec.rb
@@ -17,9 +17,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/exports/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'exports' => {
@@ -27,8 +27,8 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
)
@@ -36,7 +36,7 @@
subject(:get_response) do
client.exports.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -57,8 +57,8 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
)
@@ -97,8 +97,8 @@
it 'retries timeouts' do
stub_url = '/exports/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -107,11 +107,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/exports/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -126,20 +126,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -159,14 +159,14 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -202,19 +202,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/exports})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/exports}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/exports})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/exports}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -233,12 +233,12 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -253,12 +253,12 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -282,19 +282,19 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/exports\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/exports\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'exports' => [{
@@ -302,12 +302,12 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -327,18 +327,18 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/exports\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/exports\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -350,12 +350,12 @@
'currency' => 'currency-input',
'download_url' => 'download_url-input',
'export_type' => 'export_type-input',
- 'id' => 'id-input'
+ 'id' => 'id-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/funds_availabilities_service_spec.rb b/spec/services/funds_availabilities_service_spec.rb
new file mode 100644
index 00000000..f5661653
--- /dev/null
+++ b/spec/services/funds_availabilities_service_spec.rb
@@ -0,0 +1,75 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Services::FundsAvailabilitiesService do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#check' do
+ subject(:get_response) { client.funds_availabilities.check(resource_id) }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /funds_availability/%v
+ stub_url = '/funds_availability/:identity'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'funds_availability' => {
+
+ 'available' => 'available-input',
+ },
+ }.to_json,
+
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response and calls the right endpoint' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::FundsAvailability)
+
+ expect(stub).to have_been_requested
+ end
+
+ describe 'retry behaviour' do
+ it "doesn't retry errors" do
+ stub_url = '/funds_availability/:identity'.gsub(':identity', resource_id)
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout
+
+ expect { get_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
+ let(:body) { { foo: 'bar' } }
+ let(:headers) { { 'Foo' => 'Bar' } }
+ subject(:get_response) { client.funds_availabilities.check(resource_id, body, headers) }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /funds_availability/%v
+ stub_url = '/funds_availability/:identity'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
+ body: { foo: 'bar' },
+ headers: { 'Foo' => 'Bar' }
+ ).to_return(
+ body: {
+ 'funds_availability' => {
+
+ 'available' => 'available-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+ end
+ end
+end
diff --git a/spec/services/instalment_schedules_service_spec.rb b/spec/services/instalment_schedules_service_spec.rb
index e7398b05..12c42d1d 100644
--- a/spec/services/instalment_schedules_service_spec.rb
+++ b/spec/services/instalment_schedules_service_spec.rb
@@ -23,13 +23,13 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ with(
body: {
'instalment_schedules' => {
@@ -41,11 +41,11 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'instalment_schedules' =>
@@ -59,8 +59,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
@@ -75,19 +75,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -105,9 +105,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -133,7 +133,7 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
@@ -148,11 +148,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -161,8 +161,8 @@
let!(:get_stub) do
stub_url = "/instalment_schedules/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'instalment_schedules' => {
@@ -174,8 +174,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -198,8 +198,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -219,13 +219,13 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ with(
body: {
'instalment_schedules' => {
@@ -237,11 +237,11 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'instalment_schedules' =>
@@ -255,8 +255,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
@@ -271,19 +271,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/instalment_schedules}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -301,9 +301,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -329,7 +329,7 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}
end
@@ -344,11 +344,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -357,8 +357,8 @@
let!(:get_stub) do
stub_url = "/instalment_schedules/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'instalment_schedules' => {
@@ -370,8 +370,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -394,8 +394,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -417,14 +417,14 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -468,19 +468,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -503,12 +503,12 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -527,12 +527,12 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -560,19 +560,19 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'instalment_schedules' => [{
@@ -584,12 +584,12 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -613,18 +613,18 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/instalment_schedules\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -640,12 +640,12 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
+ 'total_amount' => 'total_amount-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -666,9 +666,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'instalment_schedules' => {
@@ -680,8 +680,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -689,7 +689,7 @@
subject(:get_response) do
client.instalment_schedules.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -714,8 +714,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -754,8 +754,8 @@
it 'retries timeouts' do
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -764,11 +764,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -783,20 +783,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -825,8 +825,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
@@ -842,8 +842,8 @@
it 'retries timeouts' do
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -851,11 +851,11 @@
it 'retries 5XX errors' do
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -884,8 +884,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
@@ -901,8 +901,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/instalment_schedules/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -919,8 +919,8 @@
let!(:stub) do
# /instalment_schedules/%v/actions/cancel
stub_url = '/instalment_schedules/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -935,8 +935,8 @@
'name' => 'name-input',
'payment_errors' => 'payment_errors-input',
'status' => 'status-input',
- 'total_amount' => 'total_amount-input'
- }
+ 'total_amount' => 'total_amount-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/institutions_service_spec.rb b/spec/services/institutions_service_spec.rb
index 59365ee7..a2ce6840 100644
--- a/spec/services/institutions_service_spec.rb
+++ b/spec/services/institutions_service_spec.rb
@@ -24,14 +24,14 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -73,19 +73,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/institutions})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/institutions}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/institutions})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/institutions}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -107,12 +107,12 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -130,12 +130,12 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -162,19 +162,19 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/institutions\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/institutions\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'institutions' => [{
@@ -185,12 +185,12 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -213,18 +213,18 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/institutions\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/institutions\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -239,12 +239,12 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -276,14 +276,14 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json,
headers: response_headers
@@ -304,8 +304,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/billing_requests/:identity/institutions'.gsub(':identity', resource_id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout
expect { get_response }.to raise_error(Faraday::ConnectionFailed)
expect(stub).to have_been_requested
@@ -322,8 +322,8 @@
let!(:stub) do
# /billing_requests/%v/institutions
stub_url = '/billing_requests/:identity/institutions'.gsub(':identity', resource_id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -337,8 +337,8 @@
'limits' => 'limits-input',
'logo_url' => 'logo_url-input',
'name' => 'name-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/logos_service_spec.rb b/spec/services/logos_service_spec.rb
index 895ba01d..e8dcded6 100644
--- a/spec/services/logos_service_spec.rb
+++ b/spec/services/logos_service_spec.rb
@@ -15,28 +15,28 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/branding/logos})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/branding/logos}).
+ with(
body: {
'logos' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'logos' =>
{
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
@@ -51,19 +51,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/branding/logos})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/branding/logos}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/branding/logos})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/branding/logos}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -81,9 +81,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -101,7 +101,7 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
@@ -116,11 +116,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/services/mandate_import_entries_service_spec.rb b/spec/services/mandate_import_entries_service_spec.rb
index c54fc8cd..874af5d4 100644
--- a/spec/services/mandate_import_entries_service_spec.rb
+++ b/spec/services/mandate_import_entries_service_spec.rb
@@ -18,24 +18,24 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries}).
+ with(
body: {
'mandate_import_entries' => {
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
- }
+ 'record_identifier' => 'record_identifier-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandate_import_entries' =>
@@ -44,8 +44,8 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
- }
+ 'record_identifier' => 'record_identifier-input',
+ },
}.to_json,
headers: response_headers
@@ -60,19 +60,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandate_import_entries}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -90,9 +90,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -113,7 +113,7 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}
end
@@ -128,11 +128,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -157,14 +157,14 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -198,19 +198,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -228,12 +228,12 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -247,12 +247,12 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -275,31 +275,31 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'mandate_import_entries' => [{
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -318,18 +318,18 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandate_import_entries\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -340,12 +340,12 @@
'created_at' => 'created_at-input',
'links' => 'links-input',
'processing_errors' => 'processing_errors-input',
- 'record_identifier' => 'record_identifier-input'
+ 'record_identifier' => 'record_identifier-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/mandate_imports_service_spec.rb b/spec/services/mandate_imports_service_spec.rb
index 6d40a1a9..f8aff6e3 100644
--- a/spec/services/mandate_imports_service_spec.rb
+++ b/spec/services/mandate_imports_service_spec.rb
@@ -19,13 +19,13 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandate_imports})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandate_imports}).
+ with(
body: {
'mandate_imports' => {
@@ -33,11 +33,11 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandate_imports' =>
@@ -47,8 +47,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -63,19 +63,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandate_imports})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandate_imports}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandate_imports})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandate_imports}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -93,9 +93,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -117,7 +117,7 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -132,11 +132,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -145,8 +145,8 @@
let!(:get_stub) do
stub_url = "/mandate_imports/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'mandate_imports' => {
@@ -154,8 +154,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -178,8 +178,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -193,9 +193,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/mandate_imports/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'mandate_imports' => {
@@ -203,8 +203,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -212,7 +212,7 @@
subject(:get_response) do
client.mandate_imports.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -233,8 +233,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -273,8 +273,8 @@
it 'retries timeouts' do
stub_url = '/mandate_imports/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -283,11 +283,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/mandate_imports/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -302,20 +302,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -339,8 +339,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -356,8 +356,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/mandate_imports/:identity/actions/submit'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -374,8 +374,8 @@
let!(:stub) do
# /mandate_imports/%v/actions/submit
stub_url = '/mandate_imports/:identity/actions/submit'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -386,8 +386,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -411,8 +411,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -428,8 +428,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/mandate_imports/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -446,8 +446,8 @@
let!(:stub) do
# /mandate_imports/%v/actions/cancel
stub_url = '/mandate_imports/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -458,8 +458,8 @@
'id' => 'id-input',
'links' => 'links-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/mandate_pdfs_service_spec.rb b/spec/services/mandate_pdfs_service_spec.rb
index 87c738d0..0a908e9c 100644
--- a/spec/services/mandate_pdfs_service_spec.rb
+++ b/spec/services/mandate_pdfs_service_spec.rb
@@ -16,30 +16,30 @@
{
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
+ with(
body: {
'mandate_pdfs' => {
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandate_pdfs' =>
{
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
@@ -54,19 +54,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandate_pdfs}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -84,9 +84,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -105,7 +105,7 @@
{
'expires_at' => 'expires_at-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}
end
@@ -120,11 +120,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/services/mandates_service_spec.rb b/spec/services/mandates_service_spec.rb
index 84a2ea56..5120f1ab 100644
--- a/spec/services/mandates_service_spec.rb
+++ b/spec/services/mandates_service_spec.rb
@@ -29,13 +29,13 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/mandates})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/mandates}).
+ with(
body: {
'mandates' => {
@@ -53,11 +53,11 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'mandates' =>
@@ -77,8 +77,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
@@ -93,19 +93,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandates})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandates}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/mandates})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/mandates}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -123,9 +123,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -157,7 +157,7 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}
end
@@ -172,11 +172,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -185,8 +185,8 @@
let!(:get_stub) do
stub_url = "/mandates/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'mandates' => {
@@ -204,8 +204,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -228,8 +228,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -257,14 +257,14 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -318,19 +318,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/mandates})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/mandates}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/mandates})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/mandates}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -359,12 +359,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -389,12 +389,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -428,19 +428,19 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'mandates' => [{
@@ -458,12 +458,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -493,18 +493,18 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/mandates\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -526,12 +526,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
+ 'verified_at' => 'verified_at-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -552,9 +552,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/mandates/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'mandates' => {
@@ -572,8 +572,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -581,7 +581,7 @@
subject(:get_response) do
client.mandates.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -612,8 +612,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -652,8 +652,8 @@
it 'retries timeouts' do
stub_url = '/mandates/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -662,11 +662,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/mandates/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -681,20 +681,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -729,8 +729,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -746,8 +746,8 @@
it 'retries timeouts' do
stub_url = '/mandates/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -755,11 +755,11 @@
it 'retries 5XX errors' do
stub_url = '/mandates/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -794,8 +794,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
@@ -811,8 +811,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/mandates/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -829,8 +829,8 @@
let!(:stub) do
# /mandates/%v/actions/cancel
stub_url = '/mandates/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -851,8 +851,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
@@ -886,8 +886,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
@@ -903,8 +903,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/mandates/:identity/actions/reinstate'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -921,8 +921,8 @@
let!(:stub) do
# /mandates/%v/actions/reinstate
stub_url = '/mandates/:identity/actions/reinstate'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -943,8 +943,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verified_at' => 'verified_at-input'
- }
+ 'verified_at' => 'verified_at-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/negative_balance_limits_service_spec.rb b/spec/services/negative_balance_limits_service_spec.rb
index bb53bb82..bc13c41d 100644
--- a/spec/services/negative_balance_limits_service_spec.rb
+++ b/spec/services/negative_balance_limits_service_spec.rb
@@ -21,14 +21,14 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -64,19 +64,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -95,12 +95,12 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -115,12 +115,12 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -144,19 +144,19 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'negative_balance_limits' => [{
@@ -164,12 +164,12 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -189,18 +189,18 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/negative_balance_limits\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -212,12 +212,12 @@
'created_at' => 'created_at-input',
'currency' => 'currency-input',
'id' => 'id-input',
- 'links' => 'links-input'
+ 'links' => 'links-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/outbound_payments_service_spec.rb b/spec/services/outbound_payments_service_spec.rb
index bc47b953..f291f578 100644
--- a/spec/services/outbound_payments_service_spec.rb
+++ b/spec/services/outbound_payments_service_spec.rb
@@ -27,13 +27,13 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/outbound_payments})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/outbound_payments}).
+ with(
body: {
'outbound_payments' => {
@@ -49,11 +49,11 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'outbound_payments' =>
@@ -71,8 +71,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -87,19 +87,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/outbound_payments})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/outbound_payments}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/outbound_payments})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/outbound_payments}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -117,9 +117,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -149,7 +149,7 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}
end
@@ -164,11 +164,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -177,8 +177,8 @@
let!(:get_stub) do
stub_url = "/outbound_payments/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'outbound_payments' => {
@@ -194,8 +194,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -218,8 +218,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -249,8 +249,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -266,8 +266,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/outbound_payments/withdrawal'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -282,8 +282,8 @@
let!(:stub) do
# /outbound_payments/withdrawal
stub_url = '/outbound_payments/withdrawal'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -302,8 +302,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -335,8 +335,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -352,8 +352,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/outbound_payments/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -370,8 +370,8 @@
let!(:stub) do
# /outbound_payments/%v/actions/cancel
stub_url = '/outbound_payments/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -390,8 +390,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -423,8 +423,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
@@ -440,8 +440,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/outbound_payments/:identity/actions/approve'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -458,8 +458,8 @@
let!(:stub) do
# /outbound_payments/%v/actions/approve
stub_url = '/outbound_payments/:identity/actions/approve'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -478,8 +478,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -495,9 +495,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/outbound_payments/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'outbound_payments' => {
@@ -513,8 +513,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -522,7 +522,7 @@
subject(:get_response) do
client.outbound_payments.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -551,8 +551,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -591,8 +591,8 @@
it 'retries timeouts' do
stub_url = '/outbound_payments/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -601,11 +601,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/outbound_payments/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -620,20 +620,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -661,14 +661,14 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -720,19 +720,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -759,12 +759,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -787,12 +787,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -824,19 +824,19 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'outbound_payments' => [{
@@ -852,12 +852,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -885,18 +885,18 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/outbound_payments\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -916,12 +916,12 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
+ 'verifications' => 'verifications-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -959,8 +959,8 @@
'reference' => 'reference-input',
'scheme' => 'scheme-input',
'status' => 'status-input',
- 'verifications' => 'verifications-input'
- }
+ 'verifications' => 'verifications-input',
+ },
}.to_json,
headers: response_headers
)
@@ -976,8 +976,8 @@
it 'retries timeouts' do
stub_url = '/outbound_payments/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -985,11 +985,11 @@
it 'retries 5XX errors' do
stub_url = '/outbound_payments/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -997,4 +997,90 @@
end
end
end
+
+ describe '#stats' do
+ subject(:get_response) { client.outbound_payments.stats }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /outbound_payments/stats
+ stub_url = '/outbound_payments/stats'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'outbound_payments' => {
+
+ 'amount' => 'amount-input',
+ 'created_at' => 'created_at-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'execution_date' => 'execution_date-input',
+ 'id' => 'id-input',
+ 'is_withdrawal' => 'is_withdrawal-input',
+ 'links' => 'links-input',
+ 'metadata' => 'metadata-input',
+ 'reference' => 'reference-input',
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ 'verifications' => 'verifications-input',
+ },
+ }.to_json,
+
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response and calls the right endpoint' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::OutboundPayment)
+
+ expect(stub).to have_been_requested
+ end
+
+ describe 'retry behaviour' do
+ it "doesn't retry errors" do
+ stub_url = '/outbound_payments/stats'.gsub(':identity', resource_id)
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout
+
+ expect { get_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(:get_response) { client.outbound_payments.stats(body, headers) }
+
+ let(:resource_id) { 'ABC123' }
+
+ let!(:stub) do
+ # /outbound_payments/stats
+ stub_url = '/outbound_payments/stats'.gsub(':identity', resource_id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
+ body: { foo: 'bar' },
+ headers: { 'Foo' => 'Bar' }
+ ).to_return(
+ body: {
+ 'outbound_payments' => {
+
+ 'amount' => 'amount-input',
+ 'created_at' => 'created_at-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'execution_date' => 'execution_date-input',
+ 'id' => 'id-input',
+ 'is_withdrawal' => 'is_withdrawal-input',
+ 'links' => 'links-input',
+ 'metadata' => 'metadata-input',
+ 'reference' => 'reference-input',
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ 'verifications' => 'verifications-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+ end
+ end
end
diff --git a/spec/services/payer_authorisations_service_spec.rb b/spec/services/payer_authorisations_service_spec.rb
index ed21a90d..591b614d 100644
--- a/spec/services/payer_authorisations_service_spec.rb
+++ b/spec/services/payer_authorisations_service_spec.rb
@@ -17,9 +17,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/payer_authorisations/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'payer_authorisations' => {
@@ -30,8 +30,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -39,7 +39,7 @@
subject(:get_response) do
client.payer_authorisations.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -63,8 +63,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -103,8 +103,8 @@
it 'retries timeouts' do
stub_url = '/payer_authorisations/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -113,11 +113,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/payer_authorisations/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -132,20 +132,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -166,13 +166,13 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/payer_authorisations})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/payer_authorisations}).
+ with(
body: {
'payer_authorisations' => {
@@ -183,11 +183,11 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'payer_authorisations' =>
@@ -200,8 +200,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -216,19 +216,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/payer_authorisations})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/payer_authorisations}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/payer_authorisations})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/payer_authorisations}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -246,9 +246,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -273,7 +273,7 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -288,11 +288,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -301,8 +301,8 @@
let!(:get_stub) do
stub_url = "/payer_authorisations/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'payer_authorisations' => {
@@ -313,8 +313,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -337,8 +337,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -364,8 +364,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -381,8 +381,8 @@
it 'retries timeouts' do
stub_url = '/payer_authorisations/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -390,11 +390,11 @@
it 'retries 5XX errors' do
stub_url = '/payer_authorisations/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -422,8 +422,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -439,8 +439,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/payer_authorisations/:identity/actions/submit'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -457,8 +457,8 @@
let!(:stub) do
# /payer_authorisations/%v/actions/submit
stub_url = '/payer_authorisations/:identity/actions/submit'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -472,8 +472,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -500,8 +500,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -517,8 +517,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/payer_authorisations/:identity/actions/confirm'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -535,8 +535,8 @@
let!(:stub) do
# /payer_authorisations/%v/actions/confirm
stub_url = '/payer_authorisations/:identity/actions/confirm'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -550,8 +550,8 @@
'incomplete_fields' => 'incomplete_fields-input',
'links' => 'links-input',
'mandate' => 'mandate-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/payer_themes_service_spec.rb b/spec/services/payer_themes_service_spec.rb
index 45130052..905a8f24 100644
--- a/spec/services/payer_themes_service_spec.rb
+++ b/spec/services/payer_themes_service_spec.rb
@@ -15,28 +15,28 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes}).
+ with(
body: {
'payer_themes' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'payer_themes' =>
{
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
@@ -51,19 +51,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/branding/payer_themes}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -81,9 +81,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -101,7 +101,7 @@
let(:new_resource) do
{
- 'id' => 'id-input'
+ 'id' => 'id-input',
}
end
@@ -116,11 +116,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
diff --git a/spec/services/payment_account_transactions_service_spec.rb b/spec/services/payment_account_transactions_service_spec.rb
new file mode 100644
index 00000000..138b0f62
--- /dev/null
+++ b/spec/services/payment_account_transactions_service_spec.rb
@@ -0,0 +1,288 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Services::PaymentAccountTransactionsService do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#list' do
+ describe 'with no filters' do
+ let(:identity) { 'ID123' }
+
+ subject(:get_list_response) { client.payment_account_transactions.list(identity) }
+
+ let(:body) do
+ {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ cursors: {
+ before: nil,
+ after: 'ABC123',
+ },
+ },
+ }.to_json
+ end
+
+ before do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: body,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps each item in the resource class' do
+ expect(get_list_response.records.map do |x|
+ x.class
+ end.uniq.first).to eq(GoCardlessPro::Resources::PaymentAccountTransaction)
+
+ expect(get_list_response.records.first.amount).to eq('amount-input')
+
+ expect(get_list_response.records.first.balance_after_transaction).to eq('balance_after_transaction-input')
+
+ expect(get_list_response.records.first.counterparty_name).to eq('counterparty_name-input')
+
+ expect(get_list_response.records.first.currency).to eq('currency-input')
+
+ expect(get_list_response.records.first.description).to eq('description-input')
+
+ expect(get_list_response.records.first.direction).to eq('direction-input')
+
+ expect(get_list_response.records.first.id).to eq('id-input')
+
+ expect(get_list_response.records.first.reference).to eq('reference-input')
+
+ expect(get_list_response.records.first.value_date).to eq('value_date-input')
+ end
+
+ it 'exposes the cursors for before and after' do
+ expect(get_list_response.before).to eq(nil)
+ expect(get_list_response.after).to eq('ABC123')
+ end
+
+ specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+
+ get_list_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors' do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
+
+ get_list_response
+ expect(stub).to have_been_requested.twice
+ end
+ end
+ end
+ end
+
+ describe '#all' do
+ let(:identity) { 'ID123' }
+
+ let!(:first_response_stub) do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}$/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ let!(:second_response_stub) do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}\?after=AB345/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'automatically makes the extra requests' do
+ expect(client.payment_account_transactions.all(identity).to_a.length).to eq(2)
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested
+ end
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ first_response_stub = stub_request(:get, /.*api.gocardless.com#{stub_url}$/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ second_response_stub = stub_request(:get, /.*api.gocardless.com#{stub_url}\?after=AB345/).
+ to_timeout.then.
+ to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ client.payment_account_transactions.all(identity).to_a
+
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors' do
+ stub_url = '/payment_accounts/:identity/transactions'.gsub(':identity', identity)
+ first_response_stub = stub_request(:get, /.*api.gocardless.com#{stub_url}$/).to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ second_response_stub = stub_request(:get, /.*api.gocardless.com#{stub_url}\?after=AB345/).
+ to_return(
+ status: 502,
+ body: 'Response from Cloudflare',
+ headers: { 'Content-Type' => 'text/html' }
+ ).then.to_return(
+ body: {
+ 'payment_account_transactions' => [{
+
+ 'amount' => 'amount-input',
+ 'balance_after_transaction' => 'balance_after_transaction-input',
+ 'counterparty_name' => 'counterparty_name-input',
+ 'currency' => 'currency-input',
+ 'description' => 'description-input',
+ 'direction' => 'direction-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ 'reference' => 'reference-input',
+ 'value_date' => 'value_date-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ client.payment_account_transactions.all(identity).to_a
+
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested.twice
+ end
+ end
+ end
+end
diff --git a/spec/services/payment_accounts_service_spec.rb b/spec/services/payment_accounts_service_spec.rb
new file mode 100644
index 00000000..c3c7f0f2
--- /dev/null
+++ b/spec/services/payment_accounts_service_spec.rb
@@ -0,0 +1,392 @@
+require 'spec_helper'
+
+describe GoCardlessPro::Services::PaymentAccountsService do
+ let(:client) do
+ GoCardlessPro::Client.new(
+ access_token: 'SECRET_TOKEN'
+ )
+ end
+
+ let(:response_headers) { { 'Content-Type' => 'application/json' } }
+
+ describe '#get' do
+ let(:id) { 'ID123' }
+
+ subject(:get_response) { client.payment_accounts.get(id) }
+
+ context 'passing in a custom header' do
+ let!(:stub) do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
+ body: {
+ 'payment_accounts' => {
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ subject(:get_response) do
+ client.payment_accounts.get(id, headers: {
+ 'Foo' => 'Bar',
+ })
+ end
+
+ it 'includes the header' do
+ get_response
+ expect(stub).to have_been_requested
+ end
+ end
+
+ context 'when there is a payment_account to return' do
+ before do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: {
+ 'payment_accounts' => {
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps the response in a resource' do
+ expect(get_response).to be_a(GoCardlessPro::Resources::PaymentAccount)
+ end
+ end
+
+ context 'when nothing is returned' do
+ before do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
+ body: '',
+ headers: response_headers
+ )
+ end
+
+ it 'returns nil' do
+ expect(get_response).to be_nil
+ end
+ end
+
+ context "when an ID is specified which can't be included in a valid URI" do
+ let(:id) { '`' }
+
+ it "doesn't raise an error" do
+ expect { get_response }.to_not raise_error(/bad URI/)
+ end
+ end
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
+
+ get_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors, other than 500s' do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
+
+ get_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 500 errors returned by the API' do
+ stub_url = '/payment_accounts/:identity'.gsub(':identity', id)
+
+ gocardless_error = {
+ 'error' => {
+ 'message' => 'Internal server error',
+ 'documentation_url' => 'https://developer.gocardless.com/#gocardless',
+ 'errors' => [{
+ 'message' => 'Internal server error',
+ 'reason' => 'internal_server_error',
+ }],
+ 'type' => 'gocardless',
+ 'code' => 500,
+ 'request_id' => 'dummy_request_id',
+ 'id' => 'dummy_exception_id',
+ },
+ }
+
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
+
+ get_response
+ expect(stub).to have_been_requested.twice
+ end
+ end
+ end
+
+ describe '#list' do
+ describe 'with no filters' do
+ subject(:get_list_response) { client.payment_accounts.list }
+
+ let(:body) do
+ {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ cursors: {
+ before: nil,
+ after: 'ABC123',
+ },
+ },
+ }.to_json
+ end
+
+ before do
+ stub_request(:get, %r{.*api.gocardless.com/payment_accounts}).to_return(
+ body: body,
+ headers: response_headers
+ )
+ end
+
+ it 'wraps each item in the resource class' do
+ expect(get_list_response.records.map do |x|
+ x.class
+ end.uniq.first).to eq(GoCardlessPro::Resources::PaymentAccount)
+
+ expect(get_list_response.records.first.account_balance).to eq('account_balance-input')
+
+ expect(get_list_response.records.first.account_holder_name).to eq('account_holder_name-input')
+
+ expect(get_list_response.records.first.account_number_ending).to eq('account_number_ending-input')
+
+ expect(get_list_response.records.first.bank_name).to eq('bank_name-input')
+
+ expect(get_list_response.records.first.currency).to eq('currency-input')
+
+ expect(get_list_response.records.first.id).to eq('id-input')
+ end
+
+ it 'exposes the cursors for before and after' do
+ expect(get_list_response.before).to eq(nil)
+ expect(get_list_response.after).to eq('ABC123')
+ end
+
+ specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+
+ get_list_response
+ expect(stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors' do
+ stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
+
+ get_list_response
+ expect(stub).to have_been_requested.twice
+ end
+ end
+ end
+ end
+
+ describe '#all' do
+ let!(:first_response_stub) do
+ stub_request(:get, %r{.*api.gocardless.com/payment_accounts$}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ let!(:second_response_stub) do
+ stub_request(:get, %r{.*api.gocardless.com/payment_accounts\?after=AB345}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+ end
+
+ it 'automatically makes the extra requests' do
+ expect(client.payment_accounts.all.to_a.length).to eq(2)
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested
+ end
+
+ describe 'retry behaviour' do
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
+
+ it 'retries timeouts' do
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts$}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts\?after=AB345}).
+ to_timeout.then.
+ to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ client.payment_accounts.all.to_a
+
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested.twice
+ end
+
+ it 'retries 5XX errors' do
+ first_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts$}).to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ cursors: { after: 'AB345' },
+ limit: 1,
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payment_accounts\?after=AB345}).
+ to_return(
+ status: 502,
+ body: 'Response from Cloudflare',
+ headers: { 'Content-Type' => 'text/html' }
+ ).then.to_return(
+ body: {
+ 'payment_accounts' => [{
+
+ 'account_balance' => 'account_balance-input',
+ 'account_holder_name' => 'account_holder_name-input',
+ 'account_number_ending' => 'account_number_ending-input',
+ 'bank_name' => 'bank_name-input',
+ 'currency' => 'currency-input',
+ 'id' => 'id-input',
+ 'links' => 'links-input',
+ }],
+ meta: {
+ limit: 2,
+ cursors: {},
+ },
+ }.to_json,
+ headers: response_headers
+ )
+
+ client.payment_accounts.all.to_a
+
+ expect(first_response_stub).to have_been_requested
+ expect(second_response_stub).to have_been_requested.twice
+ end
+ end
+ end
+end
diff --git a/spec/services/payments_service_spec.rb b/spec/services/payments_service_spec.rb
index c0a6908c..58449365 100644
--- a/spec/services/payments_service_spec.rb
+++ b/spec/services/payments_service_spec.rb
@@ -28,13 +28,14 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/payments})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/payments}).
+ with(
body: {
'payments' => {
@@ -51,11 +52,12 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'payments' =>
@@ -74,8 +76,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -90,19 +93,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/payments})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/payments}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/payments})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/payments}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -120,9 +123,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -153,7 +156,8 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}
end
@@ -168,11 +172,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -181,8 +185,8 @@
let!(:get_stub) do
stub_url = "/payments/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'payments' => {
@@ -199,8 +203,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -223,8 +228,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -251,14 +256,15 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -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
@@ -310,19 +318,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/payments})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/payments}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/payments})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/payments}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -350,12 +358,13 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -379,12 +388,13 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -417,19 +427,20 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payments\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payments\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'payments' => [{
@@ -446,12 +457,13 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -480,18 +492,19 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payments\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payments\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -512,12 +525,13 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -538,9 +552,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/payments/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'payments' => {
@@ -557,8 +571,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -566,7 +581,7 @@
subject(:get_response) do
client.payments.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -596,8 +611,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -636,8 +652,8 @@
it 'retries timeouts' do
stub_url = '/payments/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -646,11 +662,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/payments/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -665,20 +681,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -712,8 +728,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -729,8 +746,8 @@
it 'retries timeouts' do
stub_url = '/payments/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -738,11 +755,11 @@
it 'retries 5XX errors' do
stub_url = '/payments/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -776,8 +793,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -793,8 +811,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/payments/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -811,8 +829,8 @@
let!(:stub) do
# /payments/%v/actions/cancel
stub_url = '/payments/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -832,8 +850,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -866,8 +885,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -883,8 +903,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/payments/:identity/actions/retry'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -901,8 +921,8 @@
let!(:stub) do
# /payments/%v/actions/retry
stub_url = '/payments/:identity/actions/retry'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -922,8 +942,9 @@
'metadata' => 'metadata-input',
'reference' => 'reference-input',
'retry_if_possible' => 'retry_if_possible-input',
- 'status' => 'status-input'
- }
+ 'scheme' => 'scheme-input',
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/payout_items_service_spec.rb b/spec/services/payout_items_service_spec.rb
index ef699c55..7101753d 100644
--- a/spec/services/payout_items_service_spec.rb
+++ b/spec/services/payout_items_service_spec.rb
@@ -20,14 +20,14 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -59,19 +59,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/payout_items})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/payout_items}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/payout_items})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/payout_items}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -89,12 +89,12 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -108,12 +108,12 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -136,31 +136,31 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payout_items\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payout_items\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'payout_items' => [{
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -179,18 +179,18 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payout_items\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payout_items\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -201,12 +201,12 @@
'amount' => 'amount-input',
'links' => 'links-input',
'taxes' => 'taxes-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/payouts_service_spec.rb b/spec/services/payouts_service_spec.rb
index 66b69a0a..91730b29 100644
--- a/spec/services/payouts_service_spec.rb
+++ b/spec/services/payouts_service_spec.rb
@@ -29,14 +29,14 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -86,19 +86,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/payouts})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/payouts}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/payouts})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/payouts}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -125,12 +125,12 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -153,12 +153,12 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -190,19 +190,19 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'payouts' => [{
@@ -218,12 +218,12 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -251,18 +251,18 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/payouts\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -282,12 +282,12 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
+ 'tax_currency' => 'tax_currency-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -308,9 +308,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/payouts/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'payouts' => {
@@ -326,8 +326,8 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
- }
+ 'tax_currency' => 'tax_currency-input',
+ },
}.to_json,
headers: response_headers
)
@@ -335,7 +335,7 @@
subject(:get_response) do
client.payouts.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -364,8 +364,8 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
- }
+ 'tax_currency' => 'tax_currency-input',
+ },
}.to_json,
headers: response_headers
)
@@ -404,8 +404,8 @@
it 'retries timeouts' do
stub_url = '/payouts/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -414,11 +414,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/payouts/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -433,20 +433,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -479,8 +479,8 @@
'payout_type' => 'payout_type-input',
'reference' => 'reference-input',
'status' => 'status-input',
- 'tax_currency' => 'tax_currency-input'
- }
+ 'tax_currency' => 'tax_currency-input',
+ },
}.to_json,
headers: response_headers
)
@@ -496,8 +496,8 @@
it 'retries timeouts' do
stub_url = '/payouts/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -505,11 +505,11 @@
it 'retries 5XX errors' do
stub_url = '/payouts/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/redirect_flows_service_spec.rb b/spec/services/redirect_flows_service_spec.rb
index b462068f..3ccf3d2e 100644
--- a/spec/services/redirect_flows_service_spec.rb
+++ b/spec/services/redirect_flows_service_spec.rb
@@ -25,13 +25,13 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
+ 'success_redirect_url' => 'success_redirect_url-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/redirect_flows}).
+ with(
body: {
'redirect_flows' => {
@@ -45,11 +45,11 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'redirect_flows' =>
@@ -65,8 +65,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
@@ -81,19 +81,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/redirect_flows}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/redirect_flows}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -111,9 +111,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -141,7 +141,7 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
+ 'success_redirect_url' => 'success_redirect_url-input',
}
end
@@ -156,11 +156,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -169,8 +169,8 @@
let!(:get_stub) do
stub_url = "/redirect_flows/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'redirect_flows' => {
@@ -184,8 +184,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -208,8 +208,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -223,9 +223,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'redirect_flows' => {
@@ -239,8 +239,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -248,7 +248,7 @@
subject(:get_response) do
client.redirect_flows.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -275,8 +275,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -315,8 +315,8 @@
it 'retries timeouts' do
stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -325,11 +325,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -344,20 +344,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -387,8 +387,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
@@ -404,8 +404,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/redirect_flows/:identity/actions/complete'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -422,8 +422,8 @@
let!(:stub) do
# /redirect_flows/%v/actions/complete
stub_url = '/redirect_flows/:identity/actions/complete'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -440,8 +440,8 @@
'redirect_url' => 'redirect_url-input',
'scheme' => 'scheme-input',
'session_token' => 'session_token-input',
- 'success_redirect_url' => 'success_redirect_url-input'
- }
+ 'success_redirect_url' => 'success_redirect_url-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/refunds_service_spec.rb b/spec/services/refunds_service_spec.rb
index 82942cf5..79d1161d 100644
--- a/spec/services/refunds_service_spec.rb
+++ b/spec/services/refunds_service_spec.rb
@@ -23,13 +23,13 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/refunds})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/refunds}).
+ with(
body: {
'refunds' => {
@@ -41,11 +41,11 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'refunds' =>
@@ -59,8 +59,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -75,19 +75,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/refunds})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/refunds}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/refunds})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/refunds}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -105,9 +105,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -133,7 +133,7 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -148,11 +148,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -161,8 +161,8 @@
let!(:get_stub) do
stub_url = "/refunds/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'refunds' => {
@@ -174,8 +174,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -198,8 +198,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -221,14 +221,14 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -270,19 +270,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/refunds})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/refunds}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/refunds})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/refunds}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -305,12 +305,12 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -329,12 +329,12 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -362,19 +362,19 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/refunds\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/refunds\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'refunds' => [{
@@ -386,12 +386,12 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -415,18 +415,18 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/refunds\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/refunds\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -442,12 +442,12 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -468,9 +468,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/refunds/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'refunds' => {
@@ -482,8 +482,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -491,7 +491,7 @@
subject(:get_response) do
client.refunds.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -516,8 +516,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -556,8 +556,8 @@
it 'retries timeouts' do
stub_url = '/refunds/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -566,11 +566,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/refunds/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -585,20 +585,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -627,8 +627,8 @@
'links' => 'links-input',
'metadata' => 'metadata-input',
'reference' => 'reference-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -644,8 +644,8 @@
it 'retries timeouts' do
stub_url = '/refunds/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -653,11 +653,11 @@
it 'retries 5XX errors' do
stub_url = '/refunds/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/scenario_simulators_service_spec.rb b/spec/services/scenario_simulators_service_spec.rb
index beb129b8..e4180350 100644
--- a/spec/services/scenario_simulators_service_spec.rb
+++ b/spec/services/scenario_simulators_service_spec.rb
@@ -21,8 +21,8 @@
body: {
'scenario_simulators' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
@@ -38,8 +38,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/scenario_simulators/:identity/actions/run'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -56,16 +56,16 @@
let!(:stub) do
# /scenario_simulators/%v/actions/run
stub_url = '/scenario_simulators/:identity/actions/run'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'scenario_simulators' => {
- 'id' => 'id-input'
- }
+ 'id' => 'id-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/scheme_identifiers_service_spec.rb b/spec/services/scheme_identifiers_service_spec.rb
index 337aea94..e5f39b2a 100644
--- a/spec/services/scheme_identifiers_service_spec.rb
+++ b/spec/services/scheme_identifiers_service_spec.rb
@@ -32,13 +32,13 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers}).
+ with(
body: {
'scheme_identifiers' => {
@@ -59,11 +59,11 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'scheme_identifiers' =>
@@ -86,8 +86,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
@@ -102,19 +102,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/scheme_identifiers}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -132,9 +132,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -169,7 +169,7 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}
end
@@ -184,11 +184,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -197,8 +197,8 @@
let!(:get_stub) do
stub_url = "/scheme_identifiers/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'scheme_identifiers' => {
@@ -219,8 +219,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -243,8 +243,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -275,14 +275,14 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -346,19 +346,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -390,12 +390,12 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -423,12 +423,12 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -465,19 +465,19 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'scheme_identifiers' => [{
@@ -498,12 +498,12 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -536,18 +536,18 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/scheme_identifiers\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -572,12 +572,12 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
+ 'status' => 'status-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -598,9 +598,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/scheme_identifiers/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'scheme_identifiers' => {
@@ -621,8 +621,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -630,7 +630,7 @@
subject(:get_response) do
client.scheme_identifiers.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -664,8 +664,8 @@
'reference' => 'reference-input',
'region' => 'region-input',
'scheme' => 'scheme-input',
- 'status' => 'status-input'
- }
+ 'status' => 'status-input',
+ },
}.to_json,
headers: response_headers
)
@@ -704,8 +704,8 @@
it 'retries timeouts' do
stub_url = '/scheme_identifiers/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -714,11 +714,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/scheme_identifiers/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -733,20 +733,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/subscriptions_service_spec.rb b/spec/services/subscriptions_service_spec.rb
index f9473768..060f5535 100644
--- a/spec/services/subscriptions_service_spec.rb
+++ b/spec/services/subscriptions_service_spec.rb
@@ -35,13 +35,13 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/subscriptions})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/subscriptions}).
+ with(
body: {
'subscriptions' => {
@@ -65,11 +65,11 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'subscriptions' =>
@@ -95,8 +95,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -111,19 +111,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/subscriptions})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/subscriptions}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/subscriptions})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/subscriptions}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -141,9 +141,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -181,7 +181,7 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}
end
@@ -196,11 +196,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -209,8 +209,8 @@
let!(:get_stub) do
stub_url = "/subscriptions/#{id}"
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return(
body: {
'subscriptions' => {
@@ -234,8 +234,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -258,8 +258,8 @@
end
it 'raises an IdempotencyConflict error' do
- expect { post_create_response }
- .to raise_error(GoCardlessPro::IdempotencyConflict)
+ expect { post_create_response }.
+ to raise_error(GoCardlessPro::IdempotencyConflict)
end
end
end
@@ -293,14 +293,14 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -366,19 +366,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -413,12 +413,12 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -449,12 +449,12 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -494,19 +494,19 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'subscriptions' => [{
@@ -530,12 +530,12 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -571,18 +571,18 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/subscriptions\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -610,12 +610,12 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
+ 'upcoming_payments' => 'upcoming_payments-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -636,9 +636,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/subscriptions/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'subscriptions' => {
@@ -662,8 +662,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -671,7 +671,7 @@
subject(:get_response) do
client.subscriptions.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -708,8 +708,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -748,8 +748,8 @@
it 'retries timeouts' do
stub_url = '/subscriptions/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -758,11 +758,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/subscriptions/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -777,20 +777,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -831,8 +831,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -848,8 +848,8 @@
it 'retries timeouts' do
stub_url = '/subscriptions/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -857,11 +857,11 @@
it 'retries 5XX errors' do
stub_url = '/subscriptions/:identity'.gsub(':identity', id)
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
put_update_response
expect(stub).to have_been_requested.twice
@@ -902,8 +902,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -919,8 +919,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -937,8 +937,8 @@
let!(:stub) do
# /subscriptions/%v/actions/pause
stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -965,8 +965,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1006,8 +1006,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -1023,8 +1023,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -1041,8 +1041,8 @@
let!(:stub) do
# /subscriptions/%v/actions/resume
stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1069,8 +1069,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
@@ -1110,8 +1110,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
@@ -1127,8 +1127,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/subscriptions/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -1145,8 +1145,8 @@
let!(:stub) do
# /subscriptions/%v/actions/cancel
stub_url = '/subscriptions/:identity/actions/cancel'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -1173,8 +1173,8 @@
'retry_if_possible' => 'retry_if_possible-input',
'start_date' => 'start_date-input',
'status' => 'status-input',
- 'upcoming_payments' => 'upcoming_payments-input'
- }
+ 'upcoming_payments' => 'upcoming_payments-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/tax_rates_service_spec.rb b/spec/services/tax_rates_service_spec.rb
index f3a8758f..7ac82a93 100644
--- a/spec/services/tax_rates_service_spec.rb
+++ b/spec/services/tax_rates_service_spec.rb
@@ -22,14 +22,14 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -67,19 +67,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -99,12 +99,12 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -120,12 +120,12 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -150,19 +150,19 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'tax_rates' => [{
@@ -171,12 +171,12 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -197,18 +197,18 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/tax_rates\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -221,12 +221,12 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
+ 'type' => 'type-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -247,9 +247,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/tax_rates/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'tax_rates' => {
@@ -258,8 +258,8 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
)
@@ -267,7 +267,7 @@
subject(:get_response) do
client.tax_rates.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -289,8 +289,8 @@
'jurisdiction' => 'jurisdiction-input',
'percentage' => 'percentage-input',
'start_date' => 'start_date-input',
- 'type' => 'type-input'
- }
+ 'type' => 'type-input',
+ },
}.to_json,
headers: response_headers
)
@@ -329,8 +329,8 @@
it 'retries timeouts' do
stub_url = '/tax_rates/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -339,11 +339,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/tax_rates/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -358,20 +358,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
diff --git a/spec/services/transferred_mandates_service_spec.rb b/spec/services/transferred_mandates_service_spec.rb
index 3f2f369c..3d78d3f4 100644
--- a/spec/services/transferred_mandates_service_spec.rb
+++ b/spec/services/transferred_mandates_service_spec.rb
@@ -24,8 +24,8 @@
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
- 'public_key_id' => 'public_key_id-input'
- }
+ 'public_key_id' => 'public_key_id-input',
+ },
}.to_json,
headers: response_headers
@@ -41,8 +41,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout
expect { get_response }.to raise_error(Faraday::ConnectionFailed)
expect(stub).to have_been_requested
@@ -59,8 +59,8 @@
let!(:stub) do
# /transferred_mandates/%v
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -70,8 +70,8 @@
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
- 'public_key_id' => 'public_key_id-input'
- }
+ 'public_key_id' => 'public_key_id-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/verification_details_service_spec.rb b/spec/services/verification_details_service_spec.rb
index ab0fe04f..f3ce3d14 100644
--- a/spec/services/verification_details_service_spec.rb
+++ b/spec/services/verification_details_service_spec.rb
@@ -24,13 +24,13 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}
end
before do
- stub_request(:post, %r{.*api.gocardless.com/verification_details})
- .with(
+ stub_request(:post, %r{.*api.gocardless.com/verification_details}).
+ with(
body: {
'verification_details' => {
@@ -43,11 +43,11 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
- }
+ 'postal_code' => 'postal_code-input',
+ },
}
- )
- .to_return(
+ ).
+ to_return(
body: {
'verification_details' =>
@@ -62,8 +62,8 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
- }
+ 'postal_code' => 'postal_code-input',
+ },
}.to_json,
headers: response_headers
@@ -78,19 +78,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:post, %r{.*api.gocardless.com/verification_details})
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/verification_details}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:post, %r{.*api.gocardless.com/verification_details})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:post, %r{.*api.gocardless.com/verification_details}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
post_create_response
expect(stub).to have_been_requested.twice
@@ -108,9 +108,9 @@
type: 'validation_failed',
code: 422,
errors: [
- { message: 'test error message', field: 'test_field' }
- ]
- }
+ { message: 'test error message', field: 'test_field' },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 422
@@ -137,7 +137,7 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}
end
@@ -152,11 +152,11 @@
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
- conflicting_resource_id: id
- }
- }
- ]
- }
+ conflicting_resource_id: id,
+ },
+ },
+ ],
+ },
}.to_json,
headers: response_headers,
status: 409
@@ -187,14 +187,14 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -240,19 +240,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/verification_details})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/verification_details}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/verification_details})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/verification_details}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -276,12 +276,12 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -301,12 +301,12 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -335,19 +335,19 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/verification_details\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/verification_details\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'verification_details' => [{
@@ -360,12 +360,12 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -390,18 +390,18 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/verification_details\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/verification_details\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -418,12 +418,12 @@
'directors' => 'directors-input',
'links' => 'links-input',
'name' => 'name-input',
- 'postal_code' => 'postal_code-input'
+ 'postal_code' => 'postal_code-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/services/webhooks_service_spec.rb b/spec/services/webhooks_service_spec.rb
index 32b5ccc8..76b705b4 100644
--- a/spec/services/webhooks_service_spec.rb
+++ b/spec/services/webhooks_service_spec.rb
@@ -29,14 +29,14 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
cursors: {
before: nil,
- after: 'ABC123'
- }
- }
+ after: 'ABC123',
+ },
+ },
}.to_json
end
@@ -88,19 +88,19 @@
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
it 'retries timeouts' do
- stub = stub_request(:get, %r{.*api.gocardless.com/webhooks})
- .to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/webhooks}).
+ to_timeout.then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
end
it 'retries 5XX errors' do
- stub = stub_request(:get, %r{.*api.gocardless.com/webhooks})
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers, body: body })
+ stub = stub_request(:get, %r{.*api.gocardless.com/webhooks}).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers, body: body })
get_list_response
expect(stub).to have_been_requested.twice
@@ -127,12 +127,12 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
@@ -155,12 +155,12 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -192,19 +192,19 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/webhooks\?after=AB345})
- .to_timeout.then
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/webhooks\?after=AB345}).
+ to_timeout.then.
+ to_return(
body: {
'webhooks' => [{
@@ -220,12 +220,12 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -253,18 +253,18 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
cursors: { after: 'AB345' },
- limit: 1
- }
+ limit: 1,
+ },
}.to_json,
headers: response_headers
)
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/webhooks\?after=AB345})
- .to_return(
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/webhooks\?after=AB345}).
+ to_return(
status: 502,
body: 'Response from Cloudflare',
headers: { 'Content-Type' => 'text/html' }
@@ -284,12 +284,12 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
+ 'url' => 'url-input',
}],
meta: {
limit: 2,
- cursors: {}
- }
+ cursors: {},
+ },
}.to_json,
headers: response_headers
)
@@ -310,9 +310,9 @@
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/webhooks/:identity'.gsub(':identity', id)
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .with(headers: { 'Foo' => 'Bar' })
- .to_return(
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ with(headers: { 'Foo' => 'Bar' }).
+ to_return(
body: {
'webhooks' => {
@@ -328,8 +328,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -337,7 +337,7 @@
subject(:get_response) do
client.webhooks.get(id, headers: {
- 'Foo' => 'Bar'
+ 'Foo' => 'Bar',
})
end
@@ -366,8 +366,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
@@ -406,8 +406,8 @@
it 'retries timeouts' do
stub_url = '/webhooks/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_timeout.then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_timeout.then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -416,11 +416,11 @@
it 'retries 5XX errors, other than 500s' do
stub_url = '/webhooks/:identity'.gsub(':identity', id)
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 502,
- headers: { 'Content-Type' => 'text/html' },
- body: 'Response from Cloudflare' })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 502,
+ headers: { 'Content-Type' => 'text/html' },
+ body: 'Response from Cloudflare' }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -435,20 +435,20 @@
'documentation_url' => 'https://developer.gocardless.com/#gocardless',
'errors' => [{
'message' => 'Internal server error',
- 'reason' => 'internal_server_error'
+ 'reason' => 'internal_server_error',
}],
'type' => 'gocardless',
'code' => 500,
'request_id' => 'dummy_request_id',
- 'id' => 'dummy_exception_id'
- }
+ 'id' => 'dummy_exception_id',
+ },
}
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
- .to_return({ status: 500,
- headers: response_headers,
- body: gocardless_error.to_json })
- .then.to_return({ status: 200, headers: response_headers })
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
+ to_return({ status: 500,
+ headers: response_headers,
+ body: gocardless_error.to_json }).
+ then.to_return({ status: 200, headers: response_headers })
get_response
expect(stub).to have_been_requested.twice
@@ -480,8 +480,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
@@ -497,8 +497,8 @@
describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/webhooks/:identity/actions/retry'.gsub(':identity', resource_id)
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .to_timeout
+ 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
@@ -515,8 +515,8 @@
let!(:stub) do
# /webhooks/%v/actions/retry
stub_url = '/webhooks/:identity/actions/retry'.gsub(':identity', resource_id)
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
- .with(
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
+ with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
@@ -535,8 +535,8 @@
'response_headers_content_truncated' => 'response_headers_content_truncated-input',
'response_headers_count_truncated' => 'response_headers_count_truncated-input',
'successful' => 'successful-input',
- 'url' => 'url-input'
- }
+ 'url' => 'url-input',
+ },
}.to_json,
headers: response_headers
)
diff --git a/spec/webhook_spec.rb b/spec/webhook_spec.rb
index aa370a22..37a1a45f 100644
--- a/spec/webhook_spec.rb
+++ b/spec/webhook_spec.rb
@@ -6,7 +6,7 @@
{
request_body: request_body,
signature_header: signature_header,
- webhook_endpoint_secret: webhook_endpoint_secret
+ webhook_endpoint_secret: webhook_endpoint_secret,
}
end
@@ -40,8 +40,8 @@
expect(events.first.links.subscription).to eq('SB0003JJQ2MR06')
expect(events.first.details['origin']).to eq('api')
expect(events.first.details['cause']).to eq('subscription_created')
- expect(events.first.details['description'])
- .to eq('Subscription created via the API.')
+ expect(events.first.details['description']).
+ to eq('Subscription created via the API.')
expect(events.first.metadata).to eq({})
expect(events.last.id).to eq('EV00BD05TB8K63')
@@ -51,8 +51,8 @@
expect(events.last.links.mandate).to eq('MD000AMA19XGEC')
expect(events.last.details['origin']).to eq('api')
expect(events.last.details['cause']).to eq('mandate_created')
- expect(events.last.details['description'])
- .to eq('Mandate created via the API.')
+ expect(events.last.details['description']).
+ to eq('Mandate created via the API.')
expect(events.last.metadata).to eq({})
end
end
@@ -61,9 +61,9 @@
let(:webhook_endpoint_secret) { 'foo' }
it 'raises an InvalidSignatureError' do
- expect { described_class.parse(options) }
- .to raise_error(described_class::InvalidSignatureError,
- /doesn't appear to be a genuine webhook from GoCardless/)
+ expect { described_class.parse(options) }.
+ to raise_error(described_class::InvalidSignatureError,
+ /doesn't appear to be a genuine webhook from GoCardless/)
end
end
@@ -71,9 +71,9 @@
before { options.delete(:request_body) }
it 'raises an ArgumentError' do
- expect { described_class.signature_valid?(options) }
- .to raise_error(ArgumentError,
- 'request_body must be provided and must be a string')
+ expect { described_class.signature_valid?(options) }.
+ to raise_error(ArgumentError,
+ 'request_body must be provided and must be a string')
end
end
@@ -81,9 +81,9 @@
let(:request_body) { StringIO.new }
it 'raises an ArgumentError' do
- expect { described_class.signature_valid?(options) }
- .to raise_error(ArgumentError,
- 'request_body must be provided and must be a string')
+ expect { described_class.signature_valid?(options) }.
+ to raise_error(ArgumentError,
+ 'request_body must be provided and must be a string')
end
end
end
@@ -103,9 +103,9 @@
before { options.delete(:request_body) }
it 'raises an ArgumentError' do
- expect { described_class.signature_valid?(options) }
- .to raise_error(ArgumentError,
- 'request_body must be provided and must be a string')
+ expect { described_class.signature_valid?(options) }.
+ to raise_error(ArgumentError,
+ 'request_body must be provided and must be a string')
end
end
@@ -113,9 +113,9 @@
let(:request_body) { StringIO.new }
it 'raises an ArgumentError' do
- expect { described_class.signature_valid?(options) }
- .to raise_error(ArgumentError,
- 'request_body must be provided and must be a string')
+ expect { described_class.signature_valid?(options) }.
+ to raise_error(ArgumentError,
+ 'request_body must be provided and must be a string')
end
end
end