@@ 6-77 (lines=72) @@ | ||
3 | from paystackapi.base import PayStackBase |
|
4 | ||
5 | ||
6 | class Plan(PayStackBase): |
|
7 | """docstring for Plan.""" |
|
8 | ||
9 | @classmethod |
|
10 | def create(cls, **kwargs): |
|
11 | """ |
|
12 | Function defined to create a plan. |
|
13 | ||
14 | Args: |
|
15 | name: plan's name. |
|
16 | description: description of the plan. |
|
17 | amount: amount for the plan in kobo |
|
18 | interval: plan's interval |
|
19 | send_invoices: boolean |
|
20 | send_sms: |
|
21 | hosted_page: |
|
22 | hosted_page_url: url of hosted page |
|
23 | hosted_page_summary: summary of the hosted page |
|
24 | currency: plans currency |
|
25 | ||
26 | Returns: |
|
27 | Json data from paystack API. |
|
28 | """ |
|
29 | return cls().requests.post('plan', data=kwargs) |
|
30 | ||
31 | @classmethod |
|
32 | def get(cls, plan_id): |
|
33 | """ |
|
34 | Get a single plan. |
|
35 | ||
36 | Args: |
|
37 | plan_id: paystack plan id. |
|
38 | ||
39 | Returns: |
|
40 | Json data from paystack API. |
|
41 | """ |
|
42 | return cls().requests.get('plan/{plan_id}'.format(**locals())) |
|
43 | ||
44 | @classmethod |
|
45 | def list(cls): |
|
46 | """ |
|
47 | Static method defined to list paystack plan. |
|
48 | ||
49 | Args: |
|
50 | No argument required. |
|
51 | Returns: |
|
52 | Json data from paystack API. |
|
53 | """ |
|
54 | return cls().requests.get('plan') |
|
55 | ||
56 | @classmethod |
|
57 | def update(cls, plan_id, **kwargs): |
|
58 | """ |
|
59 | Static method defined to update paystack plan. |
|
60 | ||
61 | Args: |
|
62 | plan_id: plan identity number. |
|
63 | name: name of plan |
|
64 | description: plan description(optional) |
|
65 | amount: plan amount in Naira |
|
66 | interval: plan interval |
|
67 | send_invoice: |
|
68 | send_sms: (optional) |
|
69 | hosted_page: (optional) |
|
70 | hosted_page_url: (optional) |
|
71 | hosted_page_summary: (optional) |
|
72 | currency: Naira |
|
73 | Returns: |
|
74 | Json data from paystack API. |
|
75 | """ |
|
76 | return cls().requests.put('plan/{plan_id}'.format(**locals()), |
|
77 | data=kwargs) |
|
78 |
@@ 6-65 (lines=60) @@ | ||
3 | from paystackapi.base import PayStackBase |
|
4 | ||
5 | ||
6 | class Customer(PayStackBase): |
|
7 | """docstring for Customer.""" |
|
8 | ||
9 | @classmethod |
|
10 | def create(cls, **kwargs): |
|
11 | """ |
|
12 | Function defined to create customer. |
|
13 | ||
14 | Args: |
|
15 | first_name: customer's first name. |
|
16 | last_name: customer's last name. |
|
17 | email: customer's email address. |
|
18 | phone:customer's phone number. |
|
19 | ||
20 | Returns: |
|
21 | Json data from paystack API. |
|
22 | """ |
|
23 | return cls().requests.post('customer', data=kwargs,) |
|
24 | ||
25 | @classmethod |
|
26 | def get(cls, customer_id): |
|
27 | """ |
|
28 | Static method defined to get customers by id. |
|
29 | ||
30 | Args: |
|
31 | customer_id: paystack customer id. |
|
32 | Returns: |
|
33 | Json data from paystack API. |
|
34 | """ |
|
35 | return cls().requests.get('customer/{customer_id}'.format(**locals())) |
|
36 | ||
37 | @classmethod |
|
38 | def list(cls): |
|
39 | """ |
|
40 | Static method defined to list paystack customers. |
|
41 | ||
42 | Args: |
|
43 | No argument required. |
|
44 | Returns: |
|
45 | Json data from paystack API. |
|
46 | """ |
|
47 | return cls().requests.get('customer') |
|
48 | ||
49 | @classmethod |
|
50 | def update(cls, customer_id, **kwargs): |
|
51 | """ |
|
52 | Static method defined to update paystack customer data by id. |
|
53 | ||
54 | Args: |
|
55 | customer_id: paystack customer id. |
|
56 | first_name: customer's first name(optional). |
|
57 | last_name: customer's last name(optional). |
|
58 | email: customer's email address(optional). |
|
59 | phone:customer's phone number(optional). |
|
60 | ||
61 | Returns: |
|
62 | Json data from paystack API. |
|
63 | """ |
|
64 | return cls().requests.put('customer/{customer_id}'.format(**locals()), |
|
65 | data=kwargs) |
|
66 |