forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomer.py
More file actions
64 lines (51 loc) · 1.71 KB
/
customer.py
File metadata and controls
64 lines (51 loc) · 1.71 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
"""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):
"""
Static method defined to list paystack customers.
Args:
No argument required.
Returns:
Json data from paystack API.
"""
return cls().requests.get('customer')
@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,)