1 | """Script used to define the paystack Plan class.""" |
||
2 | |||
3 | from paystackapi.base import PayStackBase |
||
4 | |||
5 | |||
6 | View Code Duplication | class Plan(PayStackBase): |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
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 |