forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.py
More file actions
89 lines (68 loc) · 2.09 KB
/
page.py
File metadata and controls
89 lines (68 loc) · 2.09 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
77
78
79
80
81
82
83
84
85
86
87
88
89
"""Script used to define the paystack Page class."""
from paystackapi.base import PayStackBase
class Page(PayStackBase):
"""docstring for Page."""
@classmethod
def create(cls, **kwargs):
"""
method defined to create a new page.
Args:
name: name of page
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.post('page', data=kwargs,)
@classmethod
def list(cls, **kwargs):
"""
List pages
Args:
perPage: records you want to retrieve per page (Integer)
page: what page you want to retrieve (Integer)
Returns:
JSON data from paystack's API.
"""
return cls().requests.get("page", qs=kwargs)
@classmethod
def fetch(cls, id_or_slug):
"""
Get a single page by id or slug.
Args:
id_or_slug: id or slug
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"page/{id_or_slug}")
@classmethod
def update(cls, id_or_slug, **kwargs):
"""
Update a single page by id or slug.
Args:
id_or_slug: id or slug
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"page/{id_or_slug}", data=kwargs,)
@classmethod
def is_slug_available(cls, slug):
"""
Check if a slug is available.
Args:
slug: URL slug to be confirmed
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"page/check_slug_availability/{slug}")
@classmethod
def add_products(cls, payment_page_id, **kwargs):
"""
Add products to page
Args:
payment_page_id: Id of the payment page (Integer)
product: Ids of all the products i.e. [473, 292]
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"page/{payment_page_id}/product", data=kwargs,)