forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct.py
More file actions
68 lines (53 loc) · 1.69 KB
/
product.py
File metadata and controls
68 lines (53 loc) · 1.69 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
"""Script used to define the paystack Product class."""
from paystackapi.base import PayStackBase
class Product(PayStackBase):
"""docstring for Product."""
@classmethod
def create(cls, **kwargs):
"""
Function defined to create product.
Args:
name: name of the product
description: description of product
price: price of the product, in kobo(Integer)
currency: currency in which amount should be charged
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.post('product', data=kwargs,)
@classmethod
def list(cls):
"""
List Products.
Args:
No argument required.
Returns:
Json data from paystack API.
"""
return cls().requests.get('product')
@classmethod
def fetch(cls, product_id):
"""
Get a single product by id.
Args:
product_id: Product id(integer).
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"product/{product_id}")
@classmethod
def update(cls, product_id, **kwargs):
"""
Static method defined to update product by id.
Args:
product_id: paystack product id.
name: name of the product
description: description of product
price: price of the product, in kobo(Integer)
currency: currency in which amount should be charged
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.put(f"product/{product_id}", data=kwargs,)