Skip to content

Commit df0efc0

Browse files
Merge pull request #25 from payjp/nyamanaka/add_balance_statement_url
add balance statement URL
2 parents 916c07e + 00bb1cb commit df0efc0

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

payjp/resource.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,4 +436,16 @@ class Term(ListableAPIResource):
436436

437437

438438
class Balance(ListableAPIResource):
439-
pass
439+
def __init__(self, *args, **kwargs):
440+
super().__init__(*args, **kwargs)
441+
object.__setattr__(self, 'statement_urls', self.__statement_urls)
442+
443+
def __statement_urls(self, *args, **kwargs):
444+
return self.__class__.statement_urls(self.get('id'), *args, **kwargs)
445+
446+
@classmethod
447+
def statement_urls(cls, id, api_key=None, payjp_account=None, api_base=None, **params):
448+
requestor = api_requestor.APIRequestor(api_key, account=payjp_account, api_base=api_base)
449+
url = cls.class_url() + f'/{id}/statement_urls'
450+
response, api_key = requestor.request('post', url, params)
451+
return convert_to_payjp_object(response, api_key, payjp_account, api_base)

payjp/test/test_resources.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,21 @@ def test_retrieve_balance(self):
12101210
None
12111211
)
12121212

1213+
def test_statement_urls(self):
1214+
payjp.Balance.statement_urls('ba_xxx')
1215+
self.requestor_mock.request.assert_called_with(
1216+
'post',
1217+
'/v1/balances/ba_xxx/statement_urls',
1218+
{},
1219+
)
1220+
1221+
balance = payjp.Balance.retrieve('ba_xxx')
1222+
balance.statement_urls()
1223+
self.requestor_mock.request.assert_called_with(
1224+
'post',
1225+
'/v1/balances/ba_xxx/statement_urls',
1226+
{},
1227+
)
12131228

12141229
if __name__ == '__main__':
12151230
unittest.main()

payjp/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '0.4.0'
1+
VERSION = '0.4.1'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setup(
1616
name="payjp",
17-
version="0.4.0",
17+
version="0.4.1",
1818
description='PAY.JP python bindings',
1919
author="PAY.JP",
2020
author_email='support@pay.jp',

0 commit comments

Comments
 (0)