Repository navigation
Expand file tree
/
Copy pathcustomer.py
More file actions
75 lines (58 loc) · 2.23 KB
/
Copy pathcustomer.py
File metadata and controls
75 lines (58 loc) · 2.23 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
70
71
72
73
74
75
"""Script used to define the paystack Customer class."""
from paystackapi.base import PayStackBase
class Customer(PayStackBase):
"""docstring for Customer."""
@classmethod
def create(cls, **kwargs):
"""
Function defined to create customer.
Args:
first_name: customer's first name.
last_name: customer's last name.
email: customer's email address.
phone:customer's phone number.
Returns:
Json data from paystack API.
"""
return cls().requests.post('customer', data=kwargs,)
@classmethod
def get(cls, customer_id):
"""
Static method defined to get customers by id.
Args:
customer_id: paystack customer id.
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"customer/{customer_id}")
@classmethod
def list(cls, **kwargs):
"""
Static method defined to list paystack customers.
Args:
perPage: Specify how many records you want to retrieve per page.
If not specify we use a default value of 50. (Integer)
page: Specify exactly what page you want to retrieve.
defaults to 1 if not present(Integer)
from: A timestamp from which to start listing customers
e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime)
to: A timestamp at which to stop listing customers
e.g. 2016-09-24T00:00:05.000Z, 2016-09-21 (datetime)
Returns:
Json data from paystack API.
"""
return cls().requests.get('customer', qs=kwargs,)
@classmethod
def update(cls, customer_id, **kwargs):
"""
Static method defined to update paystack customer data by id.
Args:
customer_id: paystack customer id.
first_name: customer's first name(optional).
last_name: customer's last name(optional).
email: customer's email address(optional).
phone:customer's phone number(optional).
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"customer/{customer_id}", data=kwargs,)