Skip to content
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<!-- @format -->

# 3.4.0

- **Bug Fixes:**
- Fixed `JSONDecodeError` when calling endpoints that return `204 No Content` responses (e.g. `customers.remove()`) - fixes [#96](https://github.com/gocardless/gocardless-pro-python/issues/96)
- Fixed pagination cursor handling that was raising `KeyError` on endpoints without cursors (e.g. `institutions.list_for_billing_request`)
- Fixed POST/PUT request body envelope wrapping to use schema-defined envelopes instead of inferred ones
- Fixed invalid Python 3 syntax that was causing compatibility issues
- Improved error messages by including HTTP status code in malformed response errors

- **Breaking Changes:**
- Removed Python 2 compatibility shim (Python 2 has been EOL for 6+ years, and this library already uses Python 3-only features like f-strings)
- Removed unused `six` dependency (was never actually imported in the codebase)
- Documented minimum Python version as 3.10

- **Improvements:**
- README cleanup and documentation updates
- Added missing tests for paginator

# 3.1.0
- Added `mandate_request_constraints` to Billing Request templates
- `constraints[max_amount_per_payment]` is required for Billing Requests Creation, if they contain PayTo `mandate_request`
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.. |pypi-badge| image:: https://badge.fury.io/py/gocardless_pro.svg
:target: https://pypi.python.org/pypi/gocardless_pro

GoCardless Pro Python client library
GoCardless Python client library
============================================

A Python client for interacting with the GoCardless Pro API.
A Python client for interacting with the GoCardless API.

|pypi-badge|

Expand Down Expand Up @@ -62,10 +62,10 @@ Rate limit response headers can be read:

.. code:: python

# Note these properties will be None until you make an API request with the client
client.rate_limit.limit
client.rate_limit.remaining
client.rate_limit.reset
# Note these values will be None until you make an API request with the client
client.rate_limit["ratelimit-limit"]
client.rate_limit["ratelimit-remaining"]
client.rate_limit["ratelimit-reset"]


For full documentation, see our `API reference`_.
Expand Down
4 changes: 2 additions & 2 deletions gocardless_pro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A client library for the GoCardless Pro API."""
"""A client library for the GoCardless API."""

from .client import Client

__version__ = '3.3.0'
__version__ = '3.4.0'

4 changes: 2 additions & 2 deletions gocardless_pro/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _default_headers(self):
'Authorization': 'Bearer {0}'.format(self.access_token),
'Content-Type': 'application/json',
'GoCardless-Client-Library': 'gocardless-pro-python',
'GoCardless-Client-Version': '3.3.0',
'GoCardless-Client-Version': '3.4.0',
'User-Agent': self._user_agent(),
'GoCardless-Version': '2015-07-06',
}
Expand All @@ -181,7 +181,7 @@ def _user_agent(self):
python_version = '.'.join(platform.python_version_tuple()[0:2])
vm_version = '{}.{}.{}-{}{}'.format(*sys.version_info)
return ' '.join([
'gocardless-pro-python/3.3.0',
'gocardless-pro-python/3.4.0',
'python/{0}'.format(python_version),
'{0}/{1}'.format(platform.python_implementation(), vm_version),
'{0}/{1}'.format(platform.system(), platform.release()),
Expand Down
5 changes: 4 additions & 1 deletion gocardless_pro/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

class ApiResponse(object):
"""Response from the {{ .Config.api_name }} API, providing access
"""Response from the GoCardless API, providing access
to the status code, headers, and body.
"""

Expand All @@ -21,5 +21,8 @@ def headers(self):

@property
def body(self):
# Handle 204 No Content and other empty responses
if not self._response.content:
return {}
return self._response.json()

4 changes: 2 additions & 2 deletions gocardless_pro/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .api_client import ApiClient

class Client(object):
"""Client for interacting with the GoCardless Pro API.
"""Client for interacting with the GoCardless API.

Instantiate a client object with your access token and environment, then
use the resource methods to access the API.
Expand All @@ -23,7 +23,7 @@ class Client(object):
Example:
client = Client(access_token=ACCESS_TOKEN, environment='sandbox')
for customer in client.customers.list():
print '{} {}'.format(customer.family_name, customer.given_name)
print('{} {}'.format(customer.family_name, customer.given_name))
"""

def __init__(self, access_token=None, environment=None, base_url=None, raise_on_idempotency_conflict=False):
Expand Down
6 changes: 4 additions & 2 deletions gocardless_pro/list_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ def __init__(self, records, api_response):

@property
def before(self):
return self.api_response.body['meta']['cursors']['before']
cursors = (self.api_response.body.get('meta') or {}).get('cursors') or {}
return cursors.get('before')

@property
def after(self):
return self.api_response.body['meta']['cursors']['after']
cursors = (self.api_response.body.get('meta') or {}).get('cursors') or {}
return cursors.get('after')
7 changes: 7 additions & 0 deletions gocardless_pro/resources/customer_bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def metadata(self):
return self.attributes.get('metadata')


@property
def trusted_recipient(self):
return self.attributes.get('trusted_recipient')





Expand Down Expand Up @@ -112,3 +117,5 @@ def customer(self):





2 changes: 1 addition & 1 deletion gocardless_pro/services/balances_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BalancesService(base_service.BaseService):
"""Service class that provides access to the balances
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Balance
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/bank_account_details_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BankAccountDetailsService(base_service.BaseService):
"""Service class that provides access to the bank_account_details
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BankAccountDetail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BankAccountHolderVerificationsService(base_service.BaseService):
"""Service class that provides access to the bank_account_holder_verifications
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BankAccountHolderVerification
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/bank_authorisations_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BankAuthorisationsService(base_service.BaseService):
"""Service class that provides access to the bank_authorisations
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BankAuthorisation
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/bank_details_lookups_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BankDetailsLookupsService(base_service.BaseService):
"""Service class that provides access to the bank_details_lookups
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BankDetailsLookup
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/billing_request_flows_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BillingRequestFlowsService(base_service.BaseService):
"""Service class that provides access to the billing_request_flows
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BillingRequestFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BillingRequestTemplatesService(base_service.BaseService):
"""Service class that provides access to the billing_request_templates
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BillingRequestTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BillingRequestWithActionsService(base_service.BaseService):
"""Service class that provides access to the billing_request_with_actions
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BillingRequestWithAction
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/billing_requests_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BillingRequestsService(base_service.BaseService):
"""Service class that provides access to the billing_requests
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.BillingRequest
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/blocks_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BlocksService(base_service.BaseService):
"""Service class that provides access to the blocks
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Block
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/creditor_bank_accounts_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CreditorBankAccountsService(base_service.BaseService):
"""Service class that provides access to the creditor_bank_accounts
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.CreditorBankAccount
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/creditors_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CreditorsService(base_service.BaseService):
"""Service class that provides access to the creditors
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Creditor
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/currency_exchange_rates_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CurrencyExchangeRatesService(base_service.BaseService):
"""Service class that provides access to the currency_exchange_rates
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.CurrencyExchangeRate
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/customer_bank_accounts_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CustomerBankAccountsService(base_service.BaseService):
"""Service class that provides access to the customer_bank_accounts
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.CustomerBankAccount
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/customer_notifications_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CustomerNotificationsService(base_service.BaseService):
"""Service class that provides access to the customer_notifications
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.CustomerNotification
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/customers_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CustomersService(base_service.BaseService):
"""Service class that provides access to the customers
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Customer
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/events_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class EventsService(base_service.BaseService):
"""Service class that provides access to the events
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Event
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/exports_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ExportsService(base_service.BaseService):
"""Service class that provides access to the exports
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Export
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/funds_availabilities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class FundsAvailabilitiesService(base_service.BaseService):
"""Service class that provides access to the funds_availabilities
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.FundsAvailability
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/instalment_schedules_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class InstalmentSchedulesService(base_service.BaseService):
"""Service class that provides access to the instalment_schedules
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.InstalmentSchedule
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/institutions_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class InstitutionsService(base_service.BaseService):
"""Service class that provides access to the institutions
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Institution
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/logos_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class LogosService(base_service.BaseService):
"""Service class that provides access to the logos
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Logo
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/mandate_import_entries_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class MandateImportEntriesService(base_service.BaseService):
"""Service class that provides access to the mandate_import_entries
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.MandateImportEntry
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/mandate_imports_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class MandateImportsService(base_service.BaseService):
"""Service class that provides access to the mandate_imports
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.MandateImport
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/mandate_pdfs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class MandatePdfsService(base_service.BaseService):
"""Service class that provides access to the mandate_pdfs
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.MandatePdf
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/mandates_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class MandatesService(base_service.BaseService):
"""Service class that provides access to the mandates
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.Mandate
Expand Down
2 changes: 1 addition & 1 deletion gocardless_pro/services/negative_balance_limits_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class NegativeBalanceLimitsService(base_service.BaseService):
"""Service class that provides access to the negative_balance_limits
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.NegativeBalanceLimit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class OutboundPaymentImportEntriesService(base_service.BaseService):
"""Service class that provides access to the outbound_payment_import_entries
endpoints of the GoCardless Pro API.
endpoints of the GoCardless API.
"""

RESOURCE_CLASS = resources.OutboundPaymentImportEntry
Expand Down
Loading
Loading