forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplan.py
More file actions
76 lines (63 loc) · 1.96 KB
/
plan.py
File metadata and controls
76 lines (63 loc) · 1.96 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
76
"""Script used to define the paystack Plan class."""
from paystackapi.base import PayStackBase
class Plan(PayStackBase):
"""docstring for Plan."""
@classmethod
def create(cls, **kwargs):
"""
Function defined to create a plan.
Args:
name: plan's name.
description: description of the plan.
amount: amount for the plan in kobo
interval: plan's interval
send_invoices: boolean
send_sms:
hosted_page:
hosted_page_url: url of hosted page
hosted_page_summary: summary of the hosted page
currency: plans currency
Returns:
Json data from paystack API.
"""
return cls().requests.post('plan', data=kwargs)
@classmethod
def get(cls, plan_id):
"""
Get a single plan.
Args:
plan_id: paystack plan id.
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"plan/{plan_id}")
@classmethod
def list(cls):
"""
Static method defined to list paystack plan.
Args:
No argument required.
Returns:
Json data from paystack API.
"""
return cls().requests.get('plan')
@classmethod
def update(cls, plan_id, **kwargs):
"""
Static method defined to update paystack plan.
Args:
plan_id: plan identity number.
name: name of plan
description: plan description(optional)
amount: plan amount in Naira
interval: plan interval
send_invoice:
send_sms: (optional)
hosted_page: (optional)
hosted_page_url: (optional)
hosted_page_summary: (optional)
currency: Naira
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"plan/{plan_id}", data=kwargs,)