Skip to content

Commit fedf874

Browse files
authored
Merge pull request #111 from gocardless/template-changes
Changes from gocardless/gocardless-pro-python-template
2 parents 2df6238 + 079d23e commit fedf874

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+394
-97
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ Billing request templates
189189
# Update a Billing Request Template
190190
client.billing_request_templates.update('BRQ123', params={...})
191191
192+
Billing request with actions
193+
''''''''''''''''''''''''''''''''''''''''''
194+
195+
.. code:: python
196+
197+
# Create a Billing Request with Actions
198+
client.billing_request_with_actions.create_with_actions(params={...})
199+
192200
Blocks
193201
''''''''''''''''''''''''''''''''''''''''''
194202

gocardless_pro/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
from .client import Client
44

5-
__version__ = '2.7.0'
5+
__version__ = '2.8.0'
66

gocardless_pro/api_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _default_headers(self):
150150
'Authorization': 'Bearer {0}'.format(self.access_token),
151151
'Content-Type': 'application/json',
152152
'GoCardless-Client-Library': 'gocardless-pro-python',
153-
'GoCardless-Client-Version': '2.7.0',
153+
'GoCardless-Client-Version': '2.8.0',
154154
'User-Agent': self._user_agent(),
155155
'GoCardless-Version': '2015-07-06',
156156
}
@@ -159,7 +159,7 @@ def _user_agent(self):
159159
python_version = '.'.join(platform.python_version_tuple()[0:2])
160160
vm_version = '{}.{}.{}-{}{}'.format(*sys.version_info)
161161
return ' '.join([
162-
'gocardless-pro-python/2.7.0',
162+
'gocardless-pro-python/2.8.0',
163163
'python/{0}'.format(python_version),
164164
'{0}/{1}'.format(platform.python_implementation(), vm_version),
165165
'{0}/{1}'.format(platform.system(), platform.release()),

gocardless_pro/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def billing_request_flows(self):
6565
def billing_request_templates(self):
6666
return services.BillingRequestTemplatesService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
6767

68+
@property
69+
def billing_request_with_actions(self):
70+
return services.BillingRequestWithActionsService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)
71+
6872
@property
6973
def blocks(self):
7074
return services.BlocksService(self._api_client, 3, 0.5, self._raise_on_idempotency_conflict)

gocardless_pro/resources/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
from .billing_request_template import BillingRequestTemplate
1919

20+
from .billing_request_with_action import BillingRequestWithAction
21+
2022
from .block import Block
2123

2224
from .creditor import Creditor
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# WARNING: Do not edit by hand, this file was generated by Crank:
2+
#
3+
# https://github.com/gocardless/crank
4+
#
5+
6+
class BillingRequestWithAction(object):
7+
"""A thin wrapper around a billing_request_with_action, providing easy access to its
8+
attributes.
9+
10+
Example:
11+
billing_request_with_action = client.billing_request_with_actions.get()
12+
billing_request_with_action.id
13+
"""
14+
15+
def __init__(self, attributes, api_response):
16+
self.attributes = attributes
17+
self.api_response = api_response
18+
19+
@property
20+
def bank_authorisations(self):
21+
return self.BankAuthorisations(self.attributes.get('bank_authorisations'))
22+
23+
24+
@property
25+
def billing_requests(self):
26+
return self.BillingRequests(self.attributes.get('billing_requests'))
27+
28+
29+
30+
31+
class BankAuthorisations(object):
32+
"""Wrapper for the response's 'bank_authorisations' attribute."""
33+
34+
def __init__(self, attributes):
35+
self.attributes = attributes
36+
37+
@property
38+
def authorisation_type(self):
39+
return self.attributes.get('authorisation_type')
40+
41+
@property
42+
def authorised_at(self):
43+
return self.attributes.get('authorised_at')
44+
45+
@property
46+
def created_at(self):
47+
return self.attributes.get('created_at')
48+
49+
@property
50+
def expires_at(self):
51+
return self.attributes.get('expires_at')
52+
53+
@property
54+
def id(self):
55+
return self.attributes.get('id')
56+
57+
@property
58+
def last_visited_at(self):
59+
return self.attributes.get('last_visited_at')
60+
61+
@property
62+
def links(self):
63+
return self.attributes.get('links')
64+
65+
@property
66+
def qr_code_url(self):
67+
return self.attributes.get('qr_code_url')
68+
69+
@property
70+
def redirect_uri(self):
71+
return self.attributes.get('redirect_uri')
72+
73+
@property
74+
def url(self):
75+
return self.attributes.get('url')
76+
77+
78+
79+
80+
class BillingRequests(object):
81+
"""Wrapper for the response's 'billing_requests' attribute."""
82+
83+
def __init__(self, attributes):
84+
self.attributes = attributes
85+
86+
@property
87+
def actions(self):
88+
return self.attributes.get('actions')
89+
90+
@property
91+
def created_at(self):
92+
return self.attributes.get('created_at')
93+
94+
@property
95+
def fallback_enabled(self):
96+
return self.attributes.get('fallback_enabled')
97+
98+
@property
99+
def fallback_occurred(self):
100+
return self.attributes.get('fallback_occurred')
101+
102+
@property
103+
def id(self):
104+
return self.attributes.get('id')
105+
106+
@property
107+
def instalment_schedule_request(self):
108+
return self.attributes.get('instalment_schedule_request')
109+
110+
@property
111+
def links(self):
112+
return self.attributes.get('links')
113+
114+
@property
115+
def mandate_request(self):
116+
return self.attributes.get('mandate_request')
117+
118+
@property
119+
def metadata(self):
120+
return self.attributes.get('metadata')
121+
122+
@property
123+
def payment_request(self):
124+
return self.attributes.get('payment_request')
125+
126+
@property
127+
def purpose_code(self):
128+
return self.attributes.get('purpose_code')
129+
130+
@property
131+
def resources(self):
132+
return self.attributes.get('resources')
133+
134+
@property
135+
def status(self):
136+
return self.attributes.get('status')
137+
138+
@property
139+
def subscription_request(self):
140+
return self.attributes.get('subscription_request')
141+
142+
143+

gocardless_pro/resources/outbound_payment.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def created_at(self):
2626
return self.attributes.get('created_at')
2727

2828

29+
@property
30+
def currency(self):
31+
return self.attributes.get('currency')
32+
33+
2934
@property
3035
def description(self):
3136
return self.attributes.get('description')
@@ -90,6 +95,8 @@ def verifications(self):
9095

9196

9297

98+
99+
93100
class Links(object):
94101
"""Wrapper for the response's 'links' attribute."""
95102

gocardless_pro/services/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .billing_requests_service import BillingRequestsService
1111
from .billing_request_flows_service import BillingRequestFlowsService
1212
from .billing_request_templates_service import BillingRequestTemplatesService
13+
from .billing_request_with_actions_service import BillingRequestWithActionsService
1314
from .blocks_service import BlocksService
1415
from .creditors_service import CreditorsService
1516
from .creditor_bank_accounts_service import CreditorBankAccountsService
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# WARNING: Do not edit by hand, this file was generated by Crank:
2+
#
3+
# https://github.com/gocardless/crank
4+
#
5+
6+
from . import base_service
7+
from .. import resources
8+
from ..paginator import Paginator
9+
from .. import errors
10+
11+
class BillingRequestWithActionsService(base_service.BaseService):
12+
"""Service class that provides access to the billing_request_with_actions
13+
endpoints of the GoCardless Pro API.
14+
"""
15+
16+
RESOURCE_CLASS = resources.BillingRequestWithAction
17+
RESOURCE_NAME = 'billing_request_with_actions'
18+
19+
20+
def create_with_actions(self,params=None, headers=None):
21+
"""Create a Billing Request with Actions.
22+
23+
Creates a billing request and completes any specified actions in a
24+
single request.
25+
This endpoint allows you to create a billing request and immediately
26+
complete actions
27+
such as collecting customer details, bank account details, or other
28+
required actions.
29+
30+
Args:
31+
params (dict, optional): Request body.
32+
33+
Returns:
34+
BillingRequestWithAction
35+
"""
36+
path = '/billing_requests/create_with_actions'
37+
38+
if params is not None:
39+
params = {self._envelope_key(): params}
40+
41+
response = self._perform_request('POST', path, params, headers,
42+
retry_failures=True)
43+
return self._resource_for(response)
44+

gocardless_pro/services/refunds_service.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ def create(self,params=None, headers=None):
3131
is there to prevent two processes from creating refunds without
3232
awareness of each other.
3333
34-
- `number_of_refunds_exceeded` if twenty five or more refunds have
35-
already been created against the payment.
36-
3734
- `available_refund_amount_insufficient` if the creditor does not have
3835
sufficient balance for refunds available to cover the cost of the
3936
requested refund.

0 commit comments

Comments
 (0)