diff --git a/README.rst b/README.rst index 859fba35..8f2451d8 100644 --- a/README.rst +++ b/README.rst @@ -95,6 +95,17 @@ Bank account details # Get encrypted bank details client.bank_account_details.get('BA123', params={...}) +Bank account holder verifications +'''''''''''''''''''''''''''''''''''''''''' + +.. code:: python + + # Create a bank account holder verification. + client.bank_account_holder_verifications.create(params={...}) + + # Get a bank account holder verification. + client.bank_account_holder_verifications.get('BAHV123', params={...}) + Bank authorisations '''''''''''''''''''''''''''''''''''''''''' @@ -356,6 +367,14 @@ Exports # Iterate through all exports client.exports.all(params={...}) +Funds availabilities +'''''''''''''''''''''''''''''''''''''''''' + +.. code:: python + + # Funds availability + client.funds_availabilities.check('MD123', params={...}) + Instalment schedules '''''''''''''''''''''''''''''''''''''''''' @@ -509,6 +528,9 @@ Outbound payments # Update an outbound payment client.outbound_payments.update('OUT123', params={...}) + # Outbound payment statistics + client.outbound_payments.stats(params={...}) + Payer authorisations '''''''''''''''''''''''''''''''''''''''''' @@ -563,6 +585,20 @@ Payments # Retry a payment client.payments.retry('PM123', params={...}) +Payment accounts +'''''''''''''''''''''''''''''''''''''''''' + +.. code:: python + + # Get a single payment account details + client.payment_accounts.get('BA123', params={...}) + + # List payment accounts + client.payment_accounts.list(params={...}) + + # Iterate through all payment_accounts + client.payment_accounts.all(params={...}) + Payment account transactions '''''''''''''''''''''''''''''''''''''''''' diff --git a/gocardless_pro/api_client.py b/gocardless_pro/api_client.py index 9b127d8e..d888496c 100644 --- a/gocardless_pro/api_client.py +++ b/gocardless_pro/api_client.py @@ -131,8 +131,17 @@ def _handle_errors(self, response): if response.status_code < 400: return - error = response.json()['error'] - exception_class = errors.ApiError.exception_for(response.status_code, error['type'], error.get('errors')) + error = response_body.get('error', response_body) + + if isinstance(error, str): + error = { + 'code': response.status_code, + 'message': error, + } + exception_class = errors.ApiError + else: + exception_class = errors.ApiError.exception_for(response.status_code, error['type'], error.get('errors')) + raise exception_class(error) def _url_for(self, path): diff --git a/gocardless_pro/client.py b/gocardless_pro/client.py index a33e0be0..b37e1788 100644 --- a/gocardless_pro/client.py +++ b/gocardless_pro/client.py @@ -13,7 +13,7 @@ class Client(object): use the resource methods to access the API. Args: - access_token (str): Find or generate this in your GoCardless Pro dashboard + access_token (str): Find or generate this in your GoCardless dashboard (https://manage.gocardless.com/organisation/access-tokens). environment (str): Either 'sandbox' or 'live'. base_url (str): Manually set a base URL. Most people should use @@ -45,6 +45,10 @@ def balances(self): def bank_account_details(self): return services.BankAccountDetailsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) + @property + def bank_account_holder_verifications(self): + return services.BankAccountHolderVerificationsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) + @property def bank_authorisations(self): return services.BankAuthorisationsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) @@ -105,6 +109,10 @@ def events(self): def exports(self): return services.ExportsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) + @property + def funds_availabilities(self): + return services.FundsAvailabilitiesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) + @property def instalment_schedules(self): return services.InstalmentSchedulesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) @@ -153,6 +161,10 @@ def payer_themes(self): def payments(self): return services.PaymentsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) + @property + def payment_accounts(self): + return services.PaymentAccountsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) + @property def payment_account_transactions(self): return services.PaymentAccountTransactionsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict) diff --git a/gocardless_pro/resources/__init__.py b/gocardless_pro/resources/__init__.py index dccc8b88..33b68e06 100644 --- a/gocardless_pro/resources/__init__.py +++ b/gocardless_pro/resources/__init__.py @@ -7,6 +7,8 @@ from .bank_account_detail import BankAccountDetail +from .bank_account_holder_verification import BankAccountHolderVerification + from .bank_authorisation import BankAuthorisation from .bank_details_lookup import BankDetailsLookup @@ -37,6 +39,8 @@ from .export import Export +from .funds_availability import FundsAvailability + from .instalment_schedule import InstalmentSchedule from .institution import Institution @@ -61,6 +65,8 @@ from .payment import Payment +from .payment_account import PaymentAccount + from .payment_account_transaction import PaymentAccountTransaction from .payout import Payout diff --git a/gocardless_pro/resources/bank_account_holder_verification.py b/gocardless_pro/resources/bank_account_holder_verification.py new file mode 100644 index 00000000..d6867834 --- /dev/null +++ b/gocardless_pro/resources/bank_account_holder_verification.py @@ -0,0 +1,54 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +class BankAccountHolderVerification(object): + """A thin wrapper around a bank_account_holder_verification, providing easy access to its + attributes. + + Example: + bank_account_holder_verification = client.bank_account_holder_verifications.get() + bank_account_holder_verification.id + """ + + def __init__(self, attributes, api_response): + self.attributes = attributes + self.api_response = api_response + + @property + def actual_account_name(self): + return self.attributes.get('actual_account_name') + + + @property + def id(self): + return self.attributes.get('id') + + + @property + def result(self): + return self.attributes.get('result') + + + @property + def status(self): + return self.attributes.get('status') + + + @property + def type(self): + return self.attributes.get('type') + + + + + + + + + + + + + diff --git a/gocardless_pro/resources/billing_request.py b/gocardless_pro/resources/billing_request.py index 9e231691..975bf148 100644 --- a/gocardless_pro/resources/billing_request.py +++ b/gocardless_pro/resources/billing_request.py @@ -61,6 +61,16 @@ def metadata(self): return self.attributes.get('metadata') + @property + def payment_context_code(self): + return self.attributes.get('payment_context_code') + + + @property + def payment_purpose_code(self): + return self.attributes.get('payment_purpose_code') + + @property def payment_request(self): return self.PaymentRequest(self.attributes.get('payment_request')) @@ -275,6 +285,10 @@ def verify(self): + + + + class PaymentRequest(object): """Wrapper for the response's 'payment_request' attribute.""" diff --git a/gocardless_pro/resources/billing_request_with_action.py b/gocardless_pro/resources/billing_request_with_action.py index 25b3d404..f04666dd 100644 --- a/gocardless_pro/resources/billing_request_with_action.py +++ b/gocardless_pro/resources/billing_request_with_action.py @@ -119,6 +119,14 @@ def mandate_request(self): def metadata(self): return self.attributes.get('metadata') + @property + def payment_context_code(self): + return self.attributes.get('payment_context_code') + + @property + def payment_purpose_code(self): + return self.attributes.get('payment_purpose_code') + @property def payment_request(self): return self.attributes.get('payment_request') diff --git a/gocardless_pro/resources/event.py b/gocardless_pro/resources/event.py index 53f2b066..0f4ca4cb 100644 --- a/gocardless_pro/resources/event.py +++ b/gocardless_pro/resources/event.py @@ -187,6 +187,10 @@ def new_mandate(self): def organisation(self): return self.attributes.get('organisation') + @property + def outbound_payment(self): + return self.attributes.get('outbound_payment') + @property def parent_event(self): return self.attributes.get('parent_event') diff --git a/gocardless_pro/resources/funds_availability.py b/gocardless_pro/resources/funds_availability.py new file mode 100644 index 00000000..e7203588 --- /dev/null +++ b/gocardless_pro/resources/funds_availability.py @@ -0,0 +1,26 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +class FundsAvailability(object): + """A thin wrapper around a funds_availability, providing easy access to its + attributes. + + Example: + funds_availability = client.funds_availabilities.get() + funds_availability.id + """ + + def __init__(self, attributes, api_response): + self.attributes = attributes + self.api_response = api_response + + @property + def available(self): + return self.attributes.get('available') + + + + + diff --git a/gocardless_pro/resources/payment_account.py b/gocardless_pro/resources/payment_account.py new file mode 100644 index 00000000..85317c94 --- /dev/null +++ b/gocardless_pro/resources/payment_account.py @@ -0,0 +1,79 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +class PaymentAccount(object): + """A thin wrapper around a payment_account, providing easy access to its + attributes. + + Example: + payment_account = client.payment_accounts.get() + payment_account.id + """ + + def __init__(self, attributes, api_response): + self.attributes = attributes + self.api_response = api_response + + @property + def account_balance(self): + return self.attributes.get('account_balance') + + + @property + def account_holder_name(self): + return self.attributes.get('account_holder_name') + + + @property + def account_number_ending(self): + return self.attributes.get('account_number_ending') + + + @property + def bank_name(self): + return self.attributes.get('bank_name') + + + @property + def currency(self): + return self.attributes.get('currency') + + + @property + def id(self): + return self.attributes.get('id') + + + @property + def links(self): + return self.Links(self.attributes.get('links')) + + + + + + + + + + + + + + + + + class Links(object): + """Wrapper for the response's 'links' attribute.""" + + def __init__(self, attributes): + self.attributes = attributes + + @property + def creditor(self): + return self.attributes.get('creditor') + + + diff --git a/gocardless_pro/services/__init__.py b/gocardless_pro/services/__init__.py index 718c7681..ea2bd910 100644 --- a/gocardless_pro/services/__init__.py +++ b/gocardless_pro/services/__init__.py @@ -5,6 +5,7 @@ from .balances_service import BalancesService from .bank_account_details_service import BankAccountDetailsService +from .bank_account_holder_verifications_service import BankAccountHolderVerificationsService from .bank_authorisations_service import BankAuthorisationsService from .bank_details_lookups_service import BankDetailsLookupsService from .billing_requests_service import BillingRequestsService @@ -20,6 +21,7 @@ from .customer_notifications_service import CustomerNotificationsService from .events_service import EventsService from .exports_service import ExportsService +from .funds_availabilities_service import FundsAvailabilitiesService from .instalment_schedules_service import InstalmentSchedulesService from .institutions_service import InstitutionsService from .logos_service import LogosService @@ -32,6 +34,7 @@ from .payer_authorisations_service import PayerAuthorisationsService from .payer_themes_service import PayerThemesService from .payments_service import PaymentsService +from .payment_accounts_service import PaymentAccountsService from .payment_account_transactions_service import PaymentAccountTransactionsService from .payouts_service import PayoutsService from .payout_items_service import PayoutItemsService diff --git a/gocardless_pro/services/bank_account_holder_verifications_service.py b/gocardless_pro/services/bank_account_holder_verifications_service.py new file mode 100644 index 00000000..31fc5d70 --- /dev/null +++ b/gocardless_pro/services/bank_account_holder_verifications_service.py @@ -0,0 +1,72 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +from . import base_service +from .. import resources +from ..paginator import Paginator +from .. import errors + +class BankAccountHolderVerificationsService(base_service.BaseService): + """Service class that provides access to the bank_account_holder_verifications + endpoints of the GoCardless Pro API. + """ + + RESOURCE_CLASS = resources.BankAccountHolderVerification + RESOURCE_NAME = 'bank_account_holder_verifications' + + + def create(self,params=None, headers=None): + """Create a bank account holder verification.. + + 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. + + Args: + params (dict, optional): Request body. + + Returns: + BankAccountHolderVerification + """ + path = '/bank_account_holder_verifications' + + if params is not None: + params = {self._envelope_key(): params} + + try: + response = self._perform_request('POST', path, params, headers, + retry_failures=True) + except errors.IdempotentCreationConflictError as err: + if self.raise_on_idempotency_conflict: + raise err + return self.get(identity=err.conflicting_resource_id, + params=params, + headers=headers) + return self._resource_for(response) + + + def get(self,identity,params=None, headers=None): + """Get a bank account holder verification.. + + Fetches a bank account holder verification by ID. + + Args: + identity (string): The unique identifier for the bank account holder verification resource, e.g. "BAHV123". + params (dict, optional): Query string parameters. + + Returns: + BankAccountHolderVerification + """ + path = self._sub_url_params('/bank_account_holder_verifications/:identity', { + + 'identity': identity, + }) + + + response = self._perform_request('GET', path, params, headers, + retry_failures=True) + return self._resource_for(response) + diff --git a/gocardless_pro/services/base_service.py b/gocardless_pro/services/base_service.py index f9b2a6e2..ea4e4851 100644 --- a/gocardless_pro/services/base_service.py +++ b/gocardless_pro/services/base_service.py @@ -65,7 +65,8 @@ def _envelope_key(self): def _resource_for(self, response): api_response = ApiResponse(response) - data = api_response.body[self._envelope_key()] + body = api_response.body + data = body.get(self._envelope_key()) or body.get("data") or body klass = type(self).RESOURCE_CLASS if isinstance(data, dict): return klass(data, api_response) diff --git a/gocardless_pro/services/funds_availabilities_service.py b/gocardless_pro/services/funds_availabilities_service.py new file mode 100644 index 00000000..c8b80b96 --- /dev/null +++ b/gocardless_pro/services/funds_availabilities_service.py @@ -0,0 +1,42 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +from . import base_service +from .. import resources +from ..paginator import Paginator +from .. import errors + +class FundsAvailabilitiesService(base_service.BaseService): + """Service class that provides access to the funds_availabilities + endpoints of the GoCardless Pro API. + """ + + RESOURCE_CLASS = resources.FundsAvailability + RESOURCE_NAME = 'funds_availabilities' + + + def check(self,identity,params=None, headers=None): + """Funds availability. + + 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. + + Args: + identity (string): Unique identifier, beginning with "MD". Note that this prefix may not apply to mandates created before 2016. + params (dict, optional): Query string parameters. + + Returns: + FundsAvailability + """ + path = self._sub_url_params('/funds_availability/:identity', { + + 'identity': identity, + }) + + response = self._perform_request('GET', path, params, headers, + retry_failures=False) + return self._resource_for(response) + diff --git a/gocardless_pro/services/outbound_payments_service.py b/gocardless_pro/services/outbound_payments_service.py index 8f9926f8..db35614d 100644 --- a/gocardless_pro/services/outbound_payments_service.py +++ b/gocardless_pro/services/outbound_payments_service.py @@ -194,3 +194,21 @@ def update(self,identity,params=None, headers=None): retry_failures=True) return self._resource_for(response) + + def stats(self,params=None, headers=None): + """Outbound payment statistics. + + Retrieve aggregate statistics on outbound payments. + + Args: + params (dict, optional): Query string parameters. + + Returns: + OutboundPayment + """ + path = '/outbound_payments/stats' + + response = self._perform_request('GET', path, params, headers, + retry_failures=False) + return self._resource_for(response) + diff --git a/gocardless_pro/services/payment_accounts_service.py b/gocardless_pro/services/payment_accounts_service.py new file mode 100644 index 00000000..54681940 --- /dev/null +++ b/gocardless_pro/services/payment_accounts_service.py @@ -0,0 +1,68 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +from . import base_service +from .. import resources +from ..paginator import Paginator +from .. import errors + +class PaymentAccountsService(base_service.BaseService): + """Service class that provides access to the payment_accounts + endpoints of the GoCardless Pro API. + """ + + RESOURCE_CLASS = resources.PaymentAccount + RESOURCE_NAME = 'payment_accounts' + + + def get(self,identity,params=None, headers=None): + """Get a single payment account details. + + Retrieves the details of an existing payment account. + + Args: + identity (string): Unique identifier, beginning with "BA". + params (dict, optional): Query string parameters. + + Returns: + PaymentAccount + """ + path = self._sub_url_params('/payment_accounts/:identity', { + + 'identity': identity, + }) + + + response = self._perform_request('GET', path, params, headers, + retry_failures=True) + return self._resource_for(response) + + + def list(self,params=None, headers=None): + """List payment accounts. + + Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your + payment accounts. + + Args: + params (dict, optional): Query string parameters. + + Returns: + ListResponse of PaymentAccount instances + """ + path = '/payment_accounts' + + + response = self._perform_request('GET', path, params, headers, + retry_failures=True) + return self._resource_for(response) + + def all(self,params=None): + if params is None: + params = {} + return Paginator(self, params, identity_params={ + }) + + diff --git a/gocardless_pro/services/scenario_simulators_service.py b/gocardless_pro/services/scenario_simulators_service.py index 0802cd17..2b9ddebc 100644 --- a/gocardless_pro/services/scenario_simulators_service.py +++ b/gocardless_pro/services/scenario_simulators_service.py @@ -41,7 +41,7 @@ def run(self,identity,params=None, headers=None):
  • `mandate_customer_approval_skipped`: Transitions a mandate through to `pending_submission`, as if the customer skipped the mandate approval during the mandate creation process. It must start in the `pending_customer_approval` state. Compatible only with Bacs and SEPA mandates, which support customer signatures on the mandate. All payments associated with the mandate will be transitioned to `pending_submission`. All subscriptions associated with the mandate will become `active`.
  • `mandate_failed`: Transitions a mandate through to `failed`, having been submitted to the banks but found to be invalid (for example due to invalid bank details). It must start in the `pending_submission` or `submitted` states. Not compatible with SEPA mandates, which are submitted with their first payment.
  • `mandate_expired`: Transitions a mandate through to `expired`, having been submitted to the banks, set up successfully and then expired because no collection attempts were made against it for longer than the scheme's dormancy period (13 months for Bacs, 3 years for SEPA, 15 months for ACH, Betalingsservice, and BECS). It must start in the `pending_submission` state. Not compatible with Autogiro, BECS NZ, and PAD mandates, which do not expire.
  • -
  • `mandate_transferred`: Transitions a mandate through to `transferred`, having been submitted to the banks, set up successfully and then moved to a new bank account due to the customer using the UK's Current Account Switching Service (CASS). It must start in the `pending_submission` state. Only compatible with Bacs mandates.
  • +
  • `mandate_transferred`: Transitions a mandate through to `transferred`, having been submitted to the banks, set up successfully and then moved to a new bank account due. It must start in the `pending_submission` state. Only compatible with Bacs and SEPA mandates.
  • `mandate_transferred_with_resubmission`: Transitions a mandate through `transferred` and resubmits it to the banks, can be caused be the UK's Current Account Switching Service (CASS) or when a customer contacts GoCardless to change their bank details. It must start in the `pending_submission` state. Only compatible with Bacs mandates.
  • `mandate_suspended_by_payer`: Transitions a mandate to `suspended_by_payer`, as if payer has suspended the mandate after it has been setup successfully. It must start in the `activated` state. Only compatible with PAY_TO mandates.
  • `refund_paid`: Transitions a refund to `paid`. It must start in either the `pending_submission` or `submitted` state.
  • diff --git a/tests/api_client_test.py b/tests/api_client_test.py index a3b13a34..6da7044b 100644 --- a/tests/api_client_test.py +++ b/tests/api_client_test.py @@ -138,3 +138,15 @@ def test_handles_invalid_empty_response(): with pytest.raises(errors.MalformedResponseError): client.post('/test', body={'name': 'Billy Jean'}) + +@responses.activate +def test_handles_string_error_response(): + body = json.dumps({'error': 'bank_account_exists'}) + responses.add(responses.POST, 'http://example.com/test', + body=body, status=400) + + with pytest.raises(errors.ApiError) as exception: + client.post('/test', body={'name': 'Billy Jean'}) + + assert exception.value.message == 'bank_account_exists' + assert exception.value.code == 400 diff --git a/tests/client_test.py b/tests/client_test.py index 28d05fdd..f73911d9 100644 --- a/tests/client_test.py +++ b/tests/client_test.py @@ -23,6 +23,9 @@ def test_balances_returns_service(): def test_bank_account_details_returns_service(): assert isinstance(client.bank_account_details, services.BankAccountDetailsService) +def test_bank_account_holder_verifications_returns_service(): + assert isinstance(client.bank_account_holder_verifications, services.BankAccountHolderVerificationsService) + def test_bank_authorisations_returns_service(): assert isinstance(client.bank_authorisations, services.BankAuthorisationsService) @@ -68,6 +71,9 @@ def test_events_returns_service(): def test_exports_returns_service(): assert isinstance(client.exports, services.ExportsService) +def test_funds_availabilities_returns_service(): + assert isinstance(client.funds_availabilities, services.FundsAvailabilitiesService) + def test_instalment_schedules_returns_service(): assert isinstance(client.instalment_schedules, services.InstalmentSchedulesService) @@ -104,6 +110,9 @@ def test_payer_themes_returns_service(): def test_payments_returns_service(): assert isinstance(client.payments, services.PaymentsService) +def test_payment_accounts_returns_service(): + assert isinstance(client.payment_accounts, services.PaymentAccountsService) + def test_payment_account_transactions_returns_service(): assert isinstance(client.payment_account_transactions, services.PaymentAccountTransactionsService) diff --git a/tests/fixtures/balances.json b/tests/fixtures/balances.json index f9958814..bb6a44e3 100644 --- a/tests/fixtures/balances.json +++ b/tests/fixtures/balances.json @@ -1,8 +1,10 @@ { + + "list": { "method": "GET", "path_template": "/balances", "url_params": [], - "body": {"balances":[{"amount":8081,"balance_type":"confirmed_funds","currency":"EUR","last_updated_at":"2014-01-01T12:00:00.000Z","links":{"creditor":"CR123"}},{"amount":7887,"balance_type":"confirmed_funds","currency":"EUR","last_updated_at":"2014-01-01T12:00:00.000Z","links":{"creditor":"CR123"}}],"meta":{"cursors":{"after":"example after 4059","before":"example before 1847"},"limit":50}} + "body": {"balances":[{"amount":101,"balance_type":"confirmed_funds","currency":"EUR","last_updated_at":"2014-01-01T12:00:00.000Z","links":{"creditor":"CR123"}},{"amount":102,"balance_type":"confirmed_funds","currency":"EUR","last_updated_at":"2014-01-01T12:00:00.000Z","links":{"creditor":"CR123"}}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} } } diff --git a/tests/fixtures/bank_account_details.json b/tests/fixtures/bank_account_details.json index 266315f2..ba8c7397 100644 --- a/tests/fixtures/bank_account_details.json +++ b/tests/fixtures/bank_account_details.json @@ -1,8 +1,10 @@ { + + "get": { "method": "GET", "path_template": "/bank_account_details/:identity", "url_params": ["BA123"], - "body": {"bank_account_details":{"ciphertext":"example ciphertext 4425","encrypted_key":"example encrypted_key 2081","iv":"example iv 1318","protected":"example protected 456","tag":"example tag 2540"}} + "body": {"bank_account_details":{"ciphertext":"example ciphertext 101","encrypted_key":"example encrypted_key 101","iv":"example iv 101","protected":"example protected 101","tag":"example tag 101"}} } } diff --git a/tests/fixtures/bank_account_holder_verifications.json b/tests/fixtures/bank_account_holder_verifications.json new file mode 100644 index 00000000..4b05f396 --- /dev/null +++ b/tests/fixtures/bank_account_holder_verifications.json @@ -0,0 +1,16 @@ +{ + + + "create": { + "method": "POST", + "path_template": "/bank_account_holder_verifications", + "url_params": [], + "body": {"bank_account_holder_verifications":{"actual_account_name":"Jo Doe","id":"BAHV123","result":"partial_match","status":"pending","type":"confirmation_of_payee"}} + }, + "get": { + "method": "GET", + "path_template": "/bank_account_holder_verifications/:identity", + "url_params": ["BAHV123"], + "body": {"bank_account_holder_verifications":{"actual_account_name":"Jo Doe","id":"BAHV123","result":"partial_match","status":"pending","type":"confirmation_of_payee"}} + } +} diff --git a/tests/fixtures/bank_authorisations.json b/tests/fixtures/bank_authorisations.json index 26bec99f..eba58788 100644 --- a/tests/fixtures/bank_authorisations.json +++ b/tests/fixtures/bank_authorisations.json @@ -1,14 +1,16 @@ { + + "create": { "method": "POST", "path_template": "/bank_authorisations", "url_params": [], - "body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 3300","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2025-11-20T08:25:53.465Z","expires_at":"2025-11-20T08:25:53.465Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}} + "body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 101","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-15T10:00:00.000Z","expires_at":"2024-01-15T10:00:00.000Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}} }, "get": { "method": "GET", "path_template": "/bank_authorisations/:identity", "url_params": ["BAU123"], - "body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 694","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2025-11-20T08:25:53.465Z","expires_at":"2025-11-20T08:25:53.465Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}} + "body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 102","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-15T10:00:00.000Z","expires_at":"2024-01-15T10:00:00.000Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}} } } diff --git a/tests/fixtures/bank_details_lookups.json b/tests/fixtures/bank_details_lookups.json index 379613cf..f803811f 100644 --- a/tests/fixtures/bank_details_lookups.json +++ b/tests/fixtures/bank_details_lookups.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/bank_details_lookups", diff --git a/tests/fixtures/billing_request_flows.json b/tests/fixtures/billing_request_flows.json index 3e7579d2..5ecfd774 100644 --- a/tests/fixtures/billing_request_flows.json +++ b/tests/fixtures/billing_request_flows.json @@ -1,14 +1,16 @@ { + + "create": { "method": "POST", "path_template": "/billing_request_flows", "url_params": [], - "body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2025-11-20T08:25:53.469Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2025-11-20T08:25:53.469Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":true,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":false,"skip_success_screen":true}} + "body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2024-01-15T10:00:00.000Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-01-15T10:00:00.000Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":false,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":false,"show_success_redirect_button":false,"skip_success_screen":false}} }, "initialise": { "method": "POST", "path_template": "/billing_request_flows/:identity/actions/initialise", "url_params": ["BRF123"], - "body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2025-11-20T08:25:53.469Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2025-11-20T08:25:53.469Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":true,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":false,"show_success_redirect_button":false,"skip_success_screen":true}} + "body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-01-15T10:00:00.000Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-01-15T10:00:00.000Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":true,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":true,"skip_success_screen":true}} } } diff --git a/tests/fixtures/billing_request_templates.json b/tests/fixtures/billing_request_templates.json index 89d42cd3..acc182eb 100644 --- a/tests/fixtures/billing_request_templates.json +++ b/tests/fixtures/billing_request_templates.json @@ -1,26 +1,28 @@ { + + "list": { "method": "GET", "path_template": "/billing_request_templates", "url_params": [], - "body": {"billing_request_templates":[{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 2474","max_amount_per_payment":3544,"payment_method":"example payment_method 1723","periodic_limits":[{"alignment":"creation_date","max_payments":3922,"max_total_amount":894,"period":"flexible"}],"start_date":"example start_date 1406"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"},{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 7650","max_amount_per_payment":909,"payment_method":"example payment_method 9277","periodic_limits":[{"alignment":"calendar","max_payments":5395,"max_total_amount":30,"period":"day"}],"start_date":"example start_date 2523"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 671","before":"example before 5645"},"limit":50}} + "body": {"billing_request_templates":[{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 101","max_amount_per_payment":101,"payment_method":"example payment_method 101","periodic_limits":[{"alignment":"creation_date","max_payments":101,"max_total_amount":101,"period":"week"}],"start_date":"example start_date 101"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"},{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 102","max_amount_per_payment":102,"payment_method":"example payment_method 102","periodic_limits":[{"alignment":"calendar","max_payments":102,"max_total_amount":102,"period":"month"}],"start_date":"example start_date 102"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", "path_template": "/billing_request_templates/:identity", "url_params": ["BRT123"], - "body": {"billing_request_templates":{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 8198","max_amount_per_payment":2734,"payment_method":"example payment_method 8879","periodic_limits":[{"alignment":"calendar","max_payments":7587,"max_total_amount":4721,"period":"flexible"}],"start_date":"example start_date 7208"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}} + "body": {"billing_request_templates":{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 103","max_amount_per_payment":103,"payment_method":"example payment_method 103","periodic_limits":[{"alignment":"creation_date","max_payments":103,"max_total_amount":103,"period":"year"}],"start_date":"example start_date 103"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}} }, "create": { "method": "POST", "path_template": "/billing_request_templates", "url_params": [], - "body": {"billing_request_templates":{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 3920","max_amount_per_payment":8374,"payment_method":"example payment_method 10","periodic_limits":[{"alignment":"creation_date","max_payments":9301,"max_total_amount":1267,"period":"week"}],"start_date":"example start_date 9488"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}} + "body": {"billing_request_templates":{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 104","max_amount_per_payment":104,"payment_method":"example payment_method 104","periodic_limits":[{"alignment":"calendar","max_payments":104,"max_total_amount":104,"period":"flexible"}],"start_date":"example start_date 104"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}} }, "update": { "method": "PUT", "path_template": "/billing_request_templates/:identity", "url_params": ["BRT123"], - "body": {"billing_request_templates":{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 4401","max_amount_per_payment":8140,"payment_method":"example payment_method 3973","periodic_limits":[{"alignment":"calendar","max_payments":5596,"max_total_amount":6110,"period":"day"}],"start_date":"example start_date 6872"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}} + "body": {"billing_request_templates":{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_constraints":{"end_date":"example end_date 105","max_amount_per_payment":105,"payment_method":"example payment_method 105","periodic_limits":[{"alignment":"creation_date","max_payments":105,"max_total_amount":105,"period":"day"}],"start_date":"example start_date 105"},"mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":"100.00","payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}} } } diff --git a/tests/fixtures/billing_request_with_actions.json b/tests/fixtures/billing_request_with_actions.json index aca9beac..7bd3b551 100644 --- a/tests/fixtures/billing_request_with_actions.json +++ b/tests/fixtures/billing_request_with_actions.json @@ -1,8 +1,10 @@ { + + "create_with_actions": { "method": "POST", "path_template": "/billing_requests/create_with_actions", "url_params": [], - "body": {"billing_request_with_actions":{"bank_authorisations":{"authorisation_type":"example authorisation_type 9750","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2025-11-20T08:25:53.471Z","expires_at":"2025-11-20T08:25:53.471Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"},"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 1446","authorisation_type":"example authorisation_type 9921"},"collect_customer_details":{"default_country_code":"example default_country_code 6244","incomplete_fields":{"customer":["example customer 7063"],"customer_billing_detail":["example customer_billing_detail 1436"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 325"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 8223","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 1925","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 9434","constraints":{"end_date":"example end_date 8051","max_amount_per_payment":9026,"payment_method":"example payment_method 9219","periodic_limits":[{"alignment":"calendar","max_payments":8730,"max_total_amount":3114,"period":"day"}],"start_date":"example start_date 1300"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 7045"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"payment":"example payment 7694"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"Trade","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 6487"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 1488"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 7913"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}}} + "body": {"billing_request_with_actions":{"bank_authorisations":{"authorisation_type":"example authorisation_type 101","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-01-15T10:00:00.000Z","expires_at":"2024-01-15T10:00:00.000Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"},"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 101","authorisation_type":"example authorisation_type 102"},"collect_customer_details":{"default_country_code":"example default_country_code 101","incomplete_fields":{"customer":["example customer 101"],"customer_billing_detail":["example customer_billing_detail 101"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 101"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 101","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 102","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 101","constraints":{"end_date":"example end_date 101","max_amount_per_payment":101,"payment_method":"example payment_method 101","periodic_limits":[{"alignment":"creation_date","max_payments":101,"max_total_amount":101,"period":"week"}],"start_date":"example start_date 101"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 101"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_context_code":"billing_goods_and_services_in_arrears","payment_purpose_code":"example payment_purpose_code 101","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 101"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"utility","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 102"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 101"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 101"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}}} } } diff --git a/tests/fixtures/billing_requests.json b/tests/fixtures/billing_requests.json index c76d31ff..2b589b0a 100644 --- a/tests/fixtures/billing_requests.json +++ b/tests/fixtures/billing_requests.json @@ -1,74 +1,76 @@ { + + "create": { "method": "POST", "path_template": "/billing_requests", "url_params": [], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 1737","authorisation_type":"example authorisation_type 631"},"collect_customer_details":{"default_country_code":"example default_country_code 6831","incomplete_fields":{"customer":["example customer 5429"],"customer_billing_detail":["example customer_billing_detail 5356"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 1211"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 8162","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 8511","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 3015","constraints":{"end_date":"example end_date 2888","max_amount_per_payment":495,"payment_method":"example payment_method 5466","periodic_limits":[{"alignment":"creation_date","max_payments":6258,"max_total_amount":1528,"period":"month"}],"start_date":"example start_date 8287"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 5541"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"when_available"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 563"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"Commercial","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 3090"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 6413"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 4728"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 101","authorisation_type":"example authorisation_type 101"},"collect_customer_details":{"default_country_code":"example default_country_code 101","incomplete_fields":{"customer":["example customer 101"],"customer_billing_detail":["example customer_billing_detail 101"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 101"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 101","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 102","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 101","constraints":{"end_date":"example end_date 101","max_amount_per_payment":101,"payment_method":"example payment_method 101","periodic_limits":[{"alignment":"creation_date","max_payments":101,"max_total_amount":101,"period":"week"}],"start_date":"example start_date 101"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 101"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_context_code":"billing_goods_and_services_in_arrears","payment_purpose_code":"example payment_purpose_code 101","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 101"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"utility","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 102"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 101"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 101"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "collect_customer_details": { "method": "POST", "path_template": "/billing_requests/:identity/actions/collect_customer_details", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 5746","authorisation_type":"example authorisation_type 1563"},"collect_customer_details":{"default_country_code":"example default_country_code 4376","incomplete_fields":{"customer":["example customer 9002"],"customer_billing_detail":["example customer_billing_detail 9718"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 7202"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 8266","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 9828","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 2888","constraints":{"end_date":"example end_date 2433","max_amount_per_payment":4147,"payment_method":"example payment_method 4078","periodic_limits":[{"alignment":"creation_date","max_payments":1353,"max_total_amount":6159,"period":"flexible"}],"start_date":"example start_date 3721"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 8705"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"payment":"example payment 156"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"personal","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 1577"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 5094"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 9355"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 102","authorisation_type":"example authorisation_type 102"},"collect_customer_details":{"default_country_code":"example default_country_code 102","incomplete_fields":{"customer":["example customer 103"],"customer_billing_detail":["example customer_billing_detail 103"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 102"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 102","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 104","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 102","constraints":{"end_date":"example end_date 102","max_amount_per_payment":102,"payment_method":"example payment_method 102","periodic_limits":[{"alignment":"calendar","max_payments":102,"max_total_amount":102,"period":"month"}],"start_date":"example start_date 102"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 102"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"when_available"},"metadata":{},"payment_context_code":"face_to_face_point_of_sale","payment_purpose_code":"example payment_purpose_code 102","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 102"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"loan","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 104"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 102"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 102"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "collect_bank_account": { "method": "POST", "path_template": "/billing_requests/:identity/actions/collect_bank_account", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 7463","authorisation_type":"example authorisation_type 7996"},"collect_customer_details":{"default_country_code":"example default_country_code 6420","incomplete_fields":{"customer":["example customer 8623"],"customer_billing_detail":["example customer_billing_detail 953"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 8878"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 9241","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 3133","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 8590","constraints":{"end_date":"example end_date 9757","max_amount_per_payment":552,"payment_method":"example payment_method 9843","periodic_limits":[{"alignment":"creation_date","max_payments":7425,"max_total_amount":1598,"period":"day"}],"start_date":"example start_date 1515"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 3632"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 9107"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"pension","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 2546"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 9336"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 8643"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 103","authorisation_type":"example authorisation_type 103"},"collect_customer_details":{"default_country_code":"example default_country_code 103","incomplete_fields":{"customer":["example customer 105"],"customer_billing_detail":["example customer_billing_detail 105"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 103"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 103","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 106","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 103","constraints":{"end_date":"example end_date 103","max_amount_per_payment":103,"payment_method":"example payment_method 103","periodic_limits":[{"alignment":"creation_date","max_payments":103,"max_total_amount":103,"period":"year"}],"start_date":"example start_date 103"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 103"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"always"},"metadata":{},"payment_context_code":"ecommerce_merchant_initiated_payment","payment_purpose_code":"example payment_purpose_code 103","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 103"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"dependant_support","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 106"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 103"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 103"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "confirm_payer_details": { "method": "POST", "path_template": "/billing_requests/:identity/actions/confirm_payer_details", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 3749","authorisation_type":"example authorisation_type 1528"},"collect_customer_details":{"default_country_code":"example default_country_code 2818","incomplete_fields":{"customer":["example customer 7903"],"customer_billing_detail":["example customer_billing_detail 4384"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 8582"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 6052","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 7175","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 1297","constraints":{"end_date":"example end_date 7726","max_amount_per_payment":5802,"payment_method":"example payment_method 3981","periodic_limits":[{"alignment":"calendar","max_payments":2066,"max_total_amount":2079,"period":"year"}],"start_date":"example start_date 5894"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 9271"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 4885"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"Epayment","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 4547"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 1224"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 8553"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 104","authorisation_type":"example authorisation_type 104"},"collect_customer_details":{"default_country_code":"example default_country_code 104","incomplete_fields":{"customer":["example customer 107"],"customer_billing_detail":["example customer_billing_detail 107"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 104"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 104","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 108","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 104","constraints":{"end_date":"example end_date 104","max_amount_per_payment":104,"payment_method":"example payment_method 104","periodic_limits":[{"alignment":"calendar","max_payments":104,"max_total_amount":104,"period":"flexible"}],"start_date":"example start_date 104"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 104"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"minimum"},"metadata":{},"payment_context_code":"transfer_to_self","payment_purpose_code":"example payment_purpose_code 104","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 104"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"gambling","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 108"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 104"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 104"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "fulfil": { "method": "POST", "path_template": "/billing_requests/:identity/actions/fulfil", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 1532","authorisation_type":"example authorisation_type 3616"},"collect_customer_details":{"default_country_code":"example default_country_code 5786","incomplete_fields":{"customer":["example customer 540"],"customer_billing_detail":["example customer_billing_detail 7839"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 7822"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 7743","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 1968","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 3231","constraints":{"end_date":"example end_date 7351","max_amount_per_payment":8844,"payment_method":"example payment_method 364","periodic_limits":[{"alignment":"creation_date","max_payments":90,"max_total_amount":4801,"period":"year"}],"start_date":"example start_date 3640"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 7578"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"always"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 3162"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"government","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 7342"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 1223"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 3710"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 105","authorisation_type":"example authorisation_type 105"},"collect_customer_details":{"default_country_code":"example default_country_code 105","incomplete_fields":{"customer":["example customer 109"],"customer_billing_detail":["example customer_billing_detail 109"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 105"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 105","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 110","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 105","constraints":{"end_date":"example end_date 105","max_amount_per_payment":105,"payment_method":"example payment_method 105","periodic_limits":[{"alignment":"creation_date","max_payments":105,"max_total_amount":105,"period":"day"}],"start_date":"example start_date 105"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 105"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_context_code":"transfer_to_third_party","payment_purpose_code":"example payment_purpose_code 105","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 105"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"retail","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 110"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 105"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 105"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "cancel": { "method": "POST", "path_template": "/billing_requests/:identity/actions/cancel", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 783","authorisation_type":"example authorisation_type 6720"},"collect_customer_details":{"default_country_code":"example default_country_code 870","incomplete_fields":{"customer":["example customer 8247"],"customer_billing_detail":["example customer_billing_detail 2984"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 3430"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 8010","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 565","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 6629","constraints":{"end_date":"example end_date 8666","max_amount_per_payment":6200,"payment_method":"example payment_method 4162","periodic_limits":[{"alignment":"calendar","max_payments":6829,"max_total_amount":6756,"period":"year"}],"start_date":"example start_date 5695"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 8831"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"minimum"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 5399"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"utility","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 4415"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 9371"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 9700"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 106","authorisation_type":"example authorisation_type 106"},"collect_customer_details":{"default_country_code":"example default_country_code 106","incomplete_fields":{"customer":["example customer 111"],"customer_billing_detail":["example customer_billing_detail 111"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 106"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 106","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 112","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 106","constraints":{"end_date":"example end_date 106","max_amount_per_payment":106,"payment_method":"example payment_method 106","periodic_limits":[{"alignment":"calendar","max_payments":106,"max_total_amount":106,"period":"week"}],"start_date":"example start_date 106"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 106"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"when_available"},"metadata":{},"payment_context_code":"billing_goods_and_services_in_advance","payment_purpose_code":"example payment_purpose_code 106","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 106"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"salary","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 112"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 106"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 106"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "list": { "method": "GET", "path_template": "/billing_requests", "url_params": [], - "body": {"billing_requests":[{"created_at":"2015-01-01T12:00:00.000Z","id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 9386"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 1888","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 292","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 1853","constraints":{"end_date":"example end_date 8652","max_amount_per_payment":8675,"payment_method":"example payment_method 9888","periodic_limits":[{"alignment":"creation_date","max_payments":2019,"max_total_amount":3756,"period":"year"}],"start_date":"example start_date 6157"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 9103"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 2520"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 8470"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}},{"created_at":"2015-01-01T12:00:00.000Z","id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 60"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 2954","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 1464","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 1509","constraints":{"end_date":"example end_date 600","max_amount_per_payment":7039,"payment_method":"example payment_method 4637","periodic_limits":[{"alignment":"creation_date","max_payments":1181,"max_total_amount":9551,"period":"day"}],"start_date":"example start_date 9516"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 2804"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"payment":"example payment 2420"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 3922"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}],"meta":{"cursors":{"after":"example after 1040","before":"example before 5014"},"limit":50}} + "body": {"billing_requests":[{"created_at":"2015-01-01T12:00:00.000Z","id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 107"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 107","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 113","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 107","constraints":{"end_date":"example end_date 107","max_amount_per_payment":107,"payment_method":"example payment_method 107","periodic_limits":[{"alignment":"creation_date","max_payments":107,"max_total_amount":107,"period":"month"}],"start_date":"example start_date 107"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 107"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"always"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 107"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 107"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}},{"created_at":"2015-01-01T12:00:00.000Z","id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 108"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 108","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 114","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 108","constraints":{"end_date":"example end_date 108","max_amount_per_payment":108,"payment_method":"example payment_method 108","periodic_limits":[{"alignment":"calendar","max_payments":108,"max_total_amount":108,"period":"year"}],"start_date":"example start_date 108"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 108"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"minimum"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 108"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 108"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", "path_template": "/billing_requests/:identity", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 3479","authorisation_type":"example authorisation_type 6592"},"collect_customer_details":{"default_country_code":"example default_country_code 8151","incomplete_fields":{"customer":["example customer 8682"],"customer_billing_detail":["example customer_billing_detail 5265"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 8662"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 9284","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 6000","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 6336","constraints":{"end_date":"example end_date 3472","max_amount_per_payment":1544,"payment_method":"example payment_method 2395","periodic_limits":[{"alignment":"calendar","max_payments":1237,"max_total_amount":2174,"period":"year"}],"start_date":"example start_date 3338"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 2869"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"minimum"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"payment":"example payment 8622"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"other","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 574"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 2390"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 235"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 107","authorisation_type":"example authorisation_type 107"},"collect_customer_details":{"default_country_code":"example default_country_code 107","incomplete_fields":{"customer":["example customer 113"],"customer_billing_detail":["example customer_billing_detail 115"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 109"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 109","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 116","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 109","constraints":{"end_date":"example end_date 109","max_amount_per_payment":109,"payment_method":"example payment_method 109","periodic_limits":[{"alignment":"creation_date","max_payments":109,"max_total_amount":109,"period":"flexible"}],"start_date":"example start_date 109"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 109"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_context_code":"billing_goods_and_services_in_arrears","payment_purpose_code":"example payment_purpose_code 107","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 109"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"personal","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 114"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 107"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 109"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "notify": { "method": "POST", "path_template": "/billing_requests/:identity/actions/notify", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 4511","authorisation_type":"example authorisation_type 5343"},"collect_customer_details":{"default_country_code":"example default_country_code 1053","incomplete_fields":{"customer":["example customer 5166"],"customer_billing_detail":["example customer_billing_detail 9859"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 8721"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 6039","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 6531","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 4658","constraints":{"end_date":"example end_date 8284","max_amount_per_payment":2375,"payment_method":"example payment_method 1874","periodic_limits":[{"alignment":"calendar","max_payments":6537,"max_total_amount":106,"period":"month"}],"start_date":"example start_date 6114"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 9723"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"minimum"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"payment":"example payment 7587"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"gambling","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 8408"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 9867"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 4231"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 108","authorisation_type":"example authorisation_type 108"},"collect_customer_details":{"default_country_code":"example default_country_code 108","incomplete_fields":{"customer":["example customer 115"],"customer_billing_detail":["example customer_billing_detail 117"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 110"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 110","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 118","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 110","constraints":{"end_date":"example end_date 110","max_amount_per_payment":110,"payment_method":"example payment_method 110","periodic_limits":[{"alignment":"calendar","max_payments":110,"max_total_amount":110,"period":"day"}],"start_date":"example start_date 110"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 110"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"when_available"},"metadata":{},"payment_context_code":"face_to_face_point_of_sale","payment_purpose_code":"example payment_purpose_code 108","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 110"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"government","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 116"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 108"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 110"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "fallback": { "method": "POST", "path_template": "/billing_requests/:identity/actions/fallback", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 4405","authorisation_type":"example authorisation_type 9081"},"collect_customer_details":{"default_country_code":"example default_country_code 7276","incomplete_fields":{"customer":["example customer 1466"],"customer_billing_detail":["example customer_billing_detail 1509"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 4983"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 5036","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 7412","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 2120","constraints":{"end_date":"example end_date 7871","max_amount_per_payment":7653,"payment_method":"example payment_method 1128","periodic_limits":[{"alignment":"calendar","max_payments":8602,"max_total_amount":6861,"period":"flexible"}],"start_date":"example start_date 8345"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 4698"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"minimum"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"payment":"example payment 7762"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"dependant_support","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 7477"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 4926"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 556"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 109","authorisation_type":"example authorisation_type 109"},"collect_customer_details":{"default_country_code":"example default_country_code 109","incomplete_fields":{"customer":["example customer 117"],"customer_billing_detail":["example customer_billing_detail 119"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 111"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 111","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 120","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 111","constraints":{"end_date":"example end_date 111","max_amount_per_payment":111,"payment_method":"example payment_method 111","periodic_limits":[{"alignment":"creation_date","max_payments":111,"max_total_amount":111,"period":"week"}],"start_date":"example start_date 111"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 111"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"always"},"metadata":{},"payment_context_code":"ecommerce_merchant_initiated_payment","payment_purpose_code":"example payment_purpose_code 109","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 111"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"pension","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 118"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 109"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 111"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "choose_currency": { "method": "POST", "path_template": "/billing_requests/:identity/actions/choose_currency", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 3808","authorisation_type":"example authorisation_type 2631"},"collect_customer_details":{"default_country_code":"example default_country_code 2884","incomplete_fields":{"customer":["example customer 8265"],"customer_billing_detail":["example customer_billing_detail 8558"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 2677"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 4834","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 580","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 3740","constraints":{"end_date":"example end_date 5048","max_amount_per_payment":3162,"payment_method":"example payment_method 9673","periodic_limits":[{"alignment":"calendar","max_payments":5527,"max_total_amount":9158,"period":"year"}],"start_date":"example start_date 496"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 9023"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":true,"verify":"when_available"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 3654"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"salary","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 4993"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 3380"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 8477"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 110","authorisation_type":"example authorisation_type 110"},"collect_customer_details":{"default_country_code":"example default_country_code 110","incomplete_fields":{"customer":["example customer 119"],"customer_billing_detail":["example customer_billing_detail 121"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 112"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 112","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 122","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"web","consent_type":"example consent_type 112","constraints":{"end_date":"example end_date 112","max_amount_per_payment":112,"payment_method":"example payment_method 112","periodic_limits":[{"alignment":"calendar","max_payments":112,"max_total_amount":112,"period":"month"}],"start_date":"example start_date 112"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 112"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"minimum"},"metadata":{},"payment_context_code":"transfer_to_self","payment_purpose_code":"example payment_purpose_code 110","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 112"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"tax","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 120"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 110"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 112"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} }, "select_institution": { "method": "POST", "path_template": "/billing_requests/:identity/actions/select_institution", "url_params": ["BRQ123"], - "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 4024","authorisation_type":"example authorisation_type 1420"},"collect_customer_details":{"default_country_code":"example default_country_code 6494","incomplete_fields":{"customer":["example customer 4806"],"customer_billing_detail":["example customer_billing_detail 8999"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":true,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 4187"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 604","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 3421","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 7759","constraints":{"end_date":"example end_date 5740","max_amount_per_payment":8089,"payment_method":"example payment_method 5814","periodic_limits":[{"alignment":"calendar","max_payments":8853,"max_total_amount":3357,"period":"flexible"}],"start_date":"example start_date 8475"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 545"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":true,"verify":"always"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 8193"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"Commercial","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 922"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 6765"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 3483"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} + "body": {"billing_requests":{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 111","authorisation_type":"example authorisation_type 111"},"collect_customer_details":{"default_country_code":"example default_country_code 111","incomplete_fields":{"customer":["example customer 121"],"customer_billing_detail":["example customer_billing_detail 123"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 113"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 113","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 124","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 113","constraints":{"end_date":"example end_date 113","max_amount_per_payment":113,"payment_method":"example payment_method 113","periodic_limits":[{"alignment":"creation_date","max_payments":113,"max_total_amount":113,"period":"year"}],"start_date":"example start_date 113"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 113"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_context_code":"transfer_to_third_party","payment_purpose_code":"example payment_purpose_code 111","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 113"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"other","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 122"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 111"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 113"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}} } } diff --git a/tests/fixtures/blocks.json b/tests/fixtures/blocks.json index 6ef7ca3d..bca9bdec 100644 --- a/tests/fixtures/blocks.json +++ b/tests/fixtures/blocks.json @@ -1,38 +1,40 @@ { + + "create": { "method": "POST", "path_template": "/blocks", "url_params": [], - "body": {"blocks":{"active":true,"block_type":"example block_type 9485","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 864","reason_type":"example reason_type 2088","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} + "body": {"blocks":{"active":true,"block_type":"example block_type 101","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 101","reason_type":"example reason_type 101","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} }, "get": { "method": "GET", "path_template": "/blocks/:identity", "url_params": ["BLC123"], - "body": {"blocks":{"active":true,"block_type":"example block_type 4560","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 9719","reason_type":"example reason_type 6216","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} + "body": {"blocks":{"active":true,"block_type":"example block_type 102","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 102","reason_type":"example reason_type 102","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} }, "list": { "method": "GET", "path_template": "/blocks", "url_params": [], - "body": {"blocks":[{"active":true,"block_type":"example block_type 6813","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 6316","reason_type":"example reason_type 1582","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"},{"active":true,"block_type":"example block_type 3322","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 2516","reason_type":"example reason_type 6301","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 9277","before":"example before 9555"},"limit":50}} + "body": {"blocks":[{"active":true,"block_type":"example block_type 103","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 103","reason_type":"example reason_type 103","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"},{"active":true,"block_type":"example block_type 104","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 104","reason_type":"example reason_type 104","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "disable": { "method": "POST", "path_template": "/blocks/:identity/actions/disable", "url_params": ["BLC123"], - "body": {"blocks":{"active":true,"block_type":"example block_type 3963","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 758","reason_type":"example reason_type 6217","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} + "body": {"blocks":{"active":true,"block_type":"example block_type 105","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 105","reason_type":"example reason_type 105","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} }, "enable": { "method": "POST", "path_template": "/blocks/:identity/actions/enable", "url_params": ["BLC123"], - "body": {"blocks":{"active":true,"block_type":"example block_type 2232","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 3875","reason_type":"example reason_type 7179","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} + "body": {"blocks":{"active":true,"block_type":"example block_type 106","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 106","reason_type":"example reason_type 106","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}} }, "block_by_ref": { "method": "POST", "path_template": "/blocks/block_by_ref", "url_params": [], - "body": {"blocks":[{"active":true,"block_type":"example block_type 3333","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 7627","reason_type":"example reason_type 3740","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"},{"active":true,"block_type":"example block_type 1552","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 4534","reason_type":"example reason_type 3928","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 4647","before":"example before 7037"},"limit":50}} + "body": {"blocks":[{"active":true,"block_type":"example block_type 107","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 107","reason_type":"example reason_type 107","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"},{"active":true,"block_type":"example block_type 108","created_at":"2014-01-01T12:00:00.000Z","id":"BLC123","reason_description":"example reason_description 108","reason_type":"example reason_type 108","resource_reference":"example@example.com","updated_at":"2014-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 102","before":"example before 102"},"limit":50}} } } diff --git a/tests/fixtures/creditor_bank_accounts.json b/tests/fixtures/creditor_bank_accounts.json index fc5c5eae..56b8cc77 100644 --- a/tests/fixtures/creditor_bank_accounts.json +++ b/tests/fixtures/creditor_bank_accounts.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/creditor_bank_accounts", @@ -9,7 +11,7 @@ "method": "GET", "path_template": "/creditor_bank_accounts", "url_params": [], - "body": {"creditor_bank_accounts":[{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{},"verification_status":"successful"},{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{},"verification_status":"successful"}],"meta":{"cursors":{"after":"example after 6184","before":"example before 1757"},"limit":50}} + "body": {"creditor_bank_accounts":[{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{},"verification_status":"successful"},{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{},"verification_status":"successful"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", diff --git a/tests/fixtures/creditors.json b/tests/fixtures/creditors.json index b929ff0a..bbd9b052 100644 --- a/tests/fixtures/creditors.json +++ b/tests/fixtures/creditors.json @@ -1,26 +1,28 @@ { + + "create": { "method": "POST", "path_template": "/creditors", "url_params": [], - "body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 9969","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 1009","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 6346","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 712","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}} + "body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 101","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 101","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 101","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 101","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}} }, "list": { "method": "GET", "path_template": "/creditors", "url_params": [], - "body": {"creditors":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 3589","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 6314","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 9356","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 104","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"},{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 7223","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 2442","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 5339","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 7764","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}],"meta":{"cursors":{"after":"example after 5619","before":"example before 1730"},"limit":50}} + "body": {"creditors":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 102","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 102","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 102","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 102","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"},{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 103","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 103","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 103","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 103","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", "path_template": "/creditors/:identity", "url_params": ["CR123"], - "body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 9953","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 3360","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 894","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 5985","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}} + "body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 104","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 104","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 104","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 104","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}} }, "update": { "method": "PUT", "path_template": "/creditors/:identity", "url_params": ["CR123"], - "body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 7328","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 5721","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 9401","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 6213","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}} + "body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 105","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 105","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 105","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 105","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}} } } diff --git a/tests/fixtures/currency_exchange_rates.json b/tests/fixtures/currency_exchange_rates.json index 4e3008a8..e08c8e63 100644 --- a/tests/fixtures/currency_exchange_rates.json +++ b/tests/fixtures/currency_exchange_rates.json @@ -1,8 +1,10 @@ { + + "list": { "method": "GET", "path_template": "/currency_exchange_rates", "url_params": [], - "body": {"currency_exchange_rates":[{"rate":"1.1234567890","source":"GBP","target":"EUR","time":"2014-01-01T12:00:00Z"},{"rate":"1.1234567890","source":"GBP","target":"EUR","time":"2014-01-01T12:00:00Z"}],"meta":{"cursors":{"after":"example after 4283","before":"example before 6262"},"limit":50}} + "body": {"currency_exchange_rates":[{"rate":"1.1234567890","source":"GBP","target":"EUR","time":"2014-01-01T12:00:00Z"},{"rate":"1.1234567890","source":"GBP","target":"EUR","time":"2014-01-01T12:00:00Z"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} } } diff --git a/tests/fixtures/customer_bank_accounts.json b/tests/fixtures/customer_bank_accounts.json index 94e28ef0..4ea7e1e8 100644 --- a/tests/fixtures/customer_bank_accounts.json +++ b/tests/fixtures/customer_bank_accounts.json @@ -1,32 +1,34 @@ { + + "create": { "method": "POST", "path_template": "/customer_bank_accounts", "url_params": [], - "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 1315"},"metadata":{}}} + "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 101"},"metadata":{}}} }, "list": { "method": "GET", "path_template": "/customer_bank_accounts", "url_params": [], - "body": {"customer_bank_accounts":[{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 5540"},"metadata":{}},{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 4492"},"metadata":{}}],"meta":{"cursors":{"after":"example after 6591","before":"example before 342"},"limit":50}} + "body": {"customer_bank_accounts":[{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 102"},"metadata":{}},{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 103"},"metadata":{}}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", "path_template": "/customer_bank_accounts/:identity", "url_params": ["BA123"], - "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 1898"},"metadata":{}}} + "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 104"},"metadata":{}}} }, "update": { "method": "PUT", "path_template": "/customer_bank_accounts/:identity", "url_params": ["BA123"], - "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 3401"},"metadata":{}}} + "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 105"},"metadata":{}}} }, "disable": { "method": "POST", "path_template": "/customer_bank_accounts/:identity/actions/disable", "url_params": ["BA123"], - "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 5707"},"metadata":{}}} + "body": {"customer_bank_accounts":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 106"},"metadata":{}}} } } diff --git a/tests/fixtures/customer_notifications.json b/tests/fixtures/customer_notifications.json index 3a3231d6..9ac0226a 100644 --- a/tests/fixtures/customer_notifications.json +++ b/tests/fixtures/customer_notifications.json @@ -1,8 +1,10 @@ { + + "handle": { "method": "POST", "path_template": "/customer_notifications/:identity/actions/handle", "url_params": ["PCN123"], - "body": {"customer_notifications":{"action_taken":"example action_taken 7912","action_taken_at":"2025-11-20T08:25:53.476Z","action_taken_by":"example action_taken_by 9695","id":"PCN123","links":{"customer":"CU123","event":"EV123","mandate":"MD123","payment":"PM123","refund":"RF123","subscription":"SB123"},"type":"payment_created"}} + "body": {"customer_notifications":{"action_taken":"example action_taken 101","action_taken_at":"2024-01-15T10:00:00.000Z","action_taken_by":"example action_taken_by 101","id":"PCN123","links":{"customer":"CU123","event":"EV123","mandate":"MD123","payment":"PM123","refund":"RF123","subscription":"SB123"},"type":"payment_created"}} } } diff --git a/tests/fixtures/customers.json b/tests/fixtures/customers.json index 91218144..5effb30b 100644 --- a/tests/fixtures/customers.json +++ b/tests/fixtures/customers.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/customers", @@ -9,7 +11,7 @@ "method": "GET", "path_template": "/customers", "url_params": [], - "body": {"customers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"}],"meta":{"cursors":{"after":"example after 1350","before":"example before 4721"},"limit":50}} + "body": {"customers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", diff --git a/tests/fixtures/events.json b/tests/fixtures/events.json index dc4ee6fb..90c5efc4 100644 --- a/tests/fixtures/events.json +++ b/tests/fixtures/events.json @@ -1,14 +1,16 @@ { + + "list": { "method": "GET", "path_template": "/events", "url_params": [], - "body": {"events":[{"action":"cancelled","created_at":"2014-01-01T12:00:00.000Z","customer_notifications":[{"deadline":"2025-11-20T08:25:53.477Z","id":"PCN123","mandatory":false,"type":"example type 6452"}],"details":{"bank_account_id":"BA123","cause":"bank_account_disabled","currency":"GBP","description":"Customer's bank account closed","item_count":10,"not_retried_reason":"failure_filter_applied","origin":"bank","property":"fx_payout_currency","reason_code":"ADDACS-B","scheme":"bacs","will_attempt_retry":true},"id":"EV123","links":{"bank_authorisation":"BAU123","billing_request":"BRQ123","billing_request_flow":"BRF123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","instalment_schedule":"IS123","mandate":"MD123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","new_customer_bank_account":"BA123","new_mandate":"MD123","organisation":"OR123","parent_event":"EV123","payer_authorisation":"PAU123","payment":"PM123","payment_request_payment":"PM123","payout":"PO123","previous_customer_bank_account":"BA123","refund":"RF123","scheme_identifier":"SU123","subscription":"SB123"},"metadata":{},"resource_metadata":{},"resource_type":"mandates","source":{"name":"Joe Bloggs","type":"app"}},{"action":"cancelled","created_at":"2014-01-01T12:00:00.000Z","customer_notifications":[{"deadline":"2025-11-20T08:25:53.477Z","id":"PCN123","mandatory":false,"type":"example type 3755"}],"details":{"bank_account_id":"BA123","cause":"bank_account_disabled","currency":"GBP","description":"Customer's bank account closed","item_count":10,"not_retried_reason":"failure_filter_applied","origin":"bank","property":"fx_payout_currency","reason_code":"ADDACS-B","scheme":"bacs","will_attempt_retry":true},"id":"EV123","links":{"bank_authorisation":"BAU123","billing_request":"BRQ123","billing_request_flow":"BRF123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","instalment_schedule":"IS123","mandate":"MD123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","new_customer_bank_account":"BA123","new_mandate":"MD123","organisation":"OR123","parent_event":"EV123","payer_authorisation":"PAU123","payment":"PM123","payment_request_payment":"PM123","payout":"PO123","previous_customer_bank_account":"BA123","refund":"RF123","scheme_identifier":"SU123","subscription":"SB123"},"metadata":{},"resource_metadata":{},"resource_type":"mandates","source":{"name":"Joe Bloggs","type":"app"}}],"linked":{"billing_requests":[{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 4135","authorisation_type":"example authorisation_type 2748"},"collect_customer_details":{"default_country_code":"example default_country_code 9350","incomplete_fields":{"customer":["example customer 5652"],"customer_billing_detail":["example customer_billing_detail 3040"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_details"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":true,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 4666"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":true,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 4490","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 8798","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"paper","consent_type":"example consent_type 9401","constraints":{"end_date":"example end_date 9681","max_amount_per_payment":6848,"payment_method":"example payment_method 2356","periodic_limits":[{"alignment":"creation_date","max_payments":573,"max_total_amount":1099,"period":"flexible"}],"start_date":"example start_date 1051"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"mandate":"example mandate 3161"},"metadata":{},"payer_requested_dual_signature":true,"scheme":"bacs","sweeping":false,"verify":"always"},"metadata":{},"payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 6118"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"Epayment","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 9841"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 1086"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 1092"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21"}}],"creditors":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 5768","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 8825","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 4196","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 1526","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}],"customers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"}],"instalment_schedules":[{"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"IS123","links":{"customer":"CU123","mandate":"MD123","payments":["PM123","PM456"]},"metadata":{},"name":"Invoice 4404","payment_errors":{"0":[{"field":"charge_date","message":"must be on or after mandate's next_possible_customer_charge_date"}]},"status":"active","total_amount":1000}],"mandates":[{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 7093","max_amount_per_payment":2243,"max_amount_per_period":4121,"max_payments_per_period":2713,"period":"week","start_date":"example start_date 3709"},"consent_type":"example consent_type 4870","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}],"outbound_payments":[{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}}],"payer_authorisations":[{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 3414","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 3882","message":"example message 1590","request_pointer":"example request_pointer 7417"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}],"payments":[{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"}],"payouts":[{"amount":1000,"arrival_date":"2014-01-01","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","deducted_fees":20,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PO123","links":{"creditor":"CR123","creditor_bank_account":"BA123"},"metadata":{"salesforce_id":"ABCD1234"},"payout_type":"merchant","reference":"ref-1","status":"pending","tax_currency":"EUR"}],"refunds":[{"amount":150,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"RF123","links":{"mandate":"MD123","payment":"PM123"},"metadata":{},"reference":"WINEBOX001","status":"submitted"}],"scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 8268","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 4476","region":"Greater London","scheme":"bacs","status":"pending"}],"subscriptions":[{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}]},"meta":{"cursors":{"after":"example after 7694","before":"example before 8098"},"limit":50}} + "body": {"events":[{"action":"cancelled","created_at":"2014-01-01T12:00:00.000Z","customer_notifications":[{"deadline":"2024-01-15T10:00:00.000Z","id":"PCN123","mandatory":false,"type":"example type 101"}],"details":{"bank_account_id":"BA123","cause":"bank_account_disabled","currency":"GBP","description":"Customer's bank account closed","item_count":10,"not_retried_reason":"failure_filter_applied","origin":"bank","property":"fx_payout_currency","reason_code":"ADDACS-B","scheme":"bacs","will_attempt_retry":true},"id":"EV123","links":{"bank_authorisation":"BAU123","billing_request":"BRQ123","billing_request_flow":"BRF123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","instalment_schedule":"IS123","mandate":"MD123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","new_customer_bank_account":"BA123","new_mandate":"MD123","organisation":"OR123","outbound_payment":"OUT123","parent_event":"EV123","payer_authorisation":"PAU123","payment":"PM123","payment_request_payment":"PM123","payout":"PO123","previous_customer_bank_account":"BA123","refund":"RF123","scheme_identifier":"SU123","subscription":"SB123"},"metadata":{},"resource_metadata":{},"resource_type":"mandates","source":{"name":"Joe Bloggs","type":"gc_team"}},{"action":"cancelled","created_at":"2014-01-01T12:00:00.000Z","customer_notifications":[{"deadline":"2024-01-15T10:00:00.000Z","id":"PCN123","mandatory":true,"type":"example type 103"}],"details":{"bank_account_id":"BA123","cause":"bank_account_disabled","currency":"GBP","description":"Customer's bank account closed","item_count":10,"not_retried_reason":"failure_filter_applied","origin":"bank","property":"fx_payout_currency","reason_code":"ADDACS-B","scheme":"bacs","will_attempt_retry":true},"id":"EV123","links":{"bank_authorisation":"BAU123","billing_request":"BRQ123","billing_request_flow":"BRF123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","instalment_schedule":"IS123","mandate":"MD123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","new_customer_bank_account":"BA123","new_mandate":"MD123","organisation":"OR123","outbound_payment":"OUT123","parent_event":"EV123","payer_authorisation":"PAU123","payment":"PM123","payment_request_payment":"PM123","payout":"PO123","previous_customer_bank_account":"BA123","refund":"RF123","scheme_identifier":"SU123","subscription":"SB123"},"metadata":{},"resource_metadata":{},"resource_type":"mandates","source":{"name":"Joe Bloggs","type":"app"}}],"linked":{"billing_requests":[{"actions":[{"available_currencies":["GBP"],"bank_authorisation":{"adapter":"example adapter 101","authorisation_type":"example authorisation_type 101"},"collect_customer_details":{"default_country_code":"example default_country_code 101","incomplete_fields":{"customer":["example customer 101"],"customer_billing_detail":["example customer_billing_detail 101"]}},"completes_actions":["collect_bank_account"],"institution_guess_status":"pending","required":true,"requires_actions":["collect_bank_account"],"status":"pending","type":"collect_bank_account"}],"created_at":"2015-01-01T12:00:00.000Z","fallback_enabled":false,"fallback_occurred":false,"id":"BRQ123","instalment_schedule_request":{"app_fee":100,"currency":"USD","instalments_with_dates":[{"amount":250,"charge_date":"2020-11-03"}],"instalments_with_schedule":{"amounts":[1000],"interval":1,"interval_unit":"monthly","start_date":"2014-10-21"},"links":{"instalment_schedule":"example instalment_schedule 101"},"metadata":{},"name":"Invoice 4404","payment_reference":"GOLDPLAN","retry_if_possible":false,"total_amount":1000},"links":{"bank_authorisation":"example bank_authorisation 101","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","customer_billing_detail":"example customer_billing_detail 102","instalment_schedule_request":"ISR123","instalment_schedule_request_instalment_schedule":"IS123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","organisation":"OR123","payment_provider":"PP123","payment_request":"PRQ123","payment_request_payment":"PM123","subscription_request":"SBR123","subscription_request_subscription":"SB123"},"mandate_request":{"authorisation_source":"telephone","consent_type":"example consent_type 101","constraints":{"end_date":"example end_date 101","max_amount_per_payment":101,"payment_method":"example payment_method 101","periodic_limits":[{"alignment":"creation_date","max_payments":101,"max_total_amount":101,"period":"week"}],"start_date":"example start_date 101"},"currency":"GBP","description":"Top-up Payment","funds_settlement":"direct","links":{"mandate":"example mandate 101"},"metadata":{},"payer_requested_dual_signature":false,"scheme":"bacs","sweeping":false,"verify":"recommended"},"metadata":{},"payment_context_code":"billing_goods_and_services_in_arrears","payment_purpose_code":"example payment_purpose_code 101","payment_request":{"amount":1000,"app_fee":100,"currency":"GBP","description":"Top-up Payment","funds_settlement":"managed","links":{"payment":"example payment 101"},"metadata":{},"reference":"some-custom-ref","scheme":"faster_payments"},"purpose_code":"utility","resources":{"customer":{"company_name":"Hamilton Trading Ltd.","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999"},"customer_bank_account":{"account_holder_name":"Billie Jean","account_number_ending":"1234","account_type":"savings","bank_account_token":"bat_f975ab3c-ecee-47a1-9590-5bb1d56fa113","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","enabled":true,"id":"BA123","links":{"customer":"example customer 102"},"metadata":{}},"customer_billing_detail":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","id":"CU123","ip_address":"127.0.0.1","postal_code":"NW1 6XE","region":"Greater London","schemes":["example schemes 101"],"swedish_identity_number":"556564-5404"}},"status":"pending","subscription_request":{"amount":1000,"app_fee":100,"count":5,"currency":"USD","day_of_month":28,"interval":1,"interval_unit":"monthly","links":{"subscription":"example subscription 101"},"metadata":{},"month":"january","name":"12 month subscription","payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21"}}],"creditors":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 101","bank_reference_prefix":"ACME","can_create_refunds":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","creditor_type":"company","custom_payment_pages_enabled":true,"fx_payout_currency":"EUR","id":"CR123","links":{"default_aud_payout_account":"BA234","default_cad_payout_account":"BA792","default_dkk_payout_account":"BA790","default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123","default_nzd_payout_account":"BA791","default_sek_payout_account":"BA789","default_usd_payout_account":"BA792"},"logo_url":"https://uploads.gocardless.com/logo.png","mandate_imports_enabled":true,"merchant_responsible_for_notifications":true,"name":"Acme","postal_code":"EC1V 7LQ","region":"example region 101","scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 101","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 101","region":"Greater London","scheme":"bacs","status":"pending"}],"verification_status":"action_required"}],"customers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","language":"en","metadata":{},"phone_number":"+64 4 817 9999","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"}],"instalment_schedules":[{"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"IS123","links":{"customer":"CU123","mandate":"MD123","payments":["PM123","PM456"]},"metadata":{},"name":"Invoice 4404","payment_errors":{"0":[{"field":"charge_date","message":"must be on or after mandate's next_possible_customer_charge_date"}]},"status":"active","total_amount":1000}],"mandates":[{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 102","max_amount_per_payment":102,"max_amount_per_period":101,"max_payments_per_period":101,"period":"month","start_date":"example start_date 102"},"consent_type":"example consent_type 102","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}],"outbound_payments":[{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}}],"payer_authorisations":[{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 101","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 101","message":"example message 101","request_pointer":"example request_pointer 101"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}],"payments":[{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}],"payouts":[{"amount":1000,"arrival_date":"2014-01-01","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","deducted_fees":20,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PO123","links":{"creditor":"CR123","creditor_bank_account":"BA123"},"metadata":{"salesforce_id":"ABCD1234"},"payout_type":"merchant","reference":"ref-1","status":"pending","tax_currency":"EUR"}],"refunds":[{"amount":150,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"RF123","links":{"mandate":"MD123","payment":"PM123"},"metadata":{},"reference":"WINEBOX001","status":"submitted"}],"scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 102","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 102","region":"Greater London","scheme":"bacs","status":"pending"}],"subscriptions":[{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}]},"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", "path_template": "/events/:identity", "url_params": ["EV123"], - "body": {"events":{"action":"cancelled","created_at":"2014-01-01T12:00:00.000Z","customer_notifications":[{"deadline":"2025-11-20T08:25:53.477Z","id":"PCN123","mandatory":false,"type":"example type 3794"}],"details":{"bank_account_id":"BA123","cause":"bank_account_disabled","currency":"GBP","description":"Customer's bank account closed","item_count":10,"not_retried_reason":"failure_filter_applied","origin":"bank","property":"fx_payout_currency","reason_code":"ADDACS-B","scheme":"bacs","will_attempt_retry":true},"id":"EV123","links":{"bank_authorisation":"BAU123","billing_request":"BRQ123","billing_request_flow":"BRF123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","instalment_schedule":"IS123","mandate":"MD123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","new_customer_bank_account":"BA123","new_mandate":"MD123","organisation":"OR123","parent_event":"EV123","payer_authorisation":"PAU123","payment":"PM123","payment_request_payment":"PM123","payout":"PO123","previous_customer_bank_account":"BA123","refund":"RF123","scheme_identifier":"SU123","subscription":"SB123"},"metadata":{},"resource_metadata":{},"resource_type":"mandates","source":{"name":"Joe Bloggs","type":"access_token"}}} + "body": {"events":{"action":"cancelled","created_at":"2014-01-01T12:00:00.000Z","customer_notifications":[{"deadline":"2024-01-15T10:00:00.000Z","id":"PCN123","mandatory":false,"type":"example type 105"}],"details":{"bank_account_id":"BA123","cause":"bank_account_disabled","currency":"GBP","description":"Customer's bank account closed","item_count":10,"not_retried_reason":"failure_filter_applied","origin":"bank","property":"fx_payout_currency","reason_code":"ADDACS-B","scheme":"bacs","will_attempt_retry":true},"id":"EV123","links":{"bank_authorisation":"BAU123","billing_request":"BRQ123","billing_request_flow":"BRF123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","instalment_schedule":"IS123","mandate":"MD123","mandate_request":"MRQ123","mandate_request_mandate":"MD123","new_customer_bank_account":"BA123","new_mandate":"MD123","organisation":"OR123","outbound_payment":"OUT123","parent_event":"EV123","payer_authorisation":"PAU123","payment":"PM123","payment_request_payment":"PM123","payout":"PO123","previous_customer_bank_account":"BA123","refund":"RF123","scheme_identifier":"SU123","subscription":"SB123"},"metadata":{},"resource_metadata":{},"resource_type":"mandates","source":{"name":"Joe Bloggs","type":"gc_team"}}} } } diff --git a/tests/fixtures/exports.json b/tests/fixtures/exports.json index 6ab9d6a5..b45737ca 100644 --- a/tests/fixtures/exports.json +++ b/tests/fixtures/exports.json @@ -1,14 +1,16 @@ { + + "get": { "method": "GET", "path_template": "/exports/:identity", "url_params": ["EX123"], - "body": {"exports":{"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","download_url":"example download_url 5666","export_type":"payments_index","id":"EX123"}} + "body": {"exports":{"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","download_url":"example download_url 101","export_type":"payments_index","id":"EX123"}} }, "list": { "method": "GET", "path_template": "/exports", "url_params": [], - "body": {"exports":[{"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","export_type":"payments_index","id":"EX123"},{"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","export_type":"payments_index","id":"EX123"}],"meta":{"cursors":{"after":"example after 722","before":"example before 8601"},"limit":50}} + "body": {"exports":[{"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","export_type":"payments_index","id":"EX123"},{"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","export_type":"payments_index","id":"EX123"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} } } diff --git a/tests/fixtures/funds_availabilities.json b/tests/fixtures/funds_availabilities.json new file mode 100644 index 00000000..3fbeb717 --- /dev/null +++ b/tests/fixtures/funds_availabilities.json @@ -0,0 +1,10 @@ +{ + + + "check": { + "method": "GET", + "path_template": "/funds_availability/:identity", + "url_params": ["MD123"], + "body": {"available":false} + } +} diff --git a/tests/fixtures/instalment_schedules.json b/tests/fixtures/instalment_schedules.json index 58ceca2c..72159a5d 100644 --- a/tests/fixtures/instalment_schedules.json +++ b/tests/fixtures/instalment_schedules.json @@ -1,4 +1,6 @@ { + + "create_with_dates": { "method": "POST", "path_template": "/instalment_schedules", @@ -15,7 +17,7 @@ "method": "GET", "path_template": "/instalment_schedules", "url_params": [], - "body": {"instalment_schedules":[{"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"IS123","links":{"customer":"CU123","mandate":"MD123","payments":["PM123","PM456"]},"metadata":{},"name":"Invoice 4404","payment_errors":{"0":[{"field":"charge_date","message":"must be on or after mandate's next_possible_customer_charge_date"}]},"status":"active","total_amount":1000},{"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"IS123","links":{"customer":"CU123","mandate":"MD123","payments":["PM123","PM456"]},"metadata":{},"name":"Invoice 4404","payment_errors":{"0":[{"field":"charge_date","message":"must be on or after mandate's next_possible_customer_charge_date"}]},"status":"active","total_amount":1000}],"meta":{"cursors":{"after":"example after 3834","before":"example before 1060"},"limit":50}} + "body": {"instalment_schedules":[{"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"IS123","links":{"customer":"CU123","mandate":"MD123","payments":["PM123","PM456"]},"metadata":{},"name":"Invoice 4404","payment_errors":{"0":[{"field":"charge_date","message":"must be on or after mandate's next_possible_customer_charge_date"}]},"status":"active","total_amount":1000},{"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"IS123","links":{"customer":"CU123","mandate":"MD123","payments":["PM123","PM456"]},"metadata":{},"name":"Invoice 4404","payment_errors":{"0":[{"field":"charge_date","message":"must be on or after mandate's next_possible_customer_charge_date"}]},"status":"active","total_amount":1000}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", diff --git a/tests/fixtures/institutions.json b/tests/fixtures/institutions.json index 84bc41fe..1a46b30f 100644 --- a/tests/fixtures/institutions.json +++ b/tests/fixtures/institutions.json @@ -1,14 +1,16 @@ { + + "list": { "method": "GET", "path_template": "/institutions", "url_params": [], - "body": {"institutions":[{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"},{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"}],"meta":{"cursors":{"after":"example after 162","before":"example before 6013"},"limit":50}} + "body": {"institutions":[{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"},{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "list_for_billing_request": { "method": "GET", "path_template": "/billing_requests/:identity/institutions", "url_params": ["BRQ123"], - "body": {"institutions":[{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"},{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"}],"meta":{"cursors":{"after":"example after 3817","before":"example before 6898"},"limit":50}} + "body": {"institutions":[{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"},{"autocompletes_collect_bank_account":true,"country_code":"GB","icon_url":"https://gocardless/assets/icons/monzo","id":"monzo","limits":{"daily":{},"single":{}},"logo_url":"https://gocardless/assets/logos/monzo","name":"VAT","status":"enabled"}],"meta":{"cursors":{"after":"example after 102","before":"example before 102"},"limit":50}} } } diff --git a/tests/fixtures/logos.json b/tests/fixtures/logos.json index a1deeb16..61a06ec2 100644 --- a/tests/fixtures/logos.json +++ b/tests/fixtures/logos.json @@ -1,4 +1,6 @@ { + + "create_for_creditor": { "method": "POST", "path_template": "/branding/logos", diff --git a/tests/fixtures/mandate_import_entries.json b/tests/fixtures/mandate_import_entries.json index 8f59e0d1..79e09f60 100644 --- a/tests/fixtures/mandate_import_entries.json +++ b/tests/fixtures/mandate_import_entries.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/mandate_import_entries", @@ -9,6 +11,6 @@ "method": "GET", "path_template": "/mandate_import_entries", "url_params": [], - "body": {"mandate_import_entries":[{"created_at":"2014-01-01T12:00:00.000Z","links":{"customer":"CU123","customer_bank_account":"BA123","mandate":"MD123","mandate_import":"IM0000AAAAAAA"},"processing_errors":{},"record_identifier":"bank-file.xml/line-1"},{"created_at":"2014-01-01T12:00:00.000Z","links":{"customer":"CU123","customer_bank_account":"BA123","mandate":"MD123","mandate_import":"IM0000AAAAAAA"},"processing_errors":{},"record_identifier":"bank-file.xml/line-1"}],"meta":{"cursors":{"after":"example after 7563","before":"example before 779"},"limit":50}} + "body": {"mandate_import_entries":[{"created_at":"2014-01-01T12:00:00.000Z","links":{"customer":"CU123","customer_bank_account":"BA123","mandate":"MD123","mandate_import":"IM0000AAAAAAA"},"processing_errors":{},"record_identifier":"bank-file.xml/line-1"},{"created_at":"2014-01-01T12:00:00.000Z","links":{"customer":"CU123","customer_bank_account":"BA123","mandate":"MD123","mandate_import":"IM0000AAAAAAA"},"processing_errors":{},"record_identifier":"bank-file.xml/line-1"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} } } diff --git a/tests/fixtures/mandate_imports.json b/tests/fixtures/mandate_imports.json index 596840af..32a4cd05 100644 --- a/tests/fixtures/mandate_imports.json +++ b/tests/fixtures/mandate_imports.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/mandate_imports", diff --git a/tests/fixtures/mandate_pdfs.json b/tests/fixtures/mandate_pdfs.json index dadb3033..71203235 100644 --- a/tests/fixtures/mandate_pdfs.json +++ b/tests/fixtures/mandate_pdfs.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/mandate_pdfs", diff --git a/tests/fixtures/mandates.json b/tests/fixtures/mandates.json index d39a6498..5518eb65 100644 --- a/tests/fixtures/mandates.json +++ b/tests/fixtures/mandates.json @@ -1,38 +1,40 @@ { + + "create": { "method": "POST", "path_template": "/mandates", "url_params": [], - "body": {"mandates":{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 6053","max_amount_per_payment":6218,"max_amount_per_period":3006,"max_payments_per_period":2188,"period":"week","start_date":"example start_date 6840"},"consent_type":"example consent_type 3571","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} + "body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 101","max_amount_per_payment":101,"max_amount_per_period":101,"max_payments_per_period":101,"period":"week","start_date":"example start_date 101"},"consent_type":"example consent_type 101","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} }, "list": { "method": "GET", "path_template": "/mandates", "url_params": [], - "body": {"mandates":[{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 2945","max_amount_per_payment":9407,"max_amount_per_period":7150,"max_payments_per_period":4907,"period":"flexible","start_date":"example start_date 7222"},"consent_type":"example consent_type 7630","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"},{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 562","max_amount_per_payment":4752,"max_amount_per_period":8114,"max_payments_per_period":3207,"period":"day","start_date":"example start_date 6904"},"consent_type":"example consent_type 5453","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 242","before":"example before 817"},"limit":50}} + "body": {"mandates":[{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 102","max_amount_per_payment":102,"max_amount_per_period":102,"max_payments_per_period":102,"period":"month","start_date":"example start_date 102"},"consent_type":"example consent_type 102","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"},{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 103","max_amount_per_payment":103,"max_amount_per_period":103,"max_payments_per_period":103,"period":"year","start_date":"example start_date 103"},"consent_type":"example consent_type 103","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50}} }, "get": { "method": "GET", "path_template": "/mandates/:identity", "url_params": ["MD123"], - "body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 6138","max_amount_per_payment":8399,"max_amount_per_period":3045,"max_payments_per_period":9227,"period":"day","start_date":"example start_date 5299"},"consent_type":"example consent_type 4195","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} + "body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 104","max_amount_per_payment":104,"max_amount_per_period":104,"max_payments_per_period":104,"period":"flexible","start_date":"example start_date 104"},"consent_type":"example consent_type 104","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} }, "update": { "method": "PUT", "path_template": "/mandates/:identity", "url_params": ["MD123"], - "body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 593","max_amount_per_payment":1775,"max_amount_per_period":5340,"max_payments_per_period":860,"period":"year","start_date":"example start_date 3539"},"consent_type":"example consent_type 2551","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} + "body": {"mandates":{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 105","max_amount_per_payment":105,"max_amount_per_period":105,"max_payments_per_period":105,"period":"day","start_date":"example start_date 105"},"consent_type":"example consent_type 105","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} }, "cancel": { "method": "POST", "path_template": "/mandates/:identity/actions/cancel", "url_params": ["MD123"], - "body": {"mandates":{"authorisation_source":"paper","consent_parameters":{"end_date":"example end_date 7185","max_amount_per_payment":5511,"max_amount_per_period":1106,"max_payments_per_period":3179,"period":"year","start_date":"example start_date 4615"},"consent_type":"example consent_type 1281","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} + "body": {"mandates":{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 106","max_amount_per_payment":106,"max_amount_per_period":106,"max_payments_per_period":106,"period":"week","start_date":"example start_date 106"},"consent_type":"example consent_type 106","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"managed","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} }, "reinstate": { "method": "POST", "path_template": "/mandates/:identity/actions/reinstate", "url_params": ["MD123"], - "body": {"mandates":{"authorisation_source":"web","consent_parameters":{"end_date":"example end_date 7483","max_amount_per_payment":6128,"max_amount_per_period":3360,"max_payments_per_period":5836,"period":"week","start_date":"example start_date 3906"},"consent_type":"example consent_type 8612","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} + "body": {"mandates":{"authorisation_source":"telephone","consent_parameters":{"end_date":"example end_date 107","max_amount_per_payment":107,"max_amount_per_period":107,"max_payments_per_period":107,"period":"month","start_date":"example start_date 107"},"consent_type":"example consent_type 107","created_at":"2014-01-01T12:00:00.000Z","funds_settlement":"direct","id":"MD123","links":{"creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","new_mandate":"MD123"},"metadata":{},"next_possible_charge_date":"2014-10-27","next_possible_standard_ach_charge_date":"2014-10-27","payments_require_approval":false,"reference":"REF-123","scheme":"bacs","status":"pending_submission","verified_at":"2021-01-01T12:00:00.000Z"}} } } diff --git a/tests/fixtures/negative_balance_limits.json b/tests/fixtures/negative_balance_limits.json index 4830fb6e..50d6e48d 100644 --- a/tests/fixtures/negative_balance_limits.json +++ b/tests/fixtures/negative_balance_limits.json @@ -1,8 +1,10 @@ { + + "list": { "method": "GET", "path_template": "/negative_balance_limits", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 3787","before":"example before 8143"},"limit":50},"negative_balance_limits":[{"balance_limit":10000,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"NBL123","links":{"creator_user":"US123","creditor":"CR123"}},{"balance_limit":10000,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"NBL123","links":{"creator_user":"US123","creditor":"CR123"}}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"negative_balance_limits":[{"balance_limit":10000,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"NBL123","links":{"creator_user":"US123","creditor":"CR123"}},{"balance_limit":10000,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","id":"NBL123","links":{"creator_user":"US123","creditor":"CR123"}}]} } } diff --git a/tests/fixtures/outbound_payments.json b/tests/fixtures/outbound_payments.json index b6d133a2..03e16457 100644 --- a/tests/fixtures/outbound_payments.json +++ b/tests/fixtures/outbound_payments.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/outbound_payments", @@ -33,12 +35,18 @@ "method": "GET", "path_template": "/outbound_payments", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 6532","before":"example before 1523"},"limit":50},"outbound_payments":[{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}},{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"outbound_payments":[{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}},{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}}]} }, "update": { "method": "PUT", "path_template": "/outbound_payments/:identity", "url_params": ["OUT123"], "body": {"outbound_payments":{"amount":1000,"created_at":"2024-01-01T12:00:00.000Z","currency":"GBP","description":"Reward Payment (August 2024)","execution_date":"2024-08-31","id":"OUT123","is_withdrawal":true,"links":{"creditor":"CR123","customer":"CU123","recipient_bank_account":"BA123"},"metadata":{},"reference":"GC-QC2FI7GBEW7VCXL","scheme":"faster_payments","status":"cancelled","verifications":{"recipient_bank_account_holder_verification":{"actual_account_name":"Jo Doe","result":"partial_match","type":"confirmation_of_payee"}}}} + }, + "stats": { + "method": "GET", + "path_template": "/outbound_payments/stats", + "url_params": [], + "body": {"outbound_payments":{"executing_amount":101,"executing_count":101,"pending_approval_amount":101,"pending_approval_count":101,"scheduled_amount":101,"scheduled_count":101}} } } diff --git a/tests/fixtures/payer_authorisations.json b/tests/fixtures/payer_authorisations.json index 2591673d..43e4ac76 100644 --- a/tests/fixtures/payer_authorisations.json +++ b/tests/fixtures/payer_authorisations.json @@ -1,32 +1,34 @@ { + + "get": { "method": "GET", "path_template": "/payer_authorisations/:identity", "url_params": ["PA123"], - "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 277","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 9723","message":"example message 2825","request_pointer":"example request_pointer 1190"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} + "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 101","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 101","message":"example message 101","request_pointer":"example request_pointer 101"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} }, "create": { "method": "POST", "path_template": "/payer_authorisations", "url_params": [], - "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 4801","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 6501","message":"example message 3847","request_pointer":"example request_pointer 7808"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} + "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 102","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 102","message":"example message 102","request_pointer":"example request_pointer 102"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} }, "update": { "method": "PUT", "path_template": "/payer_authorisations/:identity", "url_params": ["PA123"], - "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 1096","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 7407","message":"example message 4659","request_pointer":"example request_pointer 2414"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} + "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 103","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 103","message":"example message 103","request_pointer":"example request_pointer 103"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} }, "submit": { "method": "POST", "path_template": "/payer_authorisations/:identity/actions/submit", "url_params": ["PA123"], - "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 6152","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 1364","message":"example message 6588","request_pointer":"example request_pointer 3237"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} + "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 104","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 104","message":"example message 104","request_pointer":"example request_pointer 104"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} }, "confirm": { "method": "POST", "path_template": "/payer_authorisations/:identity/actions/confirm", "url_params": ["PA123"], - "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 2395","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 1192","message":"example message 5138","request_pointer":"example request_pointer 1800"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} + "body": {"payer_authorisations":{"bank_account":{"account_holder_name":"Billie Jean","account_number":"55779911","account_number_ending":"1234","account_number_suffix":"00","account_type":"savings","bank_code":"example bank_code 105","branch_code":"20-00-00","country_code":"GB","currency":"EUR","iban":"GB60BARC20000055779911","metadata":{}},"created_at":"2020-01-01T12:00:00.000Z","customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"user@example.com","family_name":"Osborne","given_name":"Frank","locale":"en-GB","metadata":{},"postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"id":"PA123","incomplete_fields":[{"field":"example field 105","message":"example message 105","request_pointer":"example request_pointer 105"}],"links":{"bank_account":"BA123","customer":"CU123","mandate":"MD123"},"mandate":{"metadata":{},"payer_ip_address":"127.0.0.1","reference":"REF-123","scheme":"bacs"},"status":"created"}} } } diff --git a/tests/fixtures/payer_themes.json b/tests/fixtures/payer_themes.json index b7cbea34..9917cf44 100644 --- a/tests/fixtures/payer_themes.json +++ b/tests/fixtures/payer_themes.json @@ -1,4 +1,6 @@ { + + "create_for_creditor": { "method": "POST", "path_template": "/branding/payer_themes", diff --git a/tests/fixtures/payment_account_transactions.json b/tests/fixtures/payment_account_transactions.json index b0f7a8ea..a6775f00 100644 --- a/tests/fixtures/payment_account_transactions.json +++ b/tests/fixtures/payment_account_transactions.json @@ -1,8 +1,10 @@ { + + "list": { "method": "GET", "path_template": "/payment_accounts/:identity/transactions", "url_params": ["BA123"], - "body": {"meta":{"cursors":{"after":"example after 3527","before":"example before 7636"},"limit":50},"payment_account_transactions":[{"amount":1000,"balance_after_transaction":1000,"counterparty_name":"Acme Ltd","currency":"example currency 2641","description":"Reward Payment (August 2024)","direction":"credit","id":"PATR1234","links":{"outbound_payment":"OUT123","payment_bank_account":"BA123","payout":"PO123"},"reference":"GC-058408d9","value_date":"2014-01-01"},{"amount":1000,"balance_after_transaction":1000,"counterparty_name":"Acme Ltd","currency":"example currency 8314","description":"Reward Payment (August 2024)","direction":"credit","id":"PATR1234","links":{"outbound_payment":"OUT123","payment_bank_account":"BA123","payout":"PO123"},"reference":"GC-058408d9","value_date":"2014-01-01"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"payment_account_transactions":[{"amount":1000,"balance_after_transaction":1000,"counterparty_name":"Acme Ltd","currency":"example currency 101","description":"Reward Payment (August 2024)","direction":"credit","id":"PATR1234","links":{"outbound_payment":"OUT123","payment_bank_account":"BA123","payout":"PO123"},"reference":"GC-058408d9","value_date":"2014-01-01"},{"amount":1000,"balance_after_transaction":1000,"counterparty_name":"Acme Ltd","currency":"example currency 102","description":"Reward Payment (August 2024)","direction":"credit","id":"PATR1234","links":{"outbound_payment":"OUT123","payment_bank_account":"BA123","payout":"PO123"},"reference":"GC-058408d9","value_date":"2014-01-01"}]} } } diff --git a/tests/fixtures/payment_accounts.json b/tests/fixtures/payment_accounts.json new file mode 100644 index 00000000..040f1a8a --- /dev/null +++ b/tests/fixtures/payment_accounts.json @@ -0,0 +1,16 @@ +{ + + + "get": { + "method": "GET", + "path_template": "/payment_accounts/:identity", + "url_params": ["BA123"], + "body": {"payment_accounts":{"account_balance":1000,"account_holder_name":"Billie Jean","account_number_ending":"1234","bank_name":"BARCLAYS BANK PLC","currency":"EUR","id":"BA123","links":{"creditor":"CR123"}}} + }, + "list": { + "method": "GET", + "path_template": "/payment_accounts", + "url_params": [], + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"payment_accounts":[{"account_balance":1000,"account_holder_name":"Billie Jean","account_number_ending":"1234","bank_name":"BARCLAYS BANK PLC","currency":"EUR","id":"BA123","links":{"creditor":"CR123"}},{"account_balance":1000,"account_holder_name":"Billie Jean","account_number_ending":"1234","bank_name":"BARCLAYS BANK PLC","currency":"EUR","id":"BA123","links":{"creditor":"CR123"}}]} + } +} diff --git a/tests/fixtures/payments.json b/tests/fixtures/payments.json index 3ebd1b38..bf8c6bca 100644 --- a/tests/fixtures/payments.json +++ b/tests/fixtures/payments.json @@ -1,15 +1,17 @@ { + + "create": { "method": "POST", "path_template": "/payments", "url_params": [], - "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}} + "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}} }, "list": { "method": "GET", "path_template": "/payments", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 7352","before":"example before 8454"},"limit":50},"payments":[{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"},{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"payments":[{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"},{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}]} }, "get": { "method": "GET", @@ -21,18 +23,18 @@ "method": "PUT", "path_template": "/payments/:identity", "url_params": ["PM123"], - "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"}} + "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}} }, "cancel": { "method": "POST", "path_template": "/payments/:identity/actions/cancel", "url_params": ["PM123"], - "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"}} + "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"}} }, "retry": { "method": "POST", "path_template": "/payments/:identity/actions/retry", "url_params": ["PM123"], - "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":true,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":true,"scheme":"bacs","status":"submitted"}} + "body": {"payments":{"amount":1000,"amount_refunded":150,"charge_date":"2014-05-21","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","description":"One-off upgrade fee","faster_ach":false,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PM123","links":{"creditor":"CR123","instalment_schedule":"IS123","mandate":"MD123","payout":"PO123","subscription":"SU123"},"metadata":{},"reference":"WINEBOX001","retry_if_possible":false,"scheme":"bacs","status":"submitted"}} } } diff --git a/tests/fixtures/payout_items.json b/tests/fixtures/payout_items.json index d698dd3d..1f462dc1 100644 --- a/tests/fixtures/payout_items.json +++ b/tests/fixtures/payout_items.json @@ -1,8 +1,10 @@ { + + "list": { "method": "GET", "path_template": "/payout_items", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 3237","before":"example before 7044"},"limit":50},"payout_items":[{"amount":"45.0","links":{"mandate":"MD123","payment":"PM123","refund":"RF123"},"taxes":[{"amount":"1.1","currency":"EUR","destination_amount":"1.1","destination_currency":"EUR","exchange_rate":"1.11205","tax_rate_id":"GB_VAT_1"}],"type":"payment_paid_out"},{"amount":"45.0","links":{"mandate":"MD123","payment":"PM123","refund":"RF123"},"taxes":[{"amount":"1.1","currency":"EUR","destination_amount":"1.1","destination_currency":"EUR","exchange_rate":"1.11205","tax_rate_id":"GB_VAT_1"}],"type":"payment_paid_out"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"payout_items":[{"amount":"45.0","links":{"mandate":"MD123","payment":"PM123","refund":"RF123"},"taxes":[{"amount":"1.1","currency":"EUR","destination_amount":"1.1","destination_currency":"EUR","exchange_rate":"1.11205","tax_rate_id":"GB_VAT_1"}],"type":"payment_paid_out"},{"amount":"45.0","links":{"mandate":"MD123","payment":"PM123","refund":"RF123"},"taxes":[{"amount":"1.1","currency":"EUR","destination_amount":"1.1","destination_currency":"EUR","exchange_rate":"1.11205","tax_rate_id":"GB_VAT_1"}],"type":"payment_paid_out"}]} } } diff --git a/tests/fixtures/payouts.json b/tests/fixtures/payouts.json index a5804772..66677e02 100644 --- a/tests/fixtures/payouts.json +++ b/tests/fixtures/payouts.json @@ -1,9 +1,11 @@ { + + "list": { "method": "GET", "path_template": "/payouts", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 8784","before":"example before 9338"},"limit":50},"payouts":[{"amount":1000,"arrival_date":"2014-01-01","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","deducted_fees":20,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PO123","links":{"creditor":"CR123","creditor_bank_account":"BA123"},"metadata":{"salesforce_id":"ABCD1234"},"payout_type":"merchant","reference":"ref-1","status":"pending","tax_currency":"EUR"},{"amount":1000,"arrival_date":"2014-01-01","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","deducted_fees":20,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PO123","links":{"creditor":"CR123","creditor_bank_account":"BA123"},"metadata":{"salesforce_id":"ABCD1234"},"payout_type":"merchant","reference":"ref-1","status":"pending","tax_currency":"EUR"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"payouts":[{"amount":1000,"arrival_date":"2014-01-01","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","deducted_fees":20,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PO123","links":{"creditor":"CR123","creditor_bank_account":"BA123"},"metadata":{"salesforce_id":"ABCD1234"},"payout_type":"merchant","reference":"ref-1","status":"pending","tax_currency":"EUR"},{"amount":1000,"arrival_date":"2014-01-01","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","deducted_fees":20,"fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"PO123","links":{"creditor":"CR123","creditor_bank_account":"BA123"},"metadata":{"salesforce_id":"ABCD1234"},"payout_type":"merchant","reference":"ref-1","status":"pending","tax_currency":"EUR"}]} }, "get": { "method": "GET", diff --git a/tests/fixtures/redirect_flows.json b/tests/fixtures/redirect_flows.json index 7e32e8de..0f9150fe 100644 --- a/tests/fixtures/redirect_flows.json +++ b/tests/fixtures/redirect_flows.json @@ -1,20 +1,22 @@ { + + "create": { "method": "POST", "path_template": "/redirect_flows", "url_params": [], - "body": {"redirect_flows":{"confirmation_url":"https://pay.gocardless.com/flow/RE123/success","created_at":"2014-01-01T12:00:00.000Z","description":"Standard subscription","id":"RE123456","links":{"billing_request":"BR123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","mandate":"MD123"},"mandate_reference":"example mandate_reference 998","metadata":{"salesforce_id":"ABCD1234"},"redirect_url":"http://pay.gocardless.com/flow/RE123","scheme":"bacs","session_token":"SESS_wSs0uGYMISxzqOBq","success_redirect_url":"https://example.com/pay/confirm"}} + "body": {"redirect_flows":{"confirmation_url":"https://pay.gocardless.com/flow/RE123/success","created_at":"2014-01-01T12:00:00.000Z","description":"Standard subscription","id":"RE123456","links":{"billing_request":"BR123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","mandate":"MD123"},"mandate_reference":"example mandate_reference 101","metadata":{"salesforce_id":"ABCD1234"},"redirect_url":"http://pay.gocardless.com/flow/RE123","scheme":"bacs","session_token":"SESS_wSs0uGYMISxzqOBq","success_redirect_url":"https://example.com/pay/confirm"}} }, "get": { "method": "GET", "path_template": "/redirect_flows/:identity", "url_params": ["RE123456"], - "body": {"redirect_flows":{"confirmation_url":"https://pay.gocardless.com/flow/RE123/success","created_at":"2014-01-01T12:00:00.000Z","description":"Standard subscription","id":"RE123456","links":{"billing_request":"BR123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","mandate":"MD123"},"mandate_reference":"example mandate_reference 2523","metadata":{"salesforce_id":"ABCD1234"},"redirect_url":"http://pay.gocardless.com/flow/RE123","scheme":"bacs","session_token":"SESS_wSs0uGYMISxzqOBq","success_redirect_url":"https://example.com/pay/confirm"}} + "body": {"redirect_flows":{"confirmation_url":"https://pay.gocardless.com/flow/RE123/success","created_at":"2014-01-01T12:00:00.000Z","description":"Standard subscription","id":"RE123456","links":{"billing_request":"BR123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","mandate":"MD123"},"mandate_reference":"example mandate_reference 102","metadata":{"salesforce_id":"ABCD1234"},"redirect_url":"http://pay.gocardless.com/flow/RE123","scheme":"bacs","session_token":"SESS_wSs0uGYMISxzqOBq","success_redirect_url":"https://example.com/pay/confirm"}} }, "complete": { "method": "POST", "path_template": "/redirect_flows/:identity/actions/complete", "url_params": ["RE123456"], - "body": {"redirect_flows":{"confirmation_url":"https://pay.gocardless.com/flow/RE123/success","created_at":"2014-01-01T12:00:00.000Z","description":"Standard subscription","id":"RE123456","links":{"billing_request":"BR123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","mandate":"MD123"},"mandate_reference":"example mandate_reference 5394","metadata":{"salesforce_id":"ABCD1234"},"redirect_url":"http://pay.gocardless.com/flow/RE123","scheme":"bacs","session_token":"SESS_wSs0uGYMISxzqOBq","success_redirect_url":"https://example.com/pay/confirm"}} + "body": {"redirect_flows":{"confirmation_url":"https://pay.gocardless.com/flow/RE123/success","created_at":"2014-01-01T12:00:00.000Z","description":"Standard subscription","id":"RE123456","links":{"billing_request":"BR123","creditor":"CR123","customer":"CU123","customer_bank_account":"BA123","mandate":"MD123"},"mandate_reference":"example mandate_reference 103","metadata":{"salesforce_id":"ABCD1234"},"redirect_url":"http://pay.gocardless.com/flow/RE123","scheme":"bacs","session_token":"SESS_wSs0uGYMISxzqOBq","success_redirect_url":"https://example.com/pay/confirm"}} } } diff --git a/tests/fixtures/refunds.json b/tests/fixtures/refunds.json index 2184b89d..10a50a19 100644 --- a/tests/fixtures/refunds.json +++ b/tests/fixtures/refunds.json @@ -1,4 +1,6 @@ { + + "create": { "method": "POST", "path_template": "/refunds", @@ -9,7 +11,7 @@ "method": "GET", "path_template": "/refunds", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 6362","before":"example before 9995"},"limit":50},"refunds":[{"amount":150,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"RF123","links":{"mandate":"MD123","payment":"PM123"},"metadata":{},"reference":"WINEBOX001","status":"submitted"},{"amount":150,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"RF123","links":{"mandate":"MD123","payment":"PM123"},"metadata":{},"reference":"WINEBOX001","status":"submitted"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"refunds":[{"amount":150,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"RF123","links":{"mandate":"MD123","payment":"PM123"},"metadata":{},"reference":"WINEBOX001","status":"submitted"},{"amount":150,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","fx":{"estimated_exchange_rate":"1.1234567890","exchange_rate":"1.1234567890","fx_amount":1150,"fx_currency":"EUR"},"id":"RF123","links":{"mandate":"MD123","payment":"PM123"},"metadata":{},"reference":"WINEBOX001","status":"submitted"}]} }, "get": { "method": "GET", diff --git a/tests/fixtures/scenario_simulators.json b/tests/fixtures/scenario_simulators.json index 1be652af..39b6eabd 100644 --- a/tests/fixtures/scenario_simulators.json +++ b/tests/fixtures/scenario_simulators.json @@ -1,4 +1,6 @@ { + + "run": { "method": "POST", "path_template": "/scenario_simulators/:identity/actions/run", diff --git a/tests/fixtures/scheme_identifiers.json b/tests/fixtures/scheme_identifiers.json index 7fd5b4b2..1baae3f7 100644 --- a/tests/fixtures/scheme_identifiers.json +++ b/tests/fixtures/scheme_identifiers.json @@ -1,20 +1,22 @@ { + + "create": { "method": "POST", "path_template": "/scheme_identifiers", "url_params": [], - "body": {"scheme_identifiers":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 7635","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 2079","region":"Greater London","scheme":"bacs","status":"pending"}} + "body": {"scheme_identifiers":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 101","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 101","region":"Greater London","scheme":"bacs","status":"pending"}} }, "list": { "method": "GET", "path_template": "/scheme_identifiers", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 1878","before":"example before 856"},"limit":50},"scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 7107","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 1428","region":"Greater London","scheme":"bacs","status":"pending"},{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 3495","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 6082","region":"Greater London","scheme":"bacs","status":"pending"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"scheme_identifiers":[{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 102","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 102","region":"Greater London","scheme":"bacs","status":"pending"},{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 103","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 103","region":"Greater London","scheme":"bacs","status":"pending"}]} }, "get": { "method": "GET", "path_template": "/scheme_identifiers/:identity", "url_params": ["SU123"], - "body": {"scheme_identifiers":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 72","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 989","region":"Greater London","scheme":"bacs","status":"pending"}} + "body": {"scheme_identifiers":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","can_specify_mandate_reference":false,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","email":"user@example.com","id":"SU123","minimum_advance_notice":3,"name":"example name 104","phone_number":"+44 20 1234 1234","postal_code":"NW1 6XE","reference":"example reference 104","region":"Greater London","scheme":"bacs","status":"pending"}} } } diff --git a/tests/fixtures/subscriptions.json b/tests/fixtures/subscriptions.json index 3f70daaa..ddc3a506 100644 --- a/tests/fixtures/subscriptions.json +++ b/tests/fixtures/subscriptions.json @@ -1,44 +1,46 @@ { + + "create": { "method": "POST", "path_template": "/subscriptions", "url_params": [], - "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} + "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} }, "list": { "method": "GET", "path_template": "/subscriptions", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 8804","before":"example before 503"},"limit":50},"subscriptions":[{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]},{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"subscriptions":[{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]},{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}]} }, "get": { "method": "GET", "path_template": "/subscriptions/:identity", "url_params": ["SB123"], - "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} + "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} }, "update": { "method": "PUT", "path_template": "/subscriptions/:identity", "url_params": ["SB123"], - "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} + "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} }, "pause": { "method": "POST", "path_template": "/subscriptions/:identity/actions/pause", "url_params": ["SB123"], - "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} + "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} }, "resume": { "method": "POST", "path_template": "/subscriptions/:identity/actions/resume", "url_params": ["SB123"], - "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} + "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":false,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} }, "cancel": { "method": "POST", "path_template": "/subscriptions/:identity/actions/cancel", "url_params": ["SB123"], - "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":false,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} + "body": {"subscriptions":{"amount":1000,"app_fee":100,"count":5,"created_at":"2014-01-01T12:00:00.000Z","currency":"EUR","day_of_month":28,"earliest_charge_date_after_resume":"2014-11-03","end_date":"2015-10-21","id":"SB123","interval":1,"interval_unit":"monthly","links":{"mandate":"MD123"},"metadata":{},"month":"january","name":"12 month subscription","parent_plan_paused":true,"payment_reference":"GOLDPLAN","retry_if_possible":true,"start_date":"2014-10-21","status":"active","upcoming_payments":[{"amount":2500,"charge_date":"2014-11-03"}]}} } } diff --git a/tests/fixtures/tax_rates.json b/tests/fixtures/tax_rates.json index be959451..98325ea9 100644 --- a/tests/fixtures/tax_rates.json +++ b/tests/fixtures/tax_rates.json @@ -1,9 +1,11 @@ { + + "list": { "method": "GET", "path_template": "/tax_rates", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 3380","before":"example before 7251"},"limit":50},"tax_rates":[{"end_date":"2014-01-01","id":"GB_VAT_1","jurisdiction":"GBP","percentage":"20.0","start_date":"2014-01-01","type":"VAT"},{"end_date":"2014-01-01","id":"GB_VAT_1","jurisdiction":"GBP","percentage":"20.0","start_date":"2014-01-01","type":"VAT"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"tax_rates":[{"end_date":"2014-01-01","id":"GB_VAT_1","jurisdiction":"GBP","percentage":"20.0","start_date":"2014-01-01","type":"VAT"},{"end_date":"2014-01-01","id":"GB_VAT_1","jurisdiction":"GBP","percentage":"20.0","start_date":"2014-01-01","type":"VAT"}]} }, "get": { "method": "GET", diff --git a/tests/fixtures/transferred_mandates.json b/tests/fixtures/transferred_mandates.json index 80b2a53b..699abcc1 100644 --- a/tests/fixtures/transferred_mandates.json +++ b/tests/fixtures/transferred_mandates.json @@ -1,8 +1,10 @@ { + + "transferred_mandates": { "method": "GET", "path_template": "/transferred_mandates/:identity", "url_params": ["MD123"], - "body": {"transferred_mandates":{"encrypted_customer_bank_details":"example encrypted_customer_bank_details 9962","encrypted_decryption_key":"example encrypted_decryption_key 4832","links":{"customer_bank_account":"BA123","mandate":"MD123"},"public_key_id":"example public_key_id 3332"}} + "body": {"transferred_mandates":{"encrypted_customer_bank_details":"example encrypted_customer_bank_details 101","encrypted_decryption_key":"example encrypted_decryption_key 101","links":{"customer_bank_account":"BA123","mandate":"MD123"},"public_key_id":"example public_key_id 101"}} } } diff --git a/tests/fixtures/verification_details.json b/tests/fixtures/verification_details.json index f52aa2f6..a0cea249 100644 --- a/tests/fixtures/verification_details.json +++ b/tests/fixtures/verification_details.json @@ -1,14 +1,16 @@ { + + "create": { "method": "POST", "path_template": "/verification_details", "url_params": [], - "body": {"verification_details":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 6458","city":"London","company_number":"07495895","description":"Wine and cheese seller","directors":[{"city":"London","country_code":"GB","date_of_birth":"1986-02-19","family_name":"Jones","given_name":"Tom","postal_code":"EC1V 7LQ","street":"example street 8464"}],"links":{"creditor":"CR123"},"name":"Acme Limited","postal_code":"EC1V 7LQ"}} + "body": {"verification_details":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 101","city":"London","company_number":"07495895","description":"Wine and cheese seller","directors":[{"city":"London","country_code":"GB","date_of_birth":"1986-02-19","family_name":"Jones","given_name":"Tom","postal_code":"EC1V 7LQ","street":"example street 101"}],"links":{"creditor":"CR123"},"name":"Acme Limited","postal_code":"EC1V 7LQ"}} }, "list": { "method": "GET", "path_template": "/verification_details", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 3416","before":"example before 7356"},"limit":50},"verification_details":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 9438","city":"London","company_number":"07495895","description":"Wine and cheese seller","directors":[{"city":"London","country_code":"GB","date_of_birth":"1986-02-19","family_name":"Jones","given_name":"Tom","postal_code":"EC1V 7LQ","street":"example street 9249"}],"links":{"creditor":"CR123"},"name":"Acme Limited","postal_code":"EC1V 7LQ"},{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 8788","city":"London","company_number":"07495895","description":"Wine and cheese seller","directors":[{"city":"London","country_code":"GB","date_of_birth":"1986-02-19","family_name":"Jones","given_name":"Tom","postal_code":"EC1V 7LQ","street":"example street 5809"}],"links":{"creditor":"CR123"},"name":"Acme Limited","postal_code":"EC1V 7LQ"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"verification_details":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 102","city":"London","company_number":"07495895","description":"Wine and cheese seller","directors":[{"city":"London","country_code":"GB","date_of_birth":"1986-02-19","family_name":"Jones","given_name":"Tom","postal_code":"EC1V 7LQ","street":"example street 102"}],"links":{"creditor":"CR123"},"name":"Acme Limited","postal_code":"EC1V 7LQ"},{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 103","city":"London","company_number":"07495895","description":"Wine and cheese seller","directors":[{"city":"London","country_code":"GB","date_of_birth":"1986-02-19","family_name":"Jones","given_name":"Tom","postal_code":"EC1V 7LQ","street":"example street 103"}],"links":{"creditor":"CR123"},"name":"Acme Limited","postal_code":"EC1V 7LQ"}]} } } diff --git a/tests/fixtures/webhooks.json b/tests/fixtures/webhooks.json index 316680a7..a973b8a7 100644 --- a/tests/fixtures/webhooks.json +++ b/tests/fixtures/webhooks.json @@ -1,20 +1,22 @@ { + + "list": { "method": "GET", "path_template": "/webhooks", "url_params": [], - "body": {"meta":{"cursors":{"after":"example after 4191","before":"example before 1561"},"limit":50},"webhooks":[{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":true,"request_body":"example request_body 9244","request_headers":{},"response_body":"example response_body 7346","response_body_truncated":false,"response_code":4633,"response_headers":{},"response_headers_content_truncated":false,"response_headers_count_truncated":false,"successful":false,"url":"https://example.com/webhooks"},{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":true,"request_body":"example request_body 344","request_headers":{},"response_body":"example response_body 1806","response_body_truncated":true,"response_code":7800,"response_headers":{},"response_headers_content_truncated":false,"response_headers_count_truncated":true,"successful":true,"url":"https://example.com/webhooks"}]} + "body": {"meta":{"cursors":{"after":"example after 101","before":"example before 101"},"limit":50},"webhooks":[{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":false,"request_body":"example request_body 101","request_headers":{},"response_body":"example response_body 101","response_body_truncated":false,"response_code":101,"response_headers":{},"response_headers_content_truncated":false,"response_headers_count_truncated":false,"successful":false,"url":"https://example.com/webhooks"},{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":true,"request_body":"example request_body 102","request_headers":{},"response_body":"example response_body 102","response_body_truncated":true,"response_code":102,"response_headers":{},"response_headers_content_truncated":true,"response_headers_count_truncated":true,"successful":true,"url":"https://example.com/webhooks"}]} }, "get": { "method": "GET", "path_template": "/webhooks/:identity", "url_params": ["WB123"], - "body": {"webhooks":{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":true,"request_body":"example request_body 6312","request_headers":{},"response_body":"example response_body 6444","response_body_truncated":false,"response_code":4278,"response_headers":{},"response_headers_content_truncated":false,"response_headers_count_truncated":true,"successful":false,"url":"https://example.com/webhooks"}} + "body": {"webhooks":{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":false,"request_body":"example request_body 103","request_headers":{},"response_body":"example response_body 103","response_body_truncated":false,"response_code":103,"response_headers":{},"response_headers_content_truncated":false,"response_headers_count_truncated":false,"successful":false,"url":"https://example.com/webhooks"}} }, "retry": { "method": "POST", "path_template": "/webhooks/:identity/actions/retry", "url_params": ["WB123"], - "body": {"webhooks":{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":true,"request_body":"example request_body 7801","request_headers":{},"response_body":"example response_body 2971","response_body_truncated":true,"response_code":8158,"response_headers":{},"response_headers_content_truncated":true,"response_headers_count_truncated":false,"successful":false,"url":"https://example.com/webhooks"}} + "body": {"webhooks":{"created_at":"2014-01-01T12:00:00.000Z","id":"WB123","is_test":true,"request_body":"example request_body 104","request_headers":{},"response_body":"example response_body 104","response_body_truncated":true,"response_code":104,"response_headers":{},"response_headers_content_truncated":true,"response_headers_count_truncated":true,"successful":true,"url":"https://example.com/webhooks"}} } } diff --git a/tests/integration/balances_integration_test.py b/tests/integration/balances_integration_test.py index 79d99606..322b3b81 100644 --- a/tests/integration/balances_integration_test.py +++ b/tests/integration/balances_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_balances_list(): fixture = helpers.load_fixture('balances')['list'] helpers.stub_response(fixture) response = helpers.client.balances.list(*fixture['url_params']) - body = fixture['body']['balances'] + if fixture['body'].get('balances') is not None and isinstance(fixture['body'].get('balances'), (dict, list)): + body = fixture['body']['balances'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Balance) @@ -41,7 +43,6 @@ def test_timeout_balances_list_retries(): response = helpers.client.balances.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['balances'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Balance) @@ -55,7 +56,6 @@ def test_502_balances_list_retries(): response = helpers.client.balances.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['balances'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Balance) @@ -81,5 +81,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['balances']) * 2 for record in all_records: assert isinstance(record, resources.Balance) - - diff --git a/tests/integration/bank_account_details_integration_test.py b/tests/integration/bank_account_details_integration_test.py index 0f0a0d28..cc4c6935 100644 --- a/tests/integration/bank_account_details_integration_test.py +++ b/tests/integration/bank_account_details_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_bank_account_details_get(): fixture = helpers.load_fixture('bank_account_details')['get'] helpers.stub_response(fixture) response = helpers.client.bank_account_details.get(*fixture['url_params']) - body = fixture['body']['bank_account_details'] + if fixture['body'].get('bank_account_details') is not None and isinstance(fixture['body'].get('bank_account_details'), (dict, list)): + body = fixture['body']['bank_account_details'] + else: + body = fixture['body'] assert isinstance(response, resources.BankAccountDetail) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -38,7 +40,6 @@ def test_timeout_bank_account_details_get_retries(): response = helpers.client.bank_account_details.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_account_details'] assert isinstance(response, resources.BankAccountDetail) @@ -48,7 +49,5 @@ def test_502_bank_account_details_get_retries(): response = helpers.client.bank_account_details.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_account_details'] assert isinstance(response, resources.BankAccountDetail) - diff --git a/tests/integration/bank_account_holder_verifications_integration_test.py b/tests/integration/bank_account_holder_verifications_integration_test.py new file mode 100644 index 00000000..b1136707 --- /dev/null +++ b/tests/integration/bank_account_holder_verifications_integration_test.py @@ -0,0 +1,107 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +import json + +import pytest +import requests +import responses + +from gocardless_pro.errors import MalformedResponseError +from gocardless_pro import resources +from gocardless_pro import list_response + +from .. import helpers + +@responses.activate +def test_bank_account_holder_verifications_create(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['create'] + helpers.stub_response(fixture) + response = helpers.client.bank_account_holder_verifications.create(*fixture['url_params']) + if fixture['body'].get('bank_account_holder_verifications') is not None and isinstance(fixture['body'].get('bank_account_holder_verifications'), (dict, list)): + body = fixture['body']['bank_account_holder_verifications'] + else: + body = fixture['body'] + + assert isinstance(response, resources.BankAccountHolderVerification) + assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None + assert response.actual_account_name == body.get('actual_account_name') + assert response.id == body.get('id') + assert response.result == body.get('result') + assert response.status == body.get('status') + assert response.type == body.get('type') + +@responses.activate +def test_bank_account_holder_verifications_create_new_idempotency_key_for_each_call(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['create'] + helpers.stub_response(fixture) + helpers.client.bank_account_holder_verifications.create(*fixture['url_params']) + helpers.client.bank_account_holder_verifications.create(*fixture['url_params']) + assert responses.calls[0].request.headers.get('Idempotency-Key') != responses.calls[1].request.headers.get('Idempotency-Key') + +def test_timeout_bank_account_holder_verifications_create_idempotency_conflict(): + create_fixture = helpers.load_fixture('bank_account_holder_verifications')['create'] + get_fixture = helpers.load_fixture('bank_account_holder_verifications')['get'] + with helpers.stub_timeout_then_idempotency_conflict(create_fixture, get_fixture) as rsps: + response = helpers.client.bank_account_holder_verifications.create(*create_fixture['url_params']) + assert len(rsps.calls) == 2 + + assert isinstance(response, resources.BankAccountHolderVerification) + +@responses.activate +def test_timeout_bank_account_holder_verifications_create_retries(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['create'] + with helpers.stub_timeout_then_response(fixture) as rsps: + response = helpers.client.bank_account_holder_verifications.create(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, resources.BankAccountHolderVerification) + +def test_502_bank_account_holder_verifications_create_retries(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['create'] + with helpers.stub_502_then_response(fixture) as rsps: + response = helpers.client.bank_account_holder_verifications.create(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, resources.BankAccountHolderVerification) + +@responses.activate +def test_bank_account_holder_verifications_get(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['get'] + helpers.stub_response(fixture) + response = helpers.client.bank_account_holder_verifications.get(*fixture['url_params']) + if fixture['body'].get('bank_account_holder_verifications') is not None and isinstance(fixture['body'].get('bank_account_holder_verifications'), (dict, list)): + body = fixture['body']['bank_account_holder_verifications'] + else: + body = fixture['body'] + + assert isinstance(response, resources.BankAccountHolderVerification) + assert responses.calls[-1].request.headers.get('Idempotency-Key') is None + assert response.actual_account_name == body.get('actual_account_name') + assert response.id == body.get('id') + assert response.result == body.get('result') + assert response.status == body.get('status') + assert response.type == body.get('type') + +@responses.activate +def test_timeout_bank_account_holder_verifications_get_retries(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['get'] + with helpers.stub_timeout_then_response(fixture) as rsps: + response = helpers.client.bank_account_holder_verifications.get(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, resources.BankAccountHolderVerification) + +def test_502_bank_account_holder_verifications_get_retries(): + fixture = helpers.load_fixture('bank_account_holder_verifications')['get'] + with helpers.stub_502_then_response(fixture) as rsps: + response = helpers.client.bank_account_holder_verifications.get(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, resources.BankAccountHolderVerification) diff --git a/tests/integration/bank_authorisations_integration_test.py b/tests/integration/bank_authorisations_integration_test.py index 3788e442..a473265b 100644 --- a/tests/integration/bank_authorisations_integration_test.py +++ b/tests/integration/bank_authorisations_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_bank_authorisations_create(): fixture = helpers.load_fixture('bank_authorisations')['create'] helpers.stub_response(fixture) response = helpers.client.bank_authorisations.create(*fixture['url_params']) - body = fixture['body']['bank_authorisations'] + if fixture['body'].get('bank_authorisations') is not None and isinstance(fixture['body'].get('bank_authorisations'), (dict, list)): + body = fixture['body']['bank_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.BankAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -61,7 +63,6 @@ def test_timeout_bank_authorisations_create_retries(): response = helpers.client.bank_authorisations.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_authorisations'] assert isinstance(response, resources.BankAuthorisation) @@ -71,17 +72,18 @@ def test_502_bank_authorisations_create_retries(): response = helpers.client.bank_authorisations.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_authorisations'] assert isinstance(response, resources.BankAuthorisation) - @responses.activate def test_bank_authorisations_get(): fixture = helpers.load_fixture('bank_authorisations')['get'] helpers.stub_response(fixture) response = helpers.client.bank_authorisations.get(*fixture['url_params']) - body = fixture['body']['bank_authorisations'] + if fixture['body'].get('bank_authorisations') is not None and isinstance(fixture['body'].get('bank_authorisations'), (dict, list)): + body = fixture['body']['bank_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.BankAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -104,7 +106,6 @@ def test_timeout_bank_authorisations_get_retries(): response = helpers.client.bank_authorisations.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_authorisations'] assert isinstance(response, resources.BankAuthorisation) @@ -114,7 +115,5 @@ def test_502_bank_authorisations_get_retries(): response = helpers.client.bank_authorisations.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_authorisations'] assert isinstance(response, resources.BankAuthorisation) - diff --git a/tests/integration/bank_details_lookups_integration_test.py b/tests/integration/bank_details_lookups_integration_test.py index 90d9d271..bc75f1e8 100644 --- a/tests/integration/bank_details_lookups_integration_test.py +++ b/tests/integration/bank_details_lookups_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_bank_details_lookups_create(): fixture = helpers.load_fixture('bank_details_lookups')['create'] helpers.stub_response(fixture) response = helpers.client.bank_details_lookups.create(*fixture['url_params']) - body = fixture['body']['bank_details_lookups'] + if fixture['body'].get('bank_details_lookups') is not None and isinstance(fixture['body'].get('bank_details_lookups'), (dict, list)): + body = fixture['body']['bank_details_lookups'] + else: + body = fixture['body'] assert isinstance(response, resources.BankDetailsLookup) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -36,7 +38,6 @@ def test_timeout_bank_details_lookups_create_retries(): response = helpers.client.bank_details_lookups.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_details_lookups'] assert isinstance(response, resources.BankDetailsLookup) @@ -46,7 +47,5 @@ def test_502_bank_details_lookups_create_retries(): response = helpers.client.bank_details_lookups.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['bank_details_lookups'] assert isinstance(response, resources.BankDetailsLookup) - diff --git a/tests/integration/billing_request_flows_integration_test.py b/tests/integration/billing_request_flows_integration_test.py index e984dbb2..9b21503e 100644 --- a/tests/integration/billing_request_flows_integration_test.py +++ b/tests/integration/billing_request_flows_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_billing_request_flows_create(): fixture = helpers.load_fixture('billing_request_flows')['create'] helpers.stub_response(fixture) response = helpers.client.billing_request_flows.create(*fixture['url_params']) - body = fixture['body']['billing_request_flows'] + if fixture['body'].get('billing_request_flows') is not None and isinstance(fixture['body'].get('billing_request_flows'), (dict, list)): + body = fixture['body']['billing_request_flows'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequestFlow) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -64,7 +66,6 @@ def test_timeout_billing_request_flows_create_retries(): response = helpers.client.billing_request_flows.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_flows'] assert isinstance(response, resources.BillingRequestFlow) @@ -74,17 +75,18 @@ def test_502_billing_request_flows_create_retries(): response = helpers.client.billing_request_flows.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_flows'] assert isinstance(response, resources.BillingRequestFlow) - @responses.activate def test_billing_request_flows_initialise(): fixture = helpers.load_fixture('billing_request_flows')['initialise'] helpers.stub_response(fixture) response = helpers.client.billing_request_flows.initialise(*fixture['url_params']) - body = fixture['body']['billing_request_flows'] + if fixture['body'].get('billing_request_flows') is not None and isinstance(fixture['body'].get('billing_request_flows'), (dict, list)): + body = fixture['body']['billing_request_flows'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequestFlow) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -133,4 +135,3 @@ def test_502_billing_request_flows_initialise_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_request_flows.initialise(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/billing_request_templates_integration_test.py b/tests/integration/billing_request_templates_integration_test.py index e2aad811..a11ec0dc 100644 --- a/tests/integration/billing_request_templates_integration_test.py +++ b/tests/integration/billing_request_templates_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_billing_request_templates_list(): fixture = helpers.load_fixture('billing_request_templates')['list'] helpers.stub_response(fixture) response = helpers.client.billing_request_templates.list(*fixture['url_params']) - body = fixture['body']['billing_request_templates'] + if fixture['body'].get('billing_request_templates') is not None and isinstance(fixture['body'].get('billing_request_templates'), (dict, list)): + body = fixture['body']['billing_request_templates'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.BillingRequestTemplate) @@ -54,7 +56,6 @@ def test_timeout_billing_request_templates_list_retries(): response = helpers.client.billing_request_templates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.BillingRequestTemplate) @@ -68,7 +69,6 @@ def test_502_billing_request_templates_list_retries(): response = helpers.client.billing_request_templates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.BillingRequestTemplate) @@ -94,15 +94,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['billing_request_templates']) * 2 for record in all_records: assert isinstance(record, resources.BillingRequestTemplate) - - @responses.activate def test_billing_request_templates_get(): fixture = helpers.load_fixture('billing_request_templates')['get'] helpers.stub_response(fixture) response = helpers.client.billing_request_templates.get(*fixture['url_params']) - body = fixture['body']['billing_request_templates'] + if fixture['body'].get('billing_request_templates') is not None and isinstance(fixture['body'].get('billing_request_templates'), (dict, list)): + body = fixture['body']['billing_request_templates'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequestTemplate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -136,7 +137,6 @@ def test_timeout_billing_request_templates_get_retries(): response = helpers.client.billing_request_templates.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, resources.BillingRequestTemplate) @@ -146,17 +146,18 @@ def test_502_billing_request_templates_get_retries(): response = helpers.client.billing_request_templates.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, resources.BillingRequestTemplate) - @responses.activate def test_billing_request_templates_create(): fixture = helpers.load_fixture('billing_request_templates')['create'] helpers.stub_response(fixture) response = helpers.client.billing_request_templates.create(*fixture['url_params']) - body = fixture['body']['billing_request_templates'] + if fixture['body'].get('billing_request_templates') is not None and isinstance(fixture['body'].get('billing_request_templates'), (dict, list)): + body = fixture['body']['billing_request_templates'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequestTemplate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -207,7 +208,6 @@ def test_timeout_billing_request_templates_create_retries(): response = helpers.client.billing_request_templates.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, resources.BillingRequestTemplate) @@ -217,17 +217,18 @@ def test_502_billing_request_templates_create_retries(): response = helpers.client.billing_request_templates.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, resources.BillingRequestTemplate) - @responses.activate def test_billing_request_templates_update(): fixture = helpers.load_fixture('billing_request_templates')['update'] helpers.stub_response(fixture) response = helpers.client.billing_request_templates.update(*fixture['url_params']) - body = fixture['body']['billing_request_templates'] + if fixture['body'].get('billing_request_templates') is not None and isinstance(fixture['body'].get('billing_request_templates'), (dict, list)): + body = fixture['body']['billing_request_templates'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequestTemplate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -261,7 +262,6 @@ def test_timeout_billing_request_templates_update_retries(): response = helpers.client.billing_request_templates.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, resources.BillingRequestTemplate) @@ -271,7 +271,5 @@ def test_502_billing_request_templates_update_retries(): response = helpers.client.billing_request_templates.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_templates'] assert isinstance(response, resources.BillingRequestTemplate) - diff --git a/tests/integration/billing_request_with_actions_integration_test.py b/tests/integration/billing_request_with_actions_integration_test.py index 2ad42481..206cdff5 100644 --- a/tests/integration/billing_request_with_actions_integration_test.py +++ b/tests/integration/billing_request_with_actions_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_billing_request_with_actions_create_with_actions(): fixture = helpers.load_fixture('billing_request_with_actions')['create_with_actions'] helpers.stub_response(fixture) response = helpers.client.billing_request_with_actions.create_with_actions(*fixture['url_params']) - body = fixture['body']['billing_request_with_actions'] + if fixture['body'].get('billing_request_with_actions') is not None and isinstance(fixture['body'].get('billing_request_with_actions'), (dict, list)): + body = fixture['body']['billing_request_with_actions'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequestWithAction) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -44,6 +46,8 @@ def test_billing_request_with_actions_create_with_actions(): assert response.billing_requests.links == body.get('billing_requests')['links'] assert response.billing_requests.mandate_request == body.get('billing_requests')['mandate_request'] assert response.billing_requests.metadata == body.get('billing_requests')['metadata'] + assert response.billing_requests.payment_context_code == body.get('billing_requests')['payment_context_code'] + assert response.billing_requests.payment_purpose_code == body.get('billing_requests')['payment_purpose_code'] assert response.billing_requests.payment_request == body.get('billing_requests')['payment_request'] assert response.billing_requests.purpose_code == body.get('billing_requests')['purpose_code'] assert response.billing_requests.resources == body.get('billing_requests')['resources'] @@ -57,7 +61,6 @@ def test_timeout_billing_request_with_actions_create_with_actions_retries(): response = helpers.client.billing_request_with_actions.create_with_actions(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_with_actions'] assert isinstance(response, resources.BillingRequestWithAction) @@ -67,7 +70,5 @@ def test_502_billing_request_with_actions_create_with_actions_retries(): response = helpers.client.billing_request_with_actions.create_with_actions(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_request_with_actions'] assert isinstance(response, resources.BillingRequestWithAction) - diff --git a/tests/integration/billing_requests_integration_test.py b/tests/integration/billing_requests_integration_test.py index bd6d50ef..45d8b437 100644 --- a/tests/integration/billing_requests_integration_test.py +++ b/tests/integration/billing_requests_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_billing_requests_create(): fixture = helpers.load_fixture('billing_requests')['create'] helpers.stub_response(fixture) response = helpers.client.billing_requests.create(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -31,6 +33,8 @@ def test_billing_requests_create(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -121,7 +125,6 @@ def test_timeout_billing_requests_create_retries(): response = helpers.client.billing_requests.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_requests'] assert isinstance(response, resources.BillingRequest) @@ -131,17 +134,18 @@ def test_502_billing_requests_create_retries(): response = helpers.client.billing_requests.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_requests'] assert isinstance(response, resources.BillingRequest) - @responses.activate def test_billing_requests_collect_customer_details(): fixture = helpers.load_fixture('billing_requests')['collect_customer_details'] helpers.stub_response(fixture) response = helpers.client.billing_requests.collect_customer_details(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -151,6 +155,8 @@ def test_billing_requests_collect_customer_details(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -230,14 +236,16 @@ def test_502_billing_requests_collect_customer_details_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.collect_customer_details(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_collect_bank_account(): fixture = helpers.load_fixture('billing_requests')['collect_bank_account'] helpers.stub_response(fixture) response = helpers.client.billing_requests.collect_bank_account(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -247,6 +255,8 @@ def test_billing_requests_collect_bank_account(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -326,14 +336,16 @@ def test_502_billing_requests_collect_bank_account_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.collect_bank_account(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_confirm_payer_details(): fixture = helpers.load_fixture('billing_requests')['confirm_payer_details'] helpers.stub_response(fixture) response = helpers.client.billing_requests.confirm_payer_details(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -343,6 +355,8 @@ def test_billing_requests_confirm_payer_details(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -422,14 +436,16 @@ def test_502_billing_requests_confirm_payer_details_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.confirm_payer_details(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_fulfil(): fixture = helpers.load_fixture('billing_requests')['fulfil'] helpers.stub_response(fixture) response = helpers.client.billing_requests.fulfil(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -439,6 +455,8 @@ def test_billing_requests_fulfil(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -518,14 +536,16 @@ def test_502_billing_requests_fulfil_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.fulfil(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_cancel(): fixture = helpers.load_fixture('billing_requests')['cancel'] helpers.stub_response(fixture) response = helpers.client.billing_requests.cancel(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -535,6 +555,8 @@ def test_billing_requests_cancel(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -614,14 +636,16 @@ def test_502_billing_requests_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_list(): fixture = helpers.load_fixture('billing_requests')['list'] helpers.stub_response(fixture) response = helpers.client.billing_requests.list(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.BillingRequest) @@ -635,6 +659,8 @@ def test_billing_requests_list(): assert [r.fallback_occurred for r in response.records] == [b.get('fallback_occurred') for b in body] assert [r.id for r in response.records] == [b.get('id') for b in body] assert [r.metadata for r in response.records] == [b.get('metadata') for b in body] + assert [r.payment_context_code for r in response.records] == [b.get('payment_context_code') for b in body] + assert [r.payment_purpose_code for r in response.records] == [b.get('payment_purpose_code') for b in body] assert [r.purpose_code for r in response.records] == [b.get('purpose_code') for b in body] assert [r.status for r in response.records] == [b.get('status') for b in body] @@ -645,7 +671,6 @@ def test_timeout_billing_requests_list_retries(): response = helpers.client.billing_requests.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_requests'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.BillingRequest) @@ -659,7 +684,6 @@ def test_502_billing_requests_list_retries(): response = helpers.client.billing_requests.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_requests'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.BillingRequest) @@ -685,15 +709,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['billing_requests']) * 2 for record in all_records: assert isinstance(record, resources.BillingRequest) - - @responses.activate def test_billing_requests_get(): fixture = helpers.load_fixture('billing_requests')['get'] helpers.stub_response(fixture) response = helpers.client.billing_requests.get(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -703,6 +728,8 @@ def test_billing_requests_get(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -776,7 +803,6 @@ def test_timeout_billing_requests_get_retries(): response = helpers.client.billing_requests.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_requests'] assert isinstance(response, resources.BillingRequest) @@ -786,17 +812,18 @@ def test_502_billing_requests_get_retries(): response = helpers.client.billing_requests.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['billing_requests'] assert isinstance(response, resources.BillingRequest) - @responses.activate def test_billing_requests_notify(): fixture = helpers.load_fixture('billing_requests')['notify'] helpers.stub_response(fixture) response = helpers.client.billing_requests.notify(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -806,6 +833,8 @@ def test_billing_requests_notify(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -885,14 +914,16 @@ def test_502_billing_requests_notify_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.notify(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_fallback(): fixture = helpers.load_fixture('billing_requests')['fallback'] helpers.stub_response(fixture) response = helpers.client.billing_requests.fallback(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -902,6 +933,8 @@ def test_billing_requests_fallback(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -981,14 +1014,16 @@ def test_502_billing_requests_fallback_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.fallback(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_choose_currency(): fixture = helpers.load_fixture('billing_requests')['choose_currency'] helpers.stub_response(fixture) response = helpers.client.billing_requests.choose_currency(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -998,6 +1033,8 @@ def test_billing_requests_choose_currency(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -1077,14 +1114,16 @@ def test_502_billing_requests_choose_currency_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.choose_currency(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_billing_requests_select_institution(): fixture = helpers.load_fixture('billing_requests')['select_institution'] helpers.stub_response(fixture) response = helpers.client.billing_requests.select_institution(*fixture['url_params']) - body = fixture['body']['billing_requests'] + if fixture['body'].get('billing_requests') is not None and isinstance(fixture['body'].get('billing_requests'), (dict, list)): + body = fixture['body']['billing_requests'] + else: + body = fixture['body'] assert isinstance(response, resources.BillingRequest) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -1094,6 +1133,8 @@ def test_billing_requests_select_institution(): assert response.fallback_occurred == body.get('fallback_occurred') assert response.id == body.get('id') assert response.metadata == body.get('metadata') + assert response.payment_context_code == body.get('payment_context_code') + assert response.payment_purpose_code == body.get('payment_purpose_code') assert response.purpose_code == body.get('purpose_code') assert response.status == body.get('status') assert response.instalment_schedule_request.app_fee == body.get('instalment_schedule_request')['app_fee'] @@ -1173,4 +1214,3 @@ def test_502_billing_requests_select_institution_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.billing_requests.select_institution(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/blocks_integration_test.py b/tests/integration/blocks_integration_test.py index d062499e..5f421046 100644 --- a/tests/integration/blocks_integration_test.py +++ b/tests/integration/blocks_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_blocks_create(): fixture = helpers.load_fixture('blocks')['create'] helpers.stub_response(fixture) response = helpers.client.blocks.create(*fixture['url_params']) - body = fixture['body']['blocks'] + if fixture['body'].get('blocks') is not None and isinstance(fixture['body'].get('blocks'), (dict, list)): + body = fixture['body']['blocks'] + else: + body = fixture['body'] assert isinstance(response, resources.Block) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -58,7 +60,6 @@ def test_timeout_blocks_create_retries(): response = helpers.client.blocks.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['blocks'] assert isinstance(response, resources.Block) @@ -68,17 +69,18 @@ def test_502_blocks_create_retries(): response = helpers.client.blocks.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['blocks'] assert isinstance(response, resources.Block) - @responses.activate def test_blocks_get(): fixture = helpers.load_fixture('blocks')['get'] helpers.stub_response(fixture) response = helpers.client.blocks.get(*fixture['url_params']) - body = fixture['body']['blocks'] + if fixture['body'].get('blocks') is not None and isinstance(fixture['body'].get('blocks'), (dict, list)): + body = fixture['body']['blocks'] + else: + body = fixture['body'] assert isinstance(response, resources.Block) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -98,7 +100,6 @@ def test_timeout_blocks_get_retries(): response = helpers.client.blocks.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['blocks'] assert isinstance(response, resources.Block) @@ -108,17 +109,18 @@ def test_502_blocks_get_retries(): response = helpers.client.blocks.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['blocks'] assert isinstance(response, resources.Block) - @responses.activate def test_blocks_list(): fixture = helpers.load_fixture('blocks')['list'] helpers.stub_response(fixture) response = helpers.client.blocks.list(*fixture['url_params']) - body = fixture['body']['blocks'] + if fixture['body'].get('blocks') is not None and isinstance(fixture['body'].get('blocks'), (dict, list)): + body = fixture['body']['blocks'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Block) @@ -142,7 +144,6 @@ def test_timeout_blocks_list_retries(): response = helpers.client.blocks.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['blocks'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Block) @@ -156,7 +157,6 @@ def test_502_blocks_list_retries(): response = helpers.client.blocks.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['blocks'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Block) @@ -182,15 +182,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['blocks']) * 2 for record in all_records: assert isinstance(record, resources.Block) - - @responses.activate def test_blocks_disable(): fixture = helpers.load_fixture('blocks')['disable'] helpers.stub_response(fixture) response = helpers.client.blocks.disable(*fixture['url_params']) - body = fixture['body']['blocks'] + if fixture['body'].get('blocks') is not None and isinstance(fixture['body'].get('blocks'), (dict, list)): + body = fixture['body']['blocks'] + else: + body = fixture['body'] assert isinstance(response, resources.Block) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -216,14 +217,16 @@ def test_502_blocks_disable_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.blocks.disable(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_blocks_enable(): fixture = helpers.load_fixture('blocks')['enable'] helpers.stub_response(fixture) response = helpers.client.blocks.enable(*fixture['url_params']) - body = fixture['body']['blocks'] + if fixture['body'].get('blocks') is not None and isinstance(fixture['body'].get('blocks'), (dict, list)): + body = fixture['body']['blocks'] + else: + body = fixture['body'] assert isinstance(response, resources.Block) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -249,14 +252,16 @@ def test_502_blocks_enable_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.blocks.enable(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_blocks_block_by_ref(): fixture = helpers.load_fixture('blocks')['block_by_ref'] helpers.stub_response(fixture) response = helpers.client.blocks.block_by_ref(*fixture['url_params']) - body = fixture['body']['blocks'] + if fixture['body'].get('blocks') is not None and isinstance(fixture['body'].get('blocks'), (dict, list)): + body = fixture['body']['blocks'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Block) @@ -286,4 +291,3 @@ def test_502_blocks_block_by_ref_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.blocks.block_by_ref(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/creditor_bank_accounts_integration_test.py b/tests/integration/creditor_bank_accounts_integration_test.py index dbdc3640..33d94cee 100644 --- a/tests/integration/creditor_bank_accounts_integration_test.py +++ b/tests/integration/creditor_bank_accounts_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_creditor_bank_accounts_create(): fixture = helpers.load_fixture('creditor_bank_accounts')['create'] helpers.stub_response(fixture) response = helpers.client.creditor_bank_accounts.create(*fixture['url_params']) - body = fixture['body']['creditor_bank_accounts'] + if fixture['body'].get('creditor_bank_accounts') is not None and isinstance(fixture['body'].get('creditor_bank_accounts'), (dict, list)): + body = fixture['body']['creditor_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CreditorBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -62,7 +64,6 @@ def test_timeout_creditor_bank_accounts_create_retries(): response = helpers.client.creditor_bank_accounts.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditor_bank_accounts'] assert isinstance(response, resources.CreditorBankAccount) @@ -72,17 +73,18 @@ def test_502_creditor_bank_accounts_create_retries(): response = helpers.client.creditor_bank_accounts.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditor_bank_accounts'] assert isinstance(response, resources.CreditorBankAccount) - @responses.activate def test_creditor_bank_accounts_list(): fixture = helpers.load_fixture('creditor_bank_accounts')['list'] helpers.stub_response(fixture) response = helpers.client.creditor_bank_accounts.list(*fixture['url_params']) - body = fixture['body']['creditor_bank_accounts'] + if fixture['body'].get('creditor_bank_accounts') is not None and isinstance(fixture['body'].get('creditor_bank_accounts'), (dict, list)): + body = fixture['body']['creditor_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CreditorBankAccount) @@ -109,7 +111,6 @@ def test_timeout_creditor_bank_accounts_list_retries(): response = helpers.client.creditor_bank_accounts.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditor_bank_accounts'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CreditorBankAccount) @@ -123,7 +124,6 @@ def test_502_creditor_bank_accounts_list_retries(): response = helpers.client.creditor_bank_accounts.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditor_bank_accounts'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CreditorBankAccount) @@ -149,15 +149,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['creditor_bank_accounts']) * 2 for record in all_records: assert isinstance(record, resources.CreditorBankAccount) - - @responses.activate def test_creditor_bank_accounts_get(): fixture = helpers.load_fixture('creditor_bank_accounts')['get'] helpers.stub_response(fixture) response = helpers.client.creditor_bank_accounts.get(*fixture['url_params']) - body = fixture['body']['creditor_bank_accounts'] + if fixture['body'].get('creditor_bank_accounts') is not None and isinstance(fixture['body'].get('creditor_bank_accounts'), (dict, list)): + body = fixture['body']['creditor_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CreditorBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -181,7 +182,6 @@ def test_timeout_creditor_bank_accounts_get_retries(): response = helpers.client.creditor_bank_accounts.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditor_bank_accounts'] assert isinstance(response, resources.CreditorBankAccount) @@ -191,17 +191,18 @@ def test_502_creditor_bank_accounts_get_retries(): response = helpers.client.creditor_bank_accounts.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditor_bank_accounts'] assert isinstance(response, resources.CreditorBankAccount) - @responses.activate def test_creditor_bank_accounts_disable(): fixture = helpers.load_fixture('creditor_bank_accounts')['disable'] helpers.stub_response(fixture) response = helpers.client.creditor_bank_accounts.disable(*fixture['url_params']) - body = fixture['body']['creditor_bank_accounts'] + if fixture['body'].get('creditor_bank_accounts') is not None and isinstance(fixture['body'].get('creditor_bank_accounts'), (dict, list)): + body = fixture['body']['creditor_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CreditorBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -231,4 +232,3 @@ def test_502_creditor_bank_accounts_disable_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.creditor_bank_accounts.disable(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/creditors_integration_test.py b/tests/integration/creditors_integration_test.py index 0fd3cf56..9ae8b00d 100644 --- a/tests/integration/creditors_integration_test.py +++ b/tests/integration/creditors_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_creditors_create(): fixture = helpers.load_fixture('creditors')['create'] helpers.stub_response(fixture) response = helpers.client.creditors.create(*fixture['url_params']) - body = fixture['body']['creditors'] + if fixture['body'].get('creditors') is not None and isinstance(fixture['body'].get('creditors'), (dict, list)): + body = fixture['body']['creditors'] + else: + body = fixture['body'] assert isinstance(response, resources.Creditor) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -78,7 +80,6 @@ def test_timeout_creditors_create_retries(): response = helpers.client.creditors.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, resources.Creditor) @@ -88,17 +89,18 @@ def test_502_creditors_create_retries(): response = helpers.client.creditors.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, resources.Creditor) - @responses.activate def test_creditors_list(): fixture = helpers.load_fixture('creditors')['list'] helpers.stub_response(fixture) response = helpers.client.creditors.list(*fixture['url_params']) - body = fixture['body']['creditors'] + if fixture['body'].get('creditors') is not None and isinstance(fixture['body'].get('creditors'), (dict, list)): + body = fixture['body']['creditors'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Creditor) @@ -134,7 +136,6 @@ def test_timeout_creditors_list_retries(): response = helpers.client.creditors.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Creditor) @@ -148,7 +149,6 @@ def test_502_creditors_list_retries(): response = helpers.client.creditors.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Creditor) @@ -174,15 +174,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['creditors']) * 2 for record in all_records: assert isinstance(record, resources.Creditor) - - @responses.activate def test_creditors_get(): fixture = helpers.load_fixture('creditors')['get'] helpers.stub_response(fixture) response = helpers.client.creditors.get(*fixture['url_params']) - body = fixture['body']['creditors'] + if fixture['body'].get('creditors') is not None and isinstance(fixture['body'].get('creditors'), (dict, list)): + body = fixture['body']['creditors'] + else: + body = fixture['body'] assert isinstance(response, resources.Creditor) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -222,7 +223,6 @@ def test_timeout_creditors_get_retries(): response = helpers.client.creditors.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, resources.Creditor) @@ -232,17 +232,18 @@ def test_502_creditors_get_retries(): response = helpers.client.creditors.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, resources.Creditor) - @responses.activate def test_creditors_update(): fixture = helpers.load_fixture('creditors')['update'] helpers.stub_response(fixture) response = helpers.client.creditors.update(*fixture['url_params']) - body = fixture['body']['creditors'] + if fixture['body'].get('creditors') is not None and isinstance(fixture['body'].get('creditors'), (dict, list)): + body = fixture['body']['creditors'] + else: + body = fixture['body'] assert isinstance(response, resources.Creditor) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -282,7 +283,6 @@ def test_timeout_creditors_update_retries(): response = helpers.client.creditors.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, resources.Creditor) @@ -292,7 +292,5 @@ def test_502_creditors_update_retries(): response = helpers.client.creditors.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['creditors'] assert isinstance(response, resources.Creditor) - diff --git a/tests/integration/currency_exchange_rates_integration_test.py b/tests/integration/currency_exchange_rates_integration_test.py index 34e7633d..8d62e33d 100644 --- a/tests/integration/currency_exchange_rates_integration_test.py +++ b/tests/integration/currency_exchange_rates_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_currency_exchange_rates_list(): fixture = helpers.load_fixture('currency_exchange_rates')['list'] helpers.stub_response(fixture) response = helpers.client.currency_exchange_rates.list(*fixture['url_params']) - body = fixture['body']['currency_exchange_rates'] + if fixture['body'].get('currency_exchange_rates') is not None and isinstance(fixture['body'].get('currency_exchange_rates'), (dict, list)): + body = fixture['body']['currency_exchange_rates'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CurrencyExchangeRate) @@ -41,7 +43,6 @@ def test_timeout_currency_exchange_rates_list_retries(): response = helpers.client.currency_exchange_rates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['currency_exchange_rates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CurrencyExchangeRate) @@ -55,7 +56,6 @@ def test_502_currency_exchange_rates_list_retries(): response = helpers.client.currency_exchange_rates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['currency_exchange_rates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CurrencyExchangeRate) @@ -81,5 +81,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['currency_exchange_rates']) * 2 for record in all_records: assert isinstance(record, resources.CurrencyExchangeRate) - - diff --git a/tests/integration/customer_bank_accounts_integration_test.py b/tests/integration/customer_bank_accounts_integration_test.py index 0f3b2b41..254748b5 100644 --- a/tests/integration/customer_bank_accounts_integration_test.py +++ b/tests/integration/customer_bank_accounts_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_customer_bank_accounts_create(): fixture = helpers.load_fixture('customer_bank_accounts')['create'] helpers.stub_response(fixture) response = helpers.client.customer_bank_accounts.create(*fixture['url_params']) - body = fixture['body']['customer_bank_accounts'] + if fixture['body'].get('customer_bank_accounts') is not None and isinstance(fixture['body'].get('customer_bank_accounts'), (dict, list)): + body = fixture['body']['customer_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CustomerBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -62,7 +64,6 @@ def test_timeout_customer_bank_accounts_create_retries(): response = helpers.client.customer_bank_accounts.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, resources.CustomerBankAccount) @@ -72,17 +73,18 @@ def test_502_customer_bank_accounts_create_retries(): response = helpers.client.customer_bank_accounts.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, resources.CustomerBankAccount) - @responses.activate def test_customer_bank_accounts_list(): fixture = helpers.load_fixture('customer_bank_accounts')['list'] helpers.stub_response(fixture) response = helpers.client.customer_bank_accounts.list(*fixture['url_params']) - body = fixture['body']['customer_bank_accounts'] + if fixture['body'].get('customer_bank_accounts') is not None and isinstance(fixture['body'].get('customer_bank_accounts'), (dict, list)): + body = fixture['body']['customer_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CustomerBankAccount) @@ -109,7 +111,6 @@ def test_timeout_customer_bank_accounts_list_retries(): response = helpers.client.customer_bank_accounts.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CustomerBankAccount) @@ -123,7 +124,6 @@ def test_502_customer_bank_accounts_list_retries(): response = helpers.client.customer_bank_accounts.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.CustomerBankAccount) @@ -149,15 +149,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['customer_bank_accounts']) * 2 for record in all_records: assert isinstance(record, resources.CustomerBankAccount) - - @responses.activate def test_customer_bank_accounts_get(): fixture = helpers.load_fixture('customer_bank_accounts')['get'] helpers.stub_response(fixture) response = helpers.client.customer_bank_accounts.get(*fixture['url_params']) - body = fixture['body']['customer_bank_accounts'] + if fixture['body'].get('customer_bank_accounts') is not None and isinstance(fixture['body'].get('customer_bank_accounts'), (dict, list)): + body = fixture['body']['customer_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CustomerBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -181,7 +182,6 @@ def test_timeout_customer_bank_accounts_get_retries(): response = helpers.client.customer_bank_accounts.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, resources.CustomerBankAccount) @@ -191,17 +191,18 @@ def test_502_customer_bank_accounts_get_retries(): response = helpers.client.customer_bank_accounts.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, resources.CustomerBankAccount) - @responses.activate def test_customer_bank_accounts_update(): fixture = helpers.load_fixture('customer_bank_accounts')['update'] helpers.stub_response(fixture) response = helpers.client.customer_bank_accounts.update(*fixture['url_params']) - body = fixture['body']['customer_bank_accounts'] + if fixture['body'].get('customer_bank_accounts') is not None and isinstance(fixture['body'].get('customer_bank_accounts'), (dict, list)): + body = fixture['body']['customer_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CustomerBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -225,7 +226,6 @@ def test_timeout_customer_bank_accounts_update_retries(): response = helpers.client.customer_bank_accounts.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, resources.CustomerBankAccount) @@ -235,17 +235,18 @@ def test_502_customer_bank_accounts_update_retries(): response = helpers.client.customer_bank_accounts.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customer_bank_accounts'] assert isinstance(response, resources.CustomerBankAccount) - @responses.activate def test_customer_bank_accounts_disable(): fixture = helpers.load_fixture('customer_bank_accounts')['disable'] helpers.stub_response(fixture) response = helpers.client.customer_bank_accounts.disable(*fixture['url_params']) - body = fixture['body']['customer_bank_accounts'] + if fixture['body'].get('customer_bank_accounts') is not None and isinstance(fixture['body'].get('customer_bank_accounts'), (dict, list)): + body = fixture['body']['customer_bank_accounts'] + else: + body = fixture['body'] assert isinstance(response, resources.CustomerBankAccount) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -275,4 +276,3 @@ def test_502_customer_bank_accounts_disable_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.customer_bank_accounts.disable(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/customer_notifications_integration_test.py b/tests/integration/customer_notifications_integration_test.py index 66a3b422..ff50f729 100644 --- a/tests/integration/customer_notifications_integration_test.py +++ b/tests/integration/customer_notifications_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_customer_notifications_handle(): fixture = helpers.load_fixture('customer_notifications')['handle'] helpers.stub_response(fixture) response = helpers.client.customer_notifications.handle(*fixture['url_params']) - body = fixture['body']['customer_notifications'] + if fixture['body'].get('customer_notifications') is not None and isinstance(fixture['body'].get('customer_notifications'), (dict, list)): + body = fixture['body']['customer_notifications'] + else: + body = fixture['body'] assert isinstance(response, resources.CustomerNotification) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -50,4 +52,3 @@ def test_502_customer_notifications_handle_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.customer_notifications.handle(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/customers_integration_test.py b/tests/integration/customers_integration_test.py index e200c7c3..03b98bc6 100644 --- a/tests/integration/customers_integration_test.py +++ b/tests/integration/customers_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_customers_create(): fixture = helpers.load_fixture('customers')['create'] helpers.stub_response(fixture) response = helpers.client.customers.create(*fixture['url_params']) - body = fixture['body']['customers'] + if fixture['body'].get('customers') is not None and isinstance(fixture['body'].get('customers'), (dict, list)): + body = fixture['body']['customers'] + else: + body = fixture['body'] assert isinstance(response, resources.Customer) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -68,7 +70,6 @@ def test_timeout_customers_create_retries(): response = helpers.client.customers.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, resources.Customer) @@ -78,17 +79,18 @@ def test_502_customers_create_retries(): response = helpers.client.customers.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, resources.Customer) - @responses.activate def test_customers_list(): fixture = helpers.load_fixture('customers')['list'] helpers.stub_response(fixture) response = helpers.client.customers.list(*fixture['url_params']) - body = fixture['body']['customers'] + if fixture['body'].get('customers') is not None and isinstance(fixture['body'].get('customers'), (dict, list)): + body = fixture['body']['customers'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Customer) @@ -122,7 +124,6 @@ def test_timeout_customers_list_retries(): response = helpers.client.customers.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Customer) @@ -136,7 +137,6 @@ def test_502_customers_list_retries(): response = helpers.client.customers.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Customer) @@ -162,15 +162,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['customers']) * 2 for record in all_records: assert isinstance(record, resources.Customer) - - @responses.activate def test_customers_get(): fixture = helpers.load_fixture('customers')['get'] helpers.stub_response(fixture) response = helpers.client.customers.get(*fixture['url_params']) - body = fixture['body']['customers'] + if fixture['body'].get('customers') is not None and isinstance(fixture['body'].get('customers'), (dict, list)): + body = fixture['body']['customers'] + else: + body = fixture['body'] assert isinstance(response, resources.Customer) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -200,7 +201,6 @@ def test_timeout_customers_get_retries(): response = helpers.client.customers.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, resources.Customer) @@ -210,17 +210,18 @@ def test_502_customers_get_retries(): response = helpers.client.customers.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, resources.Customer) - @responses.activate def test_customers_update(): fixture = helpers.load_fixture('customers')['update'] helpers.stub_response(fixture) response = helpers.client.customers.update(*fixture['url_params']) - body = fixture['body']['customers'] + if fixture['body'].get('customers') is not None and isinstance(fixture['body'].get('customers'), (dict, list)): + body = fixture['body']['customers'] + else: + body = fixture['body'] assert isinstance(response, resources.Customer) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -250,7 +251,6 @@ def test_timeout_customers_update_retries(): response = helpers.client.customers.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, resources.Customer) @@ -260,17 +260,18 @@ def test_502_customers_update_retries(): response = helpers.client.customers.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['customers'] assert isinstance(response, resources.Customer) - @responses.activate def test_customers_remove(): fixture = helpers.load_fixture('customers')['remove'] helpers.stub_response(fixture) response = helpers.client.customers.remove(*fixture['url_params']) - body = fixture['body']['customers'] + if fixture['body'].get('customers') is not None and isinstance(fixture['body'].get('customers'), (dict, list)): + body = fixture['body']['customers'] + else: + body = fixture['body'] assert isinstance(response, resources.Customer) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -306,4 +307,3 @@ def test_502_customers_remove_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.customers.remove(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/events_integration_test.py b/tests/integration/events_integration_test.py index 4acd6c35..9a1e4067 100644 --- a/tests/integration/events_integration_test.py +++ b/tests/integration/events_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_events_list(): fixture = helpers.load_fixture('events')['list'] helpers.stub_response(fixture) response = helpers.client.events.list(*fixture['url_params']) - body = fixture['body']['events'] + if fixture['body'].get('events') is not None and isinstance(fixture['body'].get('events'), (dict, list)): + body = fixture['body']['events'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Event) @@ -44,7 +46,6 @@ def test_timeout_events_list_retries(): response = helpers.client.events.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['events'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Event) @@ -58,7 +59,6 @@ def test_502_events_list_retries(): response = helpers.client.events.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['events'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Event) @@ -84,15 +84,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['events']) * 2 for record in all_records: assert isinstance(record, resources.Event) - - @responses.activate def test_events_get(): fixture = helpers.load_fixture('events')['get'] helpers.stub_response(fixture) response = helpers.client.events.get(*fixture['url_params']) - body = fixture['body']['events'] + if fixture['body'].get('events') is not None and isinstance(fixture['body'].get('events'), (dict, list)): + body = fixture['body']['events'] + else: + body = fixture['body'] assert isinstance(response, resources.Event) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -127,6 +128,7 @@ def test_events_get(): assert response.links.new_customer_bank_account == body.get('links')['new_customer_bank_account'] assert response.links.new_mandate == body.get('links')['new_mandate'] assert response.links.organisation == body.get('links')['organisation'] + assert response.links.outbound_payment == body.get('links')['outbound_payment'] assert response.links.parent_event == body.get('links')['parent_event'] assert response.links.payer_authorisation == body.get('links')['payer_authorisation'] assert response.links.payment == body.get('links')['payment'] @@ -146,7 +148,6 @@ def test_timeout_events_get_retries(): response = helpers.client.events.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['events'] assert isinstance(response, resources.Event) @@ -156,7 +157,5 @@ def test_502_events_get_retries(): response = helpers.client.events.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['events'] assert isinstance(response, resources.Event) - diff --git a/tests/integration/exports_integration_test.py b/tests/integration/exports_integration_test.py index 2e6e47cf..f49d3d09 100644 --- a/tests/integration/exports_integration_test.py +++ b/tests/integration/exports_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_exports_get(): fixture = helpers.load_fixture('exports')['get'] helpers.stub_response(fixture) response = helpers.client.exports.get(*fixture['url_params']) - body = fixture['body']['exports'] + if fixture['body'].get('exports') is not None and isinstance(fixture['body'].get('exports'), (dict, list)): + body = fixture['body']['exports'] + else: + body = fixture['body'] assert isinstance(response, resources.Export) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -38,7 +40,6 @@ def test_timeout_exports_get_retries(): response = helpers.client.exports.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['exports'] assert isinstance(response, resources.Export) @@ -48,17 +49,18 @@ def test_502_exports_get_retries(): response = helpers.client.exports.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['exports'] assert isinstance(response, resources.Export) - @responses.activate def test_exports_list(): fixture = helpers.load_fixture('exports')['list'] helpers.stub_response(fixture) response = helpers.client.exports.list(*fixture['url_params']) - body = fixture['body']['exports'] + if fixture['body'].get('exports') is not None and isinstance(fixture['body'].get('exports'), (dict, list)): + body = fixture['body']['exports'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Export) @@ -79,7 +81,6 @@ def test_timeout_exports_list_retries(): response = helpers.client.exports.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['exports'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Export) @@ -93,7 +94,6 @@ def test_502_exports_list_retries(): response = helpers.client.exports.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['exports'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Export) @@ -119,5 +119,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['exports']) * 2 for record in all_records: assert isinstance(record, resources.Export) - - diff --git a/tests/integration/funds_availabilities_integration_test.py b/tests/integration/funds_availabilities_integration_test.py new file mode 100644 index 00000000..4cd09782 --- /dev/null +++ b/tests/integration/funds_availabilities_integration_test.py @@ -0,0 +1,44 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +import json + +import pytest +import requests +import responses + +from gocardless_pro.errors import MalformedResponseError +from gocardless_pro import resources +from gocardless_pro import list_response + +from .. import helpers + +@responses.activate +def test_funds_availabilities_check(): + fixture = helpers.load_fixture('funds_availabilities')['check'] + helpers.stub_response(fixture) + response = helpers.client.funds_availabilities.check(*fixture['url_params']) + if fixture['body'].get('available') is not None and isinstance(fixture['body'].get('available'), (dict, list)): + body = fixture['body']['available'] + else: + body = fixture['body'] + + assert isinstance(response, resources.FundsAvailability) + assert responses.calls[-1].request.headers.get('Idempotency-Key') is None + assert response.available == body.get('available') + +def test_timeout_funds_availabilities_check_doesnt_retry(): + fixture = helpers.load_fixture('funds_availabilities')['check'] + with helpers.stub_timeout(fixture) as rsps: + with pytest.raises(requests.ConnectTimeout): + response = helpers.client.funds_availabilities.check(*fixture['url_params']) + assert len(rsps.calls) == 1 + +def test_502_funds_availabilities_check_doesnt_retry(): + fixture = helpers.load_fixture('funds_availabilities')['check'] + with helpers.stub_502(fixture) as rsps: + with pytest.raises(MalformedResponseError): + response = helpers.client.funds_availabilities.check(*fixture['url_params']) + assert len(rsps.calls) == 1 diff --git a/tests/integration/instalment_schedules_integration_test.py b/tests/integration/instalment_schedules_integration_test.py index 6bdd1a09..d512f3e6 100644 --- a/tests/integration/instalment_schedules_integration_test.py +++ b/tests/integration/instalment_schedules_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_instalment_schedules_create_with_dates(): fixture = helpers.load_fixture('instalment_schedules')['create_with_dates'] helpers.stub_response(fixture) response = helpers.client.instalment_schedules.create_with_dates(*fixture['url_params']) - body = fixture['body']['instalment_schedules'] + if fixture['body'].get('instalment_schedules') is not None and isinstance(fixture['body'].get('instalment_schedules'), (dict, list)): + body = fixture['body']['instalment_schedules'] + else: + body = fixture['body'] assert isinstance(response, resources.InstalmentSchedule) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -61,7 +63,6 @@ def test_timeout_instalment_schedules_create_with_dates_retries(): response = helpers.client.instalment_schedules.create_with_dates(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) @@ -71,17 +72,18 @@ def test_502_instalment_schedules_create_with_dates_retries(): response = helpers.client.instalment_schedules.create_with_dates(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) - @responses.activate def test_instalment_schedules_create_with_schedule(): fixture = helpers.load_fixture('instalment_schedules')['create_with_schedule'] helpers.stub_response(fixture) response = helpers.client.instalment_schedules.create_with_schedule(*fixture['url_params']) - body = fixture['body']['instalment_schedules'] + if fixture['body'].get('instalment_schedules') is not None and isinstance(fixture['body'].get('instalment_schedules'), (dict, list)): + body = fixture['body']['instalment_schedules'] + else: + body = fixture['body'] assert isinstance(response, resources.InstalmentSchedule) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -121,7 +123,6 @@ def test_timeout_instalment_schedules_create_with_schedule_retries(): response = helpers.client.instalment_schedules.create_with_schedule(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) @@ -131,17 +132,18 @@ def test_502_instalment_schedules_create_with_schedule_retries(): response = helpers.client.instalment_schedules.create_with_schedule(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) - @responses.activate def test_instalment_schedules_list(): fixture = helpers.load_fixture('instalment_schedules')['list'] helpers.stub_response(fixture) response = helpers.client.instalment_schedules.list(*fixture['url_params']) - body = fixture['body']['instalment_schedules'] + if fixture['body'].get('instalment_schedules') is not None and isinstance(fixture['body'].get('instalment_schedules'), (dict, list)): + body = fixture['body']['instalment_schedules'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.InstalmentSchedule) @@ -165,7 +167,6 @@ def test_timeout_instalment_schedules_list_retries(): response = helpers.client.instalment_schedules.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.InstalmentSchedule) @@ -179,7 +180,6 @@ def test_502_instalment_schedules_list_retries(): response = helpers.client.instalment_schedules.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.InstalmentSchedule) @@ -205,15 +205,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['instalment_schedules']) * 2 for record in all_records: assert isinstance(record, resources.InstalmentSchedule) - - @responses.activate def test_instalment_schedules_get(): fixture = helpers.load_fixture('instalment_schedules')['get'] helpers.stub_response(fixture) response = helpers.client.instalment_schedules.get(*fixture['url_params']) - body = fixture['body']['instalment_schedules'] + if fixture['body'].get('instalment_schedules') is not None and isinstance(fixture['body'].get('instalment_schedules'), (dict, list)): + body = fixture['body']['instalment_schedules'] + else: + body = fixture['body'] assert isinstance(response, resources.InstalmentSchedule) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -236,7 +237,6 @@ def test_timeout_instalment_schedules_get_retries(): response = helpers.client.instalment_schedules.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) @@ -246,17 +246,18 @@ def test_502_instalment_schedules_get_retries(): response = helpers.client.instalment_schedules.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) - @responses.activate def test_instalment_schedules_update(): fixture = helpers.load_fixture('instalment_schedules')['update'] helpers.stub_response(fixture) response = helpers.client.instalment_schedules.update(*fixture['url_params']) - body = fixture['body']['instalment_schedules'] + if fixture['body'].get('instalment_schedules') is not None and isinstance(fixture['body'].get('instalment_schedules'), (dict, list)): + body = fixture['body']['instalment_schedules'] + else: + body = fixture['body'] assert isinstance(response, resources.InstalmentSchedule) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -279,7 +280,6 @@ def test_timeout_instalment_schedules_update_retries(): response = helpers.client.instalment_schedules.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) @@ -289,17 +289,18 @@ def test_502_instalment_schedules_update_retries(): response = helpers.client.instalment_schedules.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['instalment_schedules'] assert isinstance(response, resources.InstalmentSchedule) - @responses.activate def test_instalment_schedules_cancel(): fixture = helpers.load_fixture('instalment_schedules')['cancel'] helpers.stub_response(fixture) response = helpers.client.instalment_schedules.cancel(*fixture['url_params']) - body = fixture['body']['instalment_schedules'] + if fixture['body'].get('instalment_schedules') is not None and isinstance(fixture['body'].get('instalment_schedules'), (dict, list)): + body = fixture['body']['instalment_schedules'] + else: + body = fixture['body'] assert isinstance(response, resources.InstalmentSchedule) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -328,4 +329,3 @@ def test_502_instalment_schedules_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.instalment_schedules.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/institutions_integration_test.py b/tests/integration/institutions_integration_test.py index 83ea46cc..51f1722d 100644 --- a/tests/integration/institutions_integration_test.py +++ b/tests/integration/institutions_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_institutions_list(): fixture = helpers.load_fixture('institutions')['list'] helpers.stub_response(fixture) response = helpers.client.institutions.list(*fixture['url_params']) - body = fixture['body']['institutions'] + if fixture['body'].get('institutions') is not None and isinstance(fixture['body'].get('institutions'), (dict, list)): + body = fixture['body']['institutions'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Institution) @@ -44,7 +46,6 @@ def test_timeout_institutions_list_retries(): response = helpers.client.institutions.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['institutions'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Institution) @@ -58,7 +59,6 @@ def test_502_institutions_list_retries(): response = helpers.client.institutions.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['institutions'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Institution) @@ -84,15 +84,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['institutions']) * 2 for record in all_records: assert isinstance(record, resources.Institution) - - @responses.activate def test_institutions_list_for_billing_request(): fixture = helpers.load_fixture('institutions')['list_for_billing_request'] helpers.stub_response(fixture) response = helpers.client.institutions.list_for_billing_request(*fixture['url_params']) - body = fixture['body']['institutions'] + if fixture['body'].get('institutions') is not None and isinstance(fixture['body'].get('institutions'), (dict, list)): + body = fixture['body']['institutions'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Institution) @@ -121,4 +122,3 @@ def test_502_institutions_list_for_billing_request_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.institutions.list_for_billing_request(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/logos_integration_test.py b/tests/integration/logos_integration_test.py index 3c58d022..21ec3ce9 100644 --- a/tests/integration/logos_integration_test.py +++ b/tests/integration/logos_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_logos_create_for_creditor(): fixture = helpers.load_fixture('logos')['create_for_creditor'] helpers.stub_response(fixture) response = helpers.client.logos.create_for_creditor(*fixture['url_params']) - body = fixture['body']['logos'] + if fixture['body'].get('logos') is not None and isinstance(fixture['body'].get('logos'), (dict, list)): + body = fixture['body']['logos'] + else: + body = fixture['body'] assert isinstance(response, resources.Logo) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -34,7 +36,6 @@ def test_timeout_logos_create_for_creditor_retries(): response = helpers.client.logos.create_for_creditor(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['logos'] assert isinstance(response, resources.Logo) @@ -44,7 +45,5 @@ def test_502_logos_create_for_creditor_retries(): response = helpers.client.logos.create_for_creditor(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['logos'] assert isinstance(response, resources.Logo) - diff --git a/tests/integration/mandate_import_entries_integration_test.py b/tests/integration/mandate_import_entries_integration_test.py index 391bc28b..da19bd06 100644 --- a/tests/integration/mandate_import_entries_integration_test.py +++ b/tests/integration/mandate_import_entries_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_mandate_import_entries_create(): fixture = helpers.load_fixture('mandate_import_entries')['create'] helpers.stub_response(fixture) response = helpers.client.mandate_import_entries.create(*fixture['url_params']) - body = fixture['body']['mandate_import_entries'] + if fixture['body'].get('mandate_import_entries') is not None and isinstance(fixture['body'].get('mandate_import_entries'), (dict, list)): + body = fixture['body']['mandate_import_entries'] + else: + body = fixture['body'] assert isinstance(response, resources.MandateImportEntry) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -40,7 +42,6 @@ def test_timeout_mandate_import_entries_create_retries(): response = helpers.client.mandate_import_entries.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_import_entries'] assert isinstance(response, resources.MandateImportEntry) @@ -50,17 +51,18 @@ def test_502_mandate_import_entries_create_retries(): response = helpers.client.mandate_import_entries.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_import_entries'] assert isinstance(response, resources.MandateImportEntry) - @responses.activate def test_mandate_import_entries_list(): fixture = helpers.load_fixture('mandate_import_entries')['list'] helpers.stub_response(fixture) response = helpers.client.mandate_import_entries.list(*fixture['url_params']) - body = fixture['body']['mandate_import_entries'] + if fixture['body'].get('mandate_import_entries') is not None and isinstance(fixture['body'].get('mandate_import_entries'), (dict, list)): + body = fixture['body']['mandate_import_entries'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.MandateImportEntry) @@ -79,7 +81,6 @@ def test_timeout_mandate_import_entries_list_retries(): response = helpers.client.mandate_import_entries.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_import_entries'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.MandateImportEntry) @@ -93,7 +94,6 @@ def test_502_mandate_import_entries_list_retries(): response = helpers.client.mandate_import_entries.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_import_entries'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.MandateImportEntry) @@ -119,5 +119,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['mandate_import_entries']) * 2 for record in all_records: assert isinstance(record, resources.MandateImportEntry) - - diff --git a/tests/integration/mandate_imports_integration_test.py b/tests/integration/mandate_imports_integration_test.py index d88608cb..91067e61 100644 --- a/tests/integration/mandate_imports_integration_test.py +++ b/tests/integration/mandate_imports_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_mandate_imports_create(): fixture = helpers.load_fixture('mandate_imports')['create'] helpers.stub_response(fixture) response = helpers.client.mandate_imports.create(*fixture['url_params']) - body = fixture['body']['mandate_imports'] + if fixture['body'].get('mandate_imports') is not None and isinstance(fixture['body'].get('mandate_imports'), (dict, list)): + body = fixture['body']['mandate_imports'] + else: + body = fixture['body'] assert isinstance(response, resources.MandateImport) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -55,7 +57,6 @@ def test_timeout_mandate_imports_create_retries(): response = helpers.client.mandate_imports.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_imports'] assert isinstance(response, resources.MandateImport) @@ -65,17 +66,18 @@ def test_502_mandate_imports_create_retries(): response = helpers.client.mandate_imports.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_imports'] assert isinstance(response, resources.MandateImport) - @responses.activate def test_mandate_imports_get(): fixture = helpers.load_fixture('mandate_imports')['get'] helpers.stub_response(fixture) response = helpers.client.mandate_imports.get(*fixture['url_params']) - body = fixture['body']['mandate_imports'] + if fixture['body'].get('mandate_imports') is not None and isinstance(fixture['body'].get('mandate_imports'), (dict, list)): + body = fixture['body']['mandate_imports'] + else: + body = fixture['body'] assert isinstance(response, resources.MandateImport) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -92,7 +94,6 @@ def test_timeout_mandate_imports_get_retries(): response = helpers.client.mandate_imports.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_imports'] assert isinstance(response, resources.MandateImport) @@ -102,17 +103,18 @@ def test_502_mandate_imports_get_retries(): response = helpers.client.mandate_imports.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_imports'] assert isinstance(response, resources.MandateImport) - @responses.activate def test_mandate_imports_submit(): fixture = helpers.load_fixture('mandate_imports')['submit'] helpers.stub_response(fixture) response = helpers.client.mandate_imports.submit(*fixture['url_params']) - body = fixture['body']['mandate_imports'] + if fixture['body'].get('mandate_imports') is not None and isinstance(fixture['body'].get('mandate_imports'), (dict, list)): + body = fixture['body']['mandate_imports'] + else: + body = fixture['body'] assert isinstance(response, resources.MandateImport) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -135,14 +137,16 @@ def test_502_mandate_imports_submit_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.mandate_imports.submit(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_mandate_imports_cancel(): fixture = helpers.load_fixture('mandate_imports')['cancel'] helpers.stub_response(fixture) response = helpers.client.mandate_imports.cancel(*fixture['url_params']) - body = fixture['body']['mandate_imports'] + if fixture['body'].get('mandate_imports') is not None and isinstance(fixture['body'].get('mandate_imports'), (dict, list)): + body = fixture['body']['mandate_imports'] + else: + body = fixture['body'] assert isinstance(response, resources.MandateImport) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -165,4 +169,3 @@ def test_502_mandate_imports_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.mandate_imports.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/mandate_pdfs_integration_test.py b/tests/integration/mandate_pdfs_integration_test.py index 978e6b94..68347faa 100644 --- a/tests/integration/mandate_pdfs_integration_test.py +++ b/tests/integration/mandate_pdfs_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_mandate_pdfs_create(): fixture = helpers.load_fixture('mandate_pdfs')['create'] helpers.stub_response(fixture) response = helpers.client.mandate_pdfs.create(*fixture['url_params']) - body = fixture['body']['mandate_pdfs'] + if fixture['body'].get('mandate_pdfs') is not None and isinstance(fixture['body'].get('mandate_pdfs'), (dict, list)): + body = fixture['body']['mandate_pdfs'] + else: + body = fixture['body'] assert isinstance(response, resources.MandatePdf) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -35,7 +37,6 @@ def test_timeout_mandate_pdfs_create_retries(): response = helpers.client.mandate_pdfs.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_pdfs'] assert isinstance(response, resources.MandatePdf) @@ -45,7 +46,5 @@ def test_502_mandate_pdfs_create_retries(): response = helpers.client.mandate_pdfs.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandate_pdfs'] assert isinstance(response, resources.MandatePdf) - diff --git a/tests/integration/mandates_integration_test.py b/tests/integration/mandates_integration_test.py index 5f02bdb6..f881fe93 100644 --- a/tests/integration/mandates_integration_test.py +++ b/tests/integration/mandates_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_mandates_create(): fixture = helpers.load_fixture('mandates')['create'] helpers.stub_response(fixture) response = helpers.client.mandates.create(*fixture['url_params']) - body = fixture['body']['mandates'] + if fixture['body'].get('mandates') is not None and isinstance(fixture['body'].get('mandates'), (dict, list)): + body = fixture['body']['mandates'] + else: + body = fixture['body'] assert isinstance(response, resources.Mandate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -73,7 +75,6 @@ def test_timeout_mandates_create_retries(): response = helpers.client.mandates.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, resources.Mandate) @@ -83,17 +84,18 @@ def test_502_mandates_create_retries(): response = helpers.client.mandates.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, resources.Mandate) - @responses.activate def test_mandates_list(): fixture = helpers.load_fixture('mandates')['list'] helpers.stub_response(fixture) response = helpers.client.mandates.list(*fixture['url_params']) - body = fixture['body']['mandates'] + if fixture['body'].get('mandates') is not None and isinstance(fixture['body'].get('mandates'), (dict, list)): + body = fixture['body']['mandates'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Mandate) @@ -122,7 +124,6 @@ def test_timeout_mandates_list_retries(): response = helpers.client.mandates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Mandate) @@ -136,7 +137,6 @@ def test_502_mandates_list_retries(): response = helpers.client.mandates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Mandate) @@ -162,15 +162,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['mandates']) * 2 for record in all_records: assert isinstance(record, resources.Mandate) - - @responses.activate def test_mandates_get(): fixture = helpers.load_fixture('mandates')['get'] helpers.stub_response(fixture) response = helpers.client.mandates.get(*fixture['url_params']) - body = fixture['body']['mandates'] + if fixture['body'].get('mandates') is not None and isinstance(fixture['body'].get('mandates'), (dict, list)): + body = fixture['body']['mandates'] + else: + body = fixture['body'] assert isinstance(response, resources.Mandate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -205,7 +206,6 @@ def test_timeout_mandates_get_retries(): response = helpers.client.mandates.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, resources.Mandate) @@ -215,17 +215,18 @@ def test_502_mandates_get_retries(): response = helpers.client.mandates.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, resources.Mandate) - @responses.activate def test_mandates_update(): fixture = helpers.load_fixture('mandates')['update'] helpers.stub_response(fixture) response = helpers.client.mandates.update(*fixture['url_params']) - body = fixture['body']['mandates'] + if fixture['body'].get('mandates') is not None and isinstance(fixture['body'].get('mandates'), (dict, list)): + body = fixture['body']['mandates'] + else: + body = fixture['body'] assert isinstance(response, resources.Mandate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -260,7 +261,6 @@ def test_timeout_mandates_update_retries(): response = helpers.client.mandates.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, resources.Mandate) @@ -270,17 +270,18 @@ def test_502_mandates_update_retries(): response = helpers.client.mandates.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['mandates'] assert isinstance(response, resources.Mandate) - @responses.activate def test_mandates_cancel(): fixture = helpers.load_fixture('mandates')['cancel'] helpers.stub_response(fixture) response = helpers.client.mandates.cancel(*fixture['url_params']) - body = fixture['body']['mandates'] + if fixture['body'].get('mandates') is not None and isinstance(fixture['body'].get('mandates'), (dict, list)): + body = fixture['body']['mandates'] + else: + body = fixture['body'] assert isinstance(response, resources.Mandate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -321,14 +322,16 @@ def test_502_mandates_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.mandates.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_mandates_reinstate(): fixture = helpers.load_fixture('mandates')['reinstate'] helpers.stub_response(fixture) response = helpers.client.mandates.reinstate(*fixture['url_params']) - body = fixture['body']['mandates'] + if fixture['body'].get('mandates') is not None and isinstance(fixture['body'].get('mandates'), (dict, list)): + body = fixture['body']['mandates'] + else: + body = fixture['body'] assert isinstance(response, resources.Mandate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -369,4 +372,3 @@ def test_502_mandates_reinstate_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.mandates.reinstate(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/negative_balance_limits_integration_test.py b/tests/integration/negative_balance_limits_integration_test.py index 88eb61eb..0463a932 100644 --- a/tests/integration/negative_balance_limits_integration_test.py +++ b/tests/integration/negative_balance_limits_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_negative_balance_limits_list(): fixture = helpers.load_fixture('negative_balance_limits')['list'] helpers.stub_response(fixture) response = helpers.client.negative_balance_limits.list(*fixture['url_params']) - body = fixture['body']['negative_balance_limits'] + if fixture['body'].get('negative_balance_limits') is not None and isinstance(fixture['body'].get('negative_balance_limits'), (dict, list)): + body = fixture['body']['negative_balance_limits'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.NegativeBalanceLimit) @@ -41,7 +43,6 @@ def test_timeout_negative_balance_limits_list_retries(): response = helpers.client.negative_balance_limits.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['negative_balance_limits'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.NegativeBalanceLimit) @@ -55,7 +56,6 @@ def test_502_negative_balance_limits_list_retries(): response = helpers.client.negative_balance_limits.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['negative_balance_limits'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.NegativeBalanceLimit) @@ -81,5 +81,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['negative_balance_limits']) * 2 for record in all_records: assert isinstance(record, resources.NegativeBalanceLimit) - - diff --git a/tests/integration/outbound_payments_integration_test.py b/tests/integration/outbound_payments_integration_test.py index 637086f0..174db76a 100644 --- a/tests/integration/outbound_payments_integration_test.py +++ b/tests/integration/outbound_payments_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_outbound_payments_create(): fixture = helpers.load_fixture('outbound_payments')['create'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.create(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, resources.OutboundPayment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -65,7 +67,6 @@ def test_timeout_outbound_payments_create_retries(): response = helpers.client.outbound_payments.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, resources.OutboundPayment) @@ -75,17 +76,18 @@ def test_502_outbound_payments_create_retries(): response = helpers.client.outbound_payments.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, resources.OutboundPayment) - @responses.activate def test_outbound_payments_withdraw(): fixture = helpers.load_fixture('outbound_payments')['withdraw'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.withdraw(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, resources.OutboundPayment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -118,14 +120,16 @@ def test_502_outbound_payments_withdraw_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.outbound_payments.withdraw(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_outbound_payments_cancel(): fixture = helpers.load_fixture('outbound_payments')['cancel'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.cancel(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, resources.OutboundPayment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -158,14 +162,16 @@ def test_502_outbound_payments_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.outbound_payments.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_outbound_payments_approve(): fixture = helpers.load_fixture('outbound_payments')['approve'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.approve(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, resources.OutboundPayment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -198,14 +204,16 @@ def test_502_outbound_payments_approve_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.outbound_payments.approve(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_outbound_payments_get(): fixture = helpers.load_fixture('outbound_payments')['get'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.get(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, resources.OutboundPayment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -232,7 +240,6 @@ def test_timeout_outbound_payments_get_retries(): response = helpers.client.outbound_payments.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, resources.OutboundPayment) @@ -242,17 +249,18 @@ def test_502_outbound_payments_get_retries(): response = helpers.client.outbound_payments.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, resources.OutboundPayment) - @responses.activate def test_outbound_payments_list(): fixture = helpers.load_fixture('outbound_payments')['list'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.list(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.OutboundPayment) @@ -279,7 +287,6 @@ def test_timeout_outbound_payments_list_retries(): response = helpers.client.outbound_payments.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.OutboundPayment) @@ -293,7 +300,6 @@ def test_502_outbound_payments_list_retries(): response = helpers.client.outbound_payments.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.OutboundPayment) @@ -319,15 +325,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['outbound_payments']) * 2 for record in all_records: assert isinstance(record, resources.OutboundPayment) - - @responses.activate def test_outbound_payments_update(): fixture = helpers.load_fixture('outbound_payments')['update'] helpers.stub_response(fixture) response = helpers.client.outbound_payments.update(*fixture['url_params']) - body = fixture['body']['outbound_payments'] + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] assert isinstance(response, resources.OutboundPayment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -354,7 +361,6 @@ def test_timeout_outbound_payments_update_retries(): response = helpers.client.outbound_payments.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, resources.OutboundPayment) @@ -364,7 +370,32 @@ def test_502_outbound_payments_update_retries(): response = helpers.client.outbound_payments.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['outbound_payments'] assert isinstance(response, resources.OutboundPayment) - + +@responses.activate +def test_outbound_payments_stats(): + fixture = helpers.load_fixture('outbound_payments')['stats'] + helpers.stub_response(fixture) + response = helpers.client.outbound_payments.stats(*fixture['url_params']) + if fixture['body'].get('outbound_payments') is not None and isinstance(fixture['body'].get('outbound_payments'), (dict, list)): + body = fixture['body']['outbound_payments'] + else: + body = fixture['body'] + + assert isinstance(response, resources.OutboundPayment) + assert responses.calls[-1].request.headers.get('Idempotency-Key') is None + +def test_timeout_outbound_payments_stats_doesnt_retry(): + fixture = helpers.load_fixture('outbound_payments')['stats'] + with helpers.stub_timeout(fixture) as rsps: + with pytest.raises(requests.ConnectTimeout): + response = helpers.client.outbound_payments.stats(*fixture['url_params']) + assert len(rsps.calls) == 1 + +def test_502_outbound_payments_stats_doesnt_retry(): + fixture = helpers.load_fixture('outbound_payments')['stats'] + with helpers.stub_502(fixture) as rsps: + with pytest.raises(MalformedResponseError): + response = helpers.client.outbound_payments.stats(*fixture['url_params']) + assert len(rsps.calls) == 1 diff --git a/tests/integration/payer_authorisations_integration_test.py b/tests/integration/payer_authorisations_integration_test.py index faa8abce..49296517 100644 --- a/tests/integration/payer_authorisations_integration_test.py +++ b/tests/integration/payer_authorisations_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_payer_authorisations_get(): fixture = helpers.load_fixture('payer_authorisations')['get'] helpers.stub_response(fixture) response = helpers.client.payer_authorisations.get(*fixture['url_params']) - body = fixture['body']['payer_authorisations'] + if fixture['body'].get('payer_authorisations') is not None and isinstance(fixture['body'].get('payer_authorisations'), (dict, list)): + body = fixture['body']['payer_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.PayerAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -70,7 +72,6 @@ def test_timeout_payer_authorisations_get_retries(): response = helpers.client.payer_authorisations.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_authorisations'] assert isinstance(response, resources.PayerAuthorisation) @@ -80,17 +81,18 @@ def test_502_payer_authorisations_get_retries(): response = helpers.client.payer_authorisations.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_authorisations'] assert isinstance(response, resources.PayerAuthorisation) - @responses.activate def test_payer_authorisations_create(): fixture = helpers.load_fixture('payer_authorisations')['create'] helpers.stub_response(fixture) response = helpers.client.payer_authorisations.create(*fixture['url_params']) - body = fixture['body']['payer_authorisations'] + if fixture['body'].get('payer_authorisations') is not None and isinstance(fixture['body'].get('payer_authorisations'), (dict, list)): + body = fixture['body']['payer_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.PayerAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -156,7 +158,6 @@ def test_timeout_payer_authorisations_create_retries(): response = helpers.client.payer_authorisations.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_authorisations'] assert isinstance(response, resources.PayerAuthorisation) @@ -166,17 +167,18 @@ def test_502_payer_authorisations_create_retries(): response = helpers.client.payer_authorisations.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_authorisations'] assert isinstance(response, resources.PayerAuthorisation) - @responses.activate def test_payer_authorisations_update(): fixture = helpers.load_fixture('payer_authorisations')['update'] helpers.stub_response(fixture) response = helpers.client.payer_authorisations.update(*fixture['url_params']) - body = fixture['body']['payer_authorisations'] + if fixture['body'].get('payer_authorisations') is not None and isinstance(fixture['body'].get('payer_authorisations'), (dict, list)): + body = fixture['body']['payer_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.PayerAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -225,7 +227,6 @@ def test_timeout_payer_authorisations_update_retries(): response = helpers.client.payer_authorisations.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_authorisations'] assert isinstance(response, resources.PayerAuthorisation) @@ -235,17 +236,18 @@ def test_502_payer_authorisations_update_retries(): response = helpers.client.payer_authorisations.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_authorisations'] assert isinstance(response, resources.PayerAuthorisation) - @responses.activate def test_payer_authorisations_submit(): fixture = helpers.load_fixture('payer_authorisations')['submit'] helpers.stub_response(fixture) response = helpers.client.payer_authorisations.submit(*fixture['url_params']) - body = fixture['body']['payer_authorisations'] + if fixture['body'].get('payer_authorisations') is not None and isinstance(fixture['body'].get('payer_authorisations'), (dict, list)): + body = fixture['body']['payer_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.PayerAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -300,14 +302,16 @@ def test_502_payer_authorisations_submit_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.payer_authorisations.submit(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_payer_authorisations_confirm(): fixture = helpers.load_fixture('payer_authorisations')['confirm'] helpers.stub_response(fixture) response = helpers.client.payer_authorisations.confirm(*fixture['url_params']) - body = fixture['body']['payer_authorisations'] + if fixture['body'].get('payer_authorisations') is not None and isinstance(fixture['body'].get('payer_authorisations'), (dict, list)): + body = fixture['body']['payer_authorisations'] + else: + body = fixture['body'] assert isinstance(response, resources.PayerAuthorisation) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -362,4 +366,3 @@ def test_502_payer_authorisations_confirm_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.payer_authorisations.confirm(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/payer_themes_integration_test.py b/tests/integration/payer_themes_integration_test.py index 1a82522e..e9e1af95 100644 --- a/tests/integration/payer_themes_integration_test.py +++ b/tests/integration/payer_themes_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_payer_themes_create_for_creditor(): fixture = helpers.load_fixture('payer_themes')['create_for_creditor'] helpers.stub_response(fixture) response = helpers.client.payer_themes.create_for_creditor(*fixture['url_params']) - body = fixture['body']['payer_themes'] + if fixture['body'].get('payer_themes') is not None and isinstance(fixture['body'].get('payer_themes'), (dict, list)): + body = fixture['body']['payer_themes'] + else: + body = fixture['body'] assert isinstance(response, resources.PayerTheme) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -34,7 +36,6 @@ def test_timeout_payer_themes_create_for_creditor_retries(): response = helpers.client.payer_themes.create_for_creditor(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_themes'] assert isinstance(response, resources.PayerTheme) @@ -44,7 +45,5 @@ def test_502_payer_themes_create_for_creditor_retries(): response = helpers.client.payer_themes.create_for_creditor(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payer_themes'] assert isinstance(response, resources.PayerTheme) - diff --git a/tests/integration/payment_account_transactions_integration_test.py b/tests/integration/payment_account_transactions_integration_test.py index 6b2a1597..1f0f44ca 100644 --- a/tests/integration/payment_account_transactions_integration_test.py +++ b/tests/integration/payment_account_transactions_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_payment_account_transactions_list(): fixture = helpers.load_fixture('payment_account_transactions')['list'] helpers.stub_response(fixture) response = helpers.client.payment_account_transactions.list(*fixture['url_params']) - body = fixture['body']['payment_account_transactions'] + if fixture['body'].get('payment_account_transactions') is not None and isinstance(fixture['body'].get('payment_account_transactions'), (dict, list)): + body = fixture['body']['payment_account_transactions'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.PaymentAccountTransaction) @@ -46,7 +48,6 @@ def test_timeout_payment_account_transactions_list_retries(): response = helpers.client.payment_account_transactions.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payment_account_transactions'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.PaymentAccountTransaction) @@ -60,7 +61,6 @@ def test_502_payment_account_transactions_list_retries(): response = helpers.client.payment_account_transactions.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payment_account_transactions'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.PaymentAccountTransaction) @@ -86,5 +86,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['payment_account_transactions']) * 2 for record in all_records: assert isinstance(record, resources.PaymentAccountTransaction) - - diff --git a/tests/integration/payment_accounts_integration_test.py b/tests/integration/payment_accounts_integration_test.py new file mode 100644 index 00000000..f1ffdc6d --- /dev/null +++ b/tests/integration/payment_accounts_integration_test.py @@ -0,0 +1,124 @@ +# WARNING: Do not edit by hand, this file was generated by Crank: +# +# https://github.com/gocardless/crank +# + +import json + +import pytest +import requests +import responses + +from gocardless_pro.errors import MalformedResponseError +from gocardless_pro import resources +from gocardless_pro import list_response + +from .. import helpers + +@responses.activate +def test_payment_accounts_get(): + fixture = helpers.load_fixture('payment_accounts')['get'] + helpers.stub_response(fixture) + response = helpers.client.payment_accounts.get(*fixture['url_params']) + if fixture['body'].get('payment_accounts') is not None and isinstance(fixture['body'].get('payment_accounts'), (dict, list)): + body = fixture['body']['payment_accounts'] + else: + body = fixture['body'] + + assert isinstance(response, resources.PaymentAccount) + assert responses.calls[-1].request.headers.get('Idempotency-Key') is None + assert response.account_balance == body.get('account_balance') + assert response.account_holder_name == body.get('account_holder_name') + assert response.account_number_ending == body.get('account_number_ending') + assert response.bank_name == body.get('bank_name') + assert response.currency == body.get('currency') + assert response.id == body.get('id') + assert response.links.creditor == body.get('links')['creditor'] + +@responses.activate +def test_timeout_payment_accounts_get_retries(): + fixture = helpers.load_fixture('payment_accounts')['get'] + with helpers.stub_timeout_then_response(fixture) as rsps: + response = helpers.client.payment_accounts.get(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, resources.PaymentAccount) + +def test_502_payment_accounts_get_retries(): + fixture = helpers.load_fixture('payment_accounts')['get'] + with helpers.stub_502_then_response(fixture) as rsps: + response = helpers.client.payment_accounts.get(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, resources.PaymentAccount) + +@responses.activate +def test_payment_accounts_list(): + fixture = helpers.load_fixture('payment_accounts')['list'] + helpers.stub_response(fixture) + response = helpers.client.payment_accounts.list(*fixture['url_params']) + if fixture['body'].get('payment_accounts') is not None and isinstance(fixture['body'].get('payment_accounts'), (dict, list)): + body = fixture['body']['payment_accounts'] + else: + body = fixture['body'] + + assert isinstance(response, list_response.ListResponse) + assert isinstance(response.records[0], resources.PaymentAccount) + + assert response.before == fixture['body']['meta']['cursors']['before'] + assert response.after == fixture['body']['meta']['cursors']['after'] + assert responses.calls[-1].request.headers.get('Idempotency-Key') is None + assert [r.account_balance for r in response.records] == [b.get('account_balance') for b in body] + assert [r.account_holder_name for r in response.records] == [b.get('account_holder_name') for b in body] + assert [r.account_number_ending for r in response.records] == [b.get('account_number_ending') for b in body] + assert [r.bank_name for r in response.records] == [b.get('bank_name') for b in body] + assert [r.currency for r in response.records] == [b.get('currency') for b in body] + assert [r.id for r in response.records] == [b.get('id') for b in body] + +@responses.activate +def test_timeout_payment_accounts_list_retries(): + fixture = helpers.load_fixture('payment_accounts')['list'] + with helpers.stub_timeout_then_response(fixture) as rsps: + response = helpers.client.payment_accounts.list(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, list_response.ListResponse) + assert isinstance(response.records[0], resources.PaymentAccount) + + assert response.before == fixture['body']['meta']['cursors']['before'] + assert response.after == fixture['body']['meta']['cursors']['after'] + +def test_502_payment_accounts_list_retries(): + fixture = helpers.load_fixture('payment_accounts')['list'] + with helpers.stub_502_then_response(fixture) as rsps: + response = helpers.client.payment_accounts.list(*fixture['url_params']) + assert len(rsps.calls) == 2 + assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') + + assert isinstance(response, list_response.ListResponse) + assert isinstance(response.records[0], resources.PaymentAccount) + + assert response.before == fixture['body']['meta']['cursors']['before'] + assert response.after == fixture['body']['meta']['cursors']['after'] + +@responses.activate +def test_payment_accounts_all(): + fixture = helpers.load_fixture('payment_accounts')['list'] + + def callback(request): + if 'after=123' in request.url: + fixture['body']['meta']['cursors']['after'] = None + else: + fixture['body']['meta']['cursors']['after'] = '123' + return [200, {}, json.dumps(fixture['body'])] + + url_pattern = helpers.url_pattern_for(fixture) + responses.add_callback(fixture['method'], url_pattern, callback) + + all_records = list(helpers.client.payment_accounts.all(*fixture['url_params'])) + assert len(all_records) == len(fixture['body']['payment_accounts']) * 2 + for record in all_records: + assert isinstance(record, resources.PaymentAccount) diff --git a/tests/integration/payments_integration_test.py b/tests/integration/payments_integration_test.py index 7c586f46..5dd9e013 100644 --- a/tests/integration/payments_integration_test.py +++ b/tests/integration/payments_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_payments_create(): fixture = helpers.load_fixture('payments')['create'] helpers.stub_response(fixture) response = helpers.client.payments.create(*fixture['url_params']) - body = fixture['body']['payments'] + if fixture['body'].get('payments') is not None and isinstance(fixture['body'].get('payments'), (dict, list)): + body = fixture['body']['payments'] + else: + body = fixture['body'] assert isinstance(response, resources.Payment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -72,7 +74,6 @@ def test_timeout_payments_create_retries(): response = helpers.client.payments.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, resources.Payment) @@ -82,17 +83,18 @@ def test_502_payments_create_retries(): response = helpers.client.payments.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, resources.Payment) - @responses.activate def test_payments_list(): fixture = helpers.load_fixture('payments')['list'] helpers.stub_response(fixture) response = helpers.client.payments.list(*fixture['url_params']) - body = fixture['body']['payments'] + if fixture['body'].get('payments') is not None and isinstance(fixture['body'].get('payments'), (dict, list)): + body = fixture['body']['payments'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Payment) @@ -121,7 +123,6 @@ def test_timeout_payments_list_retries(): response = helpers.client.payments.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Payment) @@ -135,7 +136,6 @@ def test_502_payments_list_retries(): response = helpers.client.payments.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Payment) @@ -161,15 +161,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['payments']) * 2 for record in all_records: assert isinstance(record, resources.Payment) - - @responses.activate def test_payments_get(): fixture = helpers.load_fixture('payments')['get'] helpers.stub_response(fixture) response = helpers.client.payments.get(*fixture['url_params']) - body = fixture['body']['payments'] + if fixture['body'].get('payments') is not None and isinstance(fixture['body'].get('payments'), (dict, list)): + body = fixture['body']['payments'] + else: + body = fixture['body'] assert isinstance(response, resources.Payment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -203,7 +204,6 @@ def test_timeout_payments_get_retries(): response = helpers.client.payments.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, resources.Payment) @@ -213,17 +213,18 @@ def test_502_payments_get_retries(): response = helpers.client.payments.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, resources.Payment) - @responses.activate def test_payments_update(): fixture = helpers.load_fixture('payments')['update'] helpers.stub_response(fixture) response = helpers.client.payments.update(*fixture['url_params']) - body = fixture['body']['payments'] + if fixture['body'].get('payments') is not None and isinstance(fixture['body'].get('payments'), (dict, list)): + body = fixture['body']['payments'] + else: + body = fixture['body'] assert isinstance(response, resources.Payment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -257,7 +258,6 @@ def test_timeout_payments_update_retries(): response = helpers.client.payments.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, resources.Payment) @@ -267,17 +267,18 @@ def test_502_payments_update_retries(): response = helpers.client.payments.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payments'] assert isinstance(response, resources.Payment) - @responses.activate def test_payments_cancel(): fixture = helpers.load_fixture('payments')['cancel'] helpers.stub_response(fixture) response = helpers.client.payments.cancel(*fixture['url_params']) - body = fixture['body']['payments'] + if fixture['body'].get('payments') is not None and isinstance(fixture['body'].get('payments'), (dict, list)): + body = fixture['body']['payments'] + else: + body = fixture['body'] assert isinstance(response, resources.Payment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -317,14 +318,16 @@ def test_502_payments_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.payments.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_payments_retry(): fixture = helpers.load_fixture('payments')['retry'] helpers.stub_response(fixture) response = helpers.client.payments.retry(*fixture['url_params']) - body = fixture['body']['payments'] + if fixture['body'].get('payments') is not None and isinstance(fixture['body'].get('payments'), (dict, list)): + body = fixture['body']['payments'] + else: + body = fixture['body'] assert isinstance(response, resources.Payment) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -364,4 +367,3 @@ def test_502_payments_retry_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.payments.retry(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/payout_items_integration_test.py b/tests/integration/payout_items_integration_test.py index e64c8565..da186b01 100644 --- a/tests/integration/payout_items_integration_test.py +++ b/tests/integration/payout_items_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_payout_items_list(): fixture = helpers.load_fixture('payout_items')['list'] helpers.stub_response(fixture) response = helpers.client.payout_items.list(*fixture['url_params']) - body = fixture['body']['payout_items'] + if fixture['body'].get('payout_items') is not None and isinstance(fixture['body'].get('payout_items'), (dict, list)): + body = fixture['body']['payout_items'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.PayoutItem) @@ -40,7 +42,6 @@ def test_timeout_payout_items_list_retries(): response = helpers.client.payout_items.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payout_items'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.PayoutItem) @@ -54,7 +55,6 @@ def test_502_payout_items_list_retries(): response = helpers.client.payout_items.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payout_items'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.PayoutItem) @@ -80,5 +80,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['payout_items']) * 2 for record in all_records: assert isinstance(record, resources.PayoutItem) - - diff --git a/tests/integration/payouts_integration_test.py b/tests/integration/payouts_integration_test.py index 082e3ae9..9434ba6c 100644 --- a/tests/integration/payouts_integration_test.py +++ b/tests/integration/payouts_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_payouts_list(): fixture = helpers.load_fixture('payouts')['list'] helpers.stub_response(fixture) response = helpers.client.payouts.list(*fixture['url_params']) - body = fixture['body']['payouts'] + if fixture['body'].get('payouts') is not None and isinstance(fixture['body'].get('payouts'), (dict, list)): + body = fixture['body']['payouts'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Payout) @@ -48,7 +50,6 @@ def test_timeout_payouts_list_retries(): response = helpers.client.payouts.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payouts'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Payout) @@ -62,7 +63,6 @@ def test_502_payouts_list_retries(): response = helpers.client.payouts.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payouts'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Payout) @@ -88,15 +88,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['payouts']) * 2 for record in all_records: assert isinstance(record, resources.Payout) - - @responses.activate def test_payouts_get(): fixture = helpers.load_fixture('payouts')['get'] helpers.stub_response(fixture) response = helpers.client.payouts.get(*fixture['url_params']) - body = fixture['body']['payouts'] + if fixture['body'].get('payouts') is not None and isinstance(fixture['body'].get('payouts'), (dict, list)): + body = fixture['body']['payouts'] + else: + body = fixture['body'] assert isinstance(response, resources.Payout) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -125,7 +126,6 @@ def test_timeout_payouts_get_retries(): response = helpers.client.payouts.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payouts'] assert isinstance(response, resources.Payout) @@ -135,17 +135,18 @@ def test_502_payouts_get_retries(): response = helpers.client.payouts.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payouts'] assert isinstance(response, resources.Payout) - @responses.activate def test_payouts_update(): fixture = helpers.load_fixture('payouts')['update'] helpers.stub_response(fixture) response = helpers.client.payouts.update(*fixture['url_params']) - body = fixture['body']['payouts'] + if fixture['body'].get('payouts') is not None and isinstance(fixture['body'].get('payouts'), (dict, list)): + body = fixture['body']['payouts'] + else: + body = fixture['body'] assert isinstance(response, resources.Payout) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -174,7 +175,6 @@ def test_timeout_payouts_update_retries(): response = helpers.client.payouts.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payouts'] assert isinstance(response, resources.Payout) @@ -184,7 +184,5 @@ def test_502_payouts_update_retries(): response = helpers.client.payouts.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['payouts'] assert isinstance(response, resources.Payout) - diff --git a/tests/integration/redirect_flows_integration_test.py b/tests/integration/redirect_flows_integration_test.py index 56854243..6d190865 100644 --- a/tests/integration/redirect_flows_integration_test.py +++ b/tests/integration/redirect_flows_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_redirect_flows_create(): fixture = helpers.load_fixture('redirect_flows')['create'] helpers.stub_response(fixture) response = helpers.client.redirect_flows.create(*fixture['url_params']) - body = fixture['body']['redirect_flows'] + if fixture['body'].get('redirect_flows') is not None and isinstance(fixture['body'].get('redirect_flows'), (dict, list)): + body = fixture['body']['redirect_flows'] + else: + body = fixture['body'] assert isinstance(response, resources.RedirectFlow) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -65,7 +67,6 @@ def test_timeout_redirect_flows_create_retries(): response = helpers.client.redirect_flows.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['redirect_flows'] assert isinstance(response, resources.RedirectFlow) @@ -75,17 +76,18 @@ def test_502_redirect_flows_create_retries(): response = helpers.client.redirect_flows.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['redirect_flows'] assert isinstance(response, resources.RedirectFlow) - @responses.activate def test_redirect_flows_get(): fixture = helpers.load_fixture('redirect_flows')['get'] helpers.stub_response(fixture) response = helpers.client.redirect_flows.get(*fixture['url_params']) - body = fixture['body']['redirect_flows'] + if fixture['body'].get('redirect_flows') is not None and isinstance(fixture['body'].get('redirect_flows'), (dict, list)): + body = fixture['body']['redirect_flows'] + else: + body = fixture['body'] assert isinstance(response, resources.RedirectFlow) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -112,7 +114,6 @@ def test_timeout_redirect_flows_get_retries(): response = helpers.client.redirect_flows.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['redirect_flows'] assert isinstance(response, resources.RedirectFlow) @@ -122,17 +123,18 @@ def test_502_redirect_flows_get_retries(): response = helpers.client.redirect_flows.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['redirect_flows'] assert isinstance(response, resources.RedirectFlow) - @responses.activate def test_redirect_flows_complete(): fixture = helpers.load_fixture('redirect_flows')['complete'] helpers.stub_response(fixture) response = helpers.client.redirect_flows.complete(*fixture['url_params']) - body = fixture['body']['redirect_flows'] + if fixture['body'].get('redirect_flows') is not None and isinstance(fixture['body'].get('redirect_flows'), (dict, list)): + body = fixture['body']['redirect_flows'] + else: + body = fixture['body'] assert isinstance(response, resources.RedirectFlow) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -165,4 +167,3 @@ def test_502_redirect_flows_complete_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.redirect_flows.complete(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/refunds_integration_test.py b/tests/integration/refunds_integration_test.py index ec939a17..69be506f 100644 --- a/tests/integration/refunds_integration_test.py +++ b/tests/integration/refunds_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_refunds_create(): fixture = helpers.load_fixture('refunds')['create'] helpers.stub_response(fixture) response = helpers.client.refunds.create(*fixture['url_params']) - body = fixture['body']['refunds'] + if fixture['body'].get('refunds') is not None and isinstance(fixture['body'].get('refunds'), (dict, list)): + body = fixture['body']['refunds'] + else: + body = fixture['body'] assert isinstance(response, resources.Refund) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -63,7 +65,6 @@ def test_timeout_refunds_create_retries(): response = helpers.client.refunds.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, resources.Refund) @@ -73,17 +74,18 @@ def test_502_refunds_create_retries(): response = helpers.client.refunds.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, resources.Refund) - @responses.activate def test_refunds_list(): fixture = helpers.load_fixture('refunds')['list'] helpers.stub_response(fixture) response = helpers.client.refunds.list(*fixture['url_params']) - body = fixture['body']['refunds'] + if fixture['body'].get('refunds') is not None and isinstance(fixture['body'].get('refunds'), (dict, list)): + body = fixture['body']['refunds'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Refund) @@ -106,7 +108,6 @@ def test_timeout_refunds_list_retries(): response = helpers.client.refunds.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Refund) @@ -120,7 +121,6 @@ def test_502_refunds_list_retries(): response = helpers.client.refunds.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Refund) @@ -146,15 +146,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['refunds']) * 2 for record in all_records: assert isinstance(record, resources.Refund) - - @responses.activate def test_refunds_get(): fixture = helpers.load_fixture('refunds')['get'] helpers.stub_response(fixture) response = helpers.client.refunds.get(*fixture['url_params']) - body = fixture['body']['refunds'] + if fixture['body'].get('refunds') is not None and isinstance(fixture['body'].get('refunds'), (dict, list)): + body = fixture['body']['refunds'] + else: + body = fixture['body'] assert isinstance(response, resources.Refund) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -179,7 +180,6 @@ def test_timeout_refunds_get_retries(): response = helpers.client.refunds.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, resources.Refund) @@ -189,17 +189,18 @@ def test_502_refunds_get_retries(): response = helpers.client.refunds.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, resources.Refund) - @responses.activate def test_refunds_update(): fixture = helpers.load_fixture('refunds')['update'] helpers.stub_response(fixture) response = helpers.client.refunds.update(*fixture['url_params']) - body = fixture['body']['refunds'] + if fixture['body'].get('refunds') is not None and isinstance(fixture['body'].get('refunds'), (dict, list)): + body = fixture['body']['refunds'] + else: + body = fixture['body'] assert isinstance(response, resources.Refund) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -224,7 +225,6 @@ def test_timeout_refunds_update_retries(): response = helpers.client.refunds.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, resources.Refund) @@ -234,7 +234,5 @@ def test_502_refunds_update_retries(): response = helpers.client.refunds.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['refunds'] assert isinstance(response, resources.Refund) - diff --git a/tests/integration/scenario_simulators_integration_test.py b/tests/integration/scenario_simulators_integration_test.py index 1062e0f2..e19d0fe6 100644 --- a/tests/integration/scenario_simulators_integration_test.py +++ b/tests/integration/scenario_simulators_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_scenario_simulators_run(): fixture = helpers.load_fixture('scenario_simulators')['run'] helpers.stub_response(fixture) response = helpers.client.scenario_simulators.run(*fixture['url_params']) - body = fixture['body']['scenario_simulators'] + if fixture['body'].get('scenario_simulators') is not None and isinstance(fixture['body'].get('scenario_simulators'), (dict, list)): + body = fixture['body']['scenario_simulators'] + else: + body = fixture['body'] assert isinstance(response, resources.ScenarioSimulator) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -40,4 +42,3 @@ def test_502_scenario_simulators_run_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.scenario_simulators.run(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/scheme_identifiers_integration_test.py b/tests/integration/scheme_identifiers_integration_test.py index 8bfb356c..8aef278e 100644 --- a/tests/integration/scheme_identifiers_integration_test.py +++ b/tests/integration/scheme_identifiers_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_scheme_identifiers_create(): fixture = helpers.load_fixture('scheme_identifiers')['create'] helpers.stub_response(fixture) response = helpers.client.scheme_identifiers.create(*fixture['url_params']) - body = fixture['body']['scheme_identifiers'] + if fixture['body'].get('scheme_identifiers') is not None and isinstance(fixture['body'].get('scheme_identifiers'), (dict, list)): + body = fixture['body']['scheme_identifiers'] + else: + body = fixture['body'] assert isinstance(response, resources.SchemeIdentifier) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -68,7 +70,6 @@ def test_timeout_scheme_identifiers_create_retries(): response = helpers.client.scheme_identifiers.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['scheme_identifiers'] assert isinstance(response, resources.SchemeIdentifier) @@ -78,17 +79,18 @@ def test_502_scheme_identifiers_create_retries(): response = helpers.client.scheme_identifiers.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['scheme_identifiers'] assert isinstance(response, resources.SchemeIdentifier) - @responses.activate def test_scheme_identifiers_list(): fixture = helpers.load_fixture('scheme_identifiers')['list'] helpers.stub_response(fixture) response = helpers.client.scheme_identifiers.list(*fixture['url_params']) - body = fixture['body']['scheme_identifiers'] + if fixture['body'].get('scheme_identifiers') is not None and isinstance(fixture['body'].get('scheme_identifiers'), (dict, list)): + body = fixture['body']['scheme_identifiers'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.SchemeIdentifier) @@ -122,7 +124,6 @@ def test_timeout_scheme_identifiers_list_retries(): response = helpers.client.scheme_identifiers.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['scheme_identifiers'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.SchemeIdentifier) @@ -136,7 +137,6 @@ def test_502_scheme_identifiers_list_retries(): response = helpers.client.scheme_identifiers.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['scheme_identifiers'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.SchemeIdentifier) @@ -162,15 +162,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['scheme_identifiers']) * 2 for record in all_records: assert isinstance(record, resources.SchemeIdentifier) - - @responses.activate def test_scheme_identifiers_get(): fixture = helpers.load_fixture('scheme_identifiers')['get'] helpers.stub_response(fixture) response = helpers.client.scheme_identifiers.get(*fixture['url_params']) - body = fixture['body']['scheme_identifiers'] + if fixture['body'].get('scheme_identifiers') is not None and isinstance(fixture['body'].get('scheme_identifiers'), (dict, list)): + body = fixture['body']['scheme_identifiers'] + else: + body = fixture['body'] assert isinstance(response, resources.SchemeIdentifier) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -200,7 +201,6 @@ def test_timeout_scheme_identifiers_get_retries(): response = helpers.client.scheme_identifiers.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['scheme_identifiers'] assert isinstance(response, resources.SchemeIdentifier) @@ -210,7 +210,5 @@ def test_502_scheme_identifiers_get_retries(): response = helpers.client.scheme_identifiers.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['scheme_identifiers'] assert isinstance(response, resources.SchemeIdentifier) - diff --git a/tests/integration/subscriptions_integration_test.py b/tests/integration/subscriptions_integration_test.py index 7327a4f2..25d7a364 100644 --- a/tests/integration/subscriptions_integration_test.py +++ b/tests/integration/subscriptions_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_subscriptions_create(): fixture = helpers.load_fixture('subscriptions')['create'] helpers.stub_response(fixture) response = helpers.client.subscriptions.create(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, resources.Subscription) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -71,7 +73,6 @@ def test_timeout_subscriptions_create_retries(): response = helpers.client.subscriptions.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, resources.Subscription) @@ -81,17 +82,18 @@ def test_502_subscriptions_create_retries(): response = helpers.client.subscriptions.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, resources.Subscription) - @responses.activate def test_subscriptions_list(): fixture = helpers.load_fixture('subscriptions')['list'] helpers.stub_response(fixture) response = helpers.client.subscriptions.list(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Subscription) @@ -127,7 +129,6 @@ def test_timeout_subscriptions_list_retries(): response = helpers.client.subscriptions.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Subscription) @@ -141,7 +142,6 @@ def test_502_subscriptions_list_retries(): response = helpers.client.subscriptions.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Subscription) @@ -167,15 +167,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['subscriptions']) * 2 for record in all_records: assert isinstance(record, resources.Subscription) - - @responses.activate def test_subscriptions_get(): fixture = helpers.load_fixture('subscriptions')['get'] helpers.stub_response(fixture) response = helpers.client.subscriptions.get(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, resources.Subscription) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -208,7 +209,6 @@ def test_timeout_subscriptions_get_retries(): response = helpers.client.subscriptions.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, resources.Subscription) @@ -218,17 +218,18 @@ def test_502_subscriptions_get_retries(): response = helpers.client.subscriptions.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, resources.Subscription) - @responses.activate def test_subscriptions_update(): fixture = helpers.load_fixture('subscriptions')['update'] helpers.stub_response(fixture) response = helpers.client.subscriptions.update(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, resources.Subscription) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -261,7 +262,6 @@ def test_timeout_subscriptions_update_retries(): response = helpers.client.subscriptions.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, resources.Subscription) @@ -271,17 +271,18 @@ def test_502_subscriptions_update_retries(): response = helpers.client.subscriptions.update(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['subscriptions'] assert isinstance(response, resources.Subscription) - @responses.activate def test_subscriptions_pause(): fixture = helpers.load_fixture('subscriptions')['pause'] helpers.stub_response(fixture) response = helpers.client.subscriptions.pause(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, resources.Subscription) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -320,14 +321,16 @@ def test_502_subscriptions_pause_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.subscriptions.pause(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_subscriptions_resume(): fixture = helpers.load_fixture('subscriptions')['resume'] helpers.stub_response(fixture) response = helpers.client.subscriptions.resume(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, resources.Subscription) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -366,14 +369,16 @@ def test_502_subscriptions_resume_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.subscriptions.resume(*fixture['url_params']) assert len(rsps.calls) == 1 - @responses.activate def test_subscriptions_cancel(): fixture = helpers.load_fixture('subscriptions')['cancel'] helpers.stub_response(fixture) response = helpers.client.subscriptions.cancel(*fixture['url_params']) - body = fixture['body']['subscriptions'] + if fixture['body'].get('subscriptions') is not None and isinstance(fixture['body'].get('subscriptions'), (dict, list)): + body = fixture['body']['subscriptions'] + else: + body = fixture['body'] assert isinstance(response, resources.Subscription) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -412,4 +417,3 @@ def test_502_subscriptions_cancel_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.subscriptions.cancel(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/tax_rates_integration_test.py b/tests/integration/tax_rates_integration_test.py index 6fb5102e..a5801b98 100644 --- a/tests/integration/tax_rates_integration_test.py +++ b/tests/integration/tax_rates_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_tax_rates_list(): fixture = helpers.load_fixture('tax_rates')['list'] helpers.stub_response(fixture) response = helpers.client.tax_rates.list(*fixture['url_params']) - body = fixture['body']['tax_rates'] + if fixture['body'].get('tax_rates') is not None and isinstance(fixture['body'].get('tax_rates'), (dict, list)): + body = fixture['body']['tax_rates'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.TaxRate) @@ -43,7 +45,6 @@ def test_timeout_tax_rates_list_retries(): response = helpers.client.tax_rates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['tax_rates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.TaxRate) @@ -57,7 +58,6 @@ def test_502_tax_rates_list_retries(): response = helpers.client.tax_rates.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['tax_rates'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.TaxRate) @@ -83,15 +83,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['tax_rates']) * 2 for record in all_records: assert isinstance(record, resources.TaxRate) - - @responses.activate def test_tax_rates_get(): fixture = helpers.load_fixture('tax_rates')['get'] helpers.stub_response(fixture) response = helpers.client.tax_rates.get(*fixture['url_params']) - body = fixture['body']['tax_rates'] + if fixture['body'].get('tax_rates') is not None and isinstance(fixture['body'].get('tax_rates'), (dict, list)): + body = fixture['body']['tax_rates'] + else: + body = fixture['body'] assert isinstance(response, resources.TaxRate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -109,7 +110,6 @@ def test_timeout_tax_rates_get_retries(): response = helpers.client.tax_rates.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['tax_rates'] assert isinstance(response, resources.TaxRate) @@ -119,7 +119,5 @@ def test_502_tax_rates_get_retries(): response = helpers.client.tax_rates.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['tax_rates'] assert isinstance(response, resources.TaxRate) - diff --git a/tests/integration/transferred_mandates_integration_test.py b/tests/integration/transferred_mandates_integration_test.py index 56facbb7..572af845 100644 --- a/tests/integration/transferred_mandates_integration_test.py +++ b/tests/integration/transferred_mandates_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_transferred_mandates_transferred_mandates(): fixture = helpers.load_fixture('transferred_mandates')['transferred_mandates'] helpers.stub_response(fixture) response = helpers.client.transferred_mandates.transferred_mandates(*fixture['url_params']) - body = fixture['body']['transferred_mandates'] + if fixture['body'].get('transferred_mandates') is not None and isinstance(fixture['body'].get('transferred_mandates'), (dict, list)): + body = fixture['body']['transferred_mandates'] + else: + body = fixture['body'] assert isinstance(response, resources.TransferredMandate) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -44,4 +46,3 @@ def test_502_transferred_mandates_transferred_mandates_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.transferred_mandates.transferred_mandates(*fixture['url_params']) assert len(rsps.calls) == 1 - diff --git a/tests/integration/verification_details_integration_test.py b/tests/integration/verification_details_integration_test.py index a24fffa7..86c8a084 100644 --- a/tests/integration/verification_details_integration_test.py +++ b/tests/integration/verification_details_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_verification_details_create(): fixture = helpers.load_fixture('verification_details')['create'] helpers.stub_response(fixture) response = helpers.client.verification_details.create(*fixture['url_params']) - body = fixture['body']['verification_details'] + if fixture['body'].get('verification_details') is not None and isinstance(fixture['body'].get('verification_details'), (dict, list)): + body = fixture['body']['verification_details'] + else: + body = fixture['body'] assert isinstance(response, resources.VerificationDetail) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -43,7 +45,6 @@ def test_timeout_verification_details_create_retries(): response = helpers.client.verification_details.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['verification_details'] assert isinstance(response, resources.VerificationDetail) @@ -53,17 +54,18 @@ def test_502_verification_details_create_retries(): response = helpers.client.verification_details.create(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['verification_details'] assert isinstance(response, resources.VerificationDetail) - @responses.activate def test_verification_details_list(): fixture = helpers.load_fixture('verification_details')['list'] helpers.stub_response(fixture) response = helpers.client.verification_details.list(*fixture['url_params']) - body = fixture['body']['verification_details'] + if fixture['body'].get('verification_details') is not None and isinstance(fixture['body'].get('verification_details'), (dict, list)): + body = fixture['body']['verification_details'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.VerificationDetail) @@ -88,7 +90,6 @@ def test_timeout_verification_details_list_retries(): response = helpers.client.verification_details.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['verification_details'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.VerificationDetail) @@ -102,7 +103,6 @@ def test_502_verification_details_list_retries(): response = helpers.client.verification_details.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['verification_details'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.VerificationDetail) @@ -128,5 +128,3 @@ def callback(request): assert len(all_records) == len(fixture['body']['verification_details']) * 2 for record in all_records: assert isinstance(record, resources.VerificationDetail) - - diff --git a/tests/integration/webhooks_integration_test.py b/tests/integration/webhooks_integration_test.py index 7593bab6..a2dadef5 100644 --- a/tests/integration/webhooks_integration_test.py +++ b/tests/integration/webhooks_integration_test.py @@ -14,14 +14,16 @@ from gocardless_pro import list_response from .. import helpers - @responses.activate def test_webhooks_list(): fixture = helpers.load_fixture('webhooks')['list'] helpers.stub_response(fixture) response = helpers.client.webhooks.list(*fixture['url_params']) - body = fixture['body']['webhooks'] + if fixture['body'].get('webhooks') is not None and isinstance(fixture['body'].get('webhooks'), (dict, list)): + body = fixture['body']['webhooks'] + else: + body = fixture['body'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Webhook) @@ -50,7 +52,6 @@ def test_timeout_webhooks_list_retries(): response = helpers.client.webhooks.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['webhooks'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Webhook) @@ -64,7 +65,6 @@ def test_502_webhooks_list_retries(): response = helpers.client.webhooks.list(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['webhooks'] assert isinstance(response, list_response.ListResponse) assert isinstance(response.records[0], resources.Webhook) @@ -90,15 +90,16 @@ def callback(request): assert len(all_records) == len(fixture['body']['webhooks']) * 2 for record in all_records: assert isinstance(record, resources.Webhook) - - @responses.activate def test_webhooks_get(): fixture = helpers.load_fixture('webhooks')['get'] helpers.stub_response(fixture) response = helpers.client.webhooks.get(*fixture['url_params']) - body = fixture['body']['webhooks'] + if fixture['body'].get('webhooks') is not None and isinstance(fixture['body'].get('webhooks'), (dict, list)): + body = fixture['body']['webhooks'] + else: + body = fixture['body'] assert isinstance(response, resources.Webhook) assert responses.calls[-1].request.headers.get('Idempotency-Key') is None @@ -123,7 +124,6 @@ def test_timeout_webhooks_get_retries(): response = helpers.client.webhooks.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['webhooks'] assert isinstance(response, resources.Webhook) @@ -133,17 +133,18 @@ def test_502_webhooks_get_retries(): response = helpers.client.webhooks.get(*fixture['url_params']) assert len(rsps.calls) == 2 assert rsps.calls[0].request.headers.get('Idempotency-Key') == rsps.calls[1].request.headers.get('Idempotency-Key') - body = fixture['body']['webhooks'] assert isinstance(response, resources.Webhook) - @responses.activate def test_webhooks_retry(): fixture = helpers.load_fixture('webhooks')['retry'] helpers.stub_response(fixture) response = helpers.client.webhooks.retry(*fixture['url_params']) - body = fixture['body']['webhooks'] + if fixture['body'].get('webhooks') is not None and isinstance(fixture['body'].get('webhooks'), (dict, list)): + body = fixture['body']['webhooks'] + else: + body = fixture['body'] assert isinstance(response, resources.Webhook) assert responses.calls[-1].request.headers.get('Idempotency-Key') is not None @@ -174,4 +175,3 @@ def test_502_webhooks_retry_doesnt_retry(): with pytest.raises(MalformedResponseError): response = helpers.client.webhooks.retry(*fixture['url_params']) assert len(rsps.calls) == 1 -