forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulkcharge.py
More file actions
100 lines (75 loc) · 2.73 KB
/
bulkcharge.py
File metadata and controls
100 lines (75 loc) · 2.73 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
90
91
92
93
94
95
96
97
98
99
100
"""Script used to define the paystack BulkCharge class."""
from paystackapi.base import PayStackBase
class BulkCharge(PayStackBase):
@classmethod
def initiate_bulk_charge(cls, bulkcharge):
"""
Initiate Bulk Charge.
{
"type": "array",
"description": "",
"format": ""
}
Args:
authorization: Authorization token
amount: Amount in kobo
Returns:
Json data from paystack API.
"""
return cls().requests.post('bulkcharge', data=bulkcharge)
@classmethod
def list(cls, **kwargs):
"""
List Bulk Charge Batches created by the integration.
Args:
perPage: Number of transfer listed per page for pagination
page: number of pages listed by pagination.
Returns:
Json data from paystack API.
"""
return cls().requests.get('bulkcharge', qs=kwargs,)
@classmethod
def fetch_bulk_batch(cls, id_or_code):
""" This endpoint retrieves a specific batch code.
It also returns useful information on its progress
by way of the total_charges and pending_charges attributes.
Args:
id_or_code: An ID or code for the transfer whose
details you want to retrieve.
Returns:
Json data from paystack API
"""
return cls().requests.get(f"bulkcharge/{id_or_code}")
@classmethod
def fetch_charges_batch(cls, id_or_code, **kwargs):
"""
Fetch the charges associated with a specified batch code.
Args:
id_or_code: An ID or code for the batch whose charges you want to retrieve.
status: pending, success or failed
perPage: Number of transfers listed per page for pagination
page: number of pages listed by pagination.
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"bulkcharge/{id_or_code}/charges", qs=kwargs)
@classmethod
def pause_bulk_batch(cls, batch_code):
"""
Pause the proccessing of an ongoing bulk charge batch.
Args:
batch_code: code of the batch to be paused
Returns:
Json data from the Paystack API.
"""
return cls().requests.get(f"bulkcharge/pause/{batch_code}")
@classmethod
def resume_bulk_charge(cls, batch_code):
"""
Resume the proccessing of an already paused bulk charge batch.
Args:
batch_code: code of the batch to be resumed
Returns:
Json data from the Paystack API.
"""
return cls().requests.get(f"bulkcharge/resume/{batch_code}")