forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubaccount.py
More file actions
69 lines (54 loc) · 1.92 KB
/
subaccount.py
File metadata and controls
69 lines (54 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Script used to define the paystack Subaccount class."""
from paystackapi.base import PayStackBase
class SubAccount(PayStackBase):
"""docstring for SubAccount."""
@classmethod
def create(cls, **kwargs):
"""
Function defined to create subaccount.
Args:
business_name: name of business for subaccount
settlement_bank: name of Bank (accepted banks)
account_number: NUBAN Bank Account number
percentage_charge: default percentage charged on subaccount?
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.post('subaccount', data=kwargs,)
@classmethod
def list(cls, **kwargs):
"""
List subaccounts
Args:
perPage: records you want to retrieve per page (Integer)
page: what page you want to retrieve (Integer)
Returns:
JSON data from paystack's API.
"""
return cls().requests.get("subaccount", qs=kwargs,)
@classmethod
def fetch(cls, id_or_slug):
"""
Get a single subaccount by id or slug.
Args:
id_or_slug: id or subaccount_code
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"subaccount/{id_or_slug}")
@classmethod
def update(cls, id_or_slug, **kwargs):
"""
Update a single subaccount by id or slug.
Args:
id_or_slug: id or subaccount_code
business_name: name of business for subaccount
settlement_bank: name of Bank (accepted banks)
account_number: NUBAN Bank Account number
percentage_charge: default percentage charged on subaccount?
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"subaccount/{id_or_slug}", data=kwargs,)