|
1 | 1 | import requests |
2 | 2 | import logging |
3 | 3 |
|
4 | | -from datetime import datetime |
| 4 | +from python_soofa import Transaction |
5 | 5 |
|
6 | | -__all__ = ["Transaction", "Soofa"] |
| 6 | +__all__ = ["Soofa"] |
7 | 7 |
|
8 | 8 | logging.basicConfig(format='%(levelname)s - %(asctime)s - %(message)s', level=logging.INFO) |
9 | 9 |
|
10 | 10 |
|
11 | | -class Transaction(object): |
12 | | - def __init__(self, status, sender_currency, receiver_currency, tid, reference, sender, receiver, |
13 | | - receipt_no, timestamp, gross_amount, net_amount, transacted_via, is_money_in, **kwargs): |
14 | | - self.sender = sender |
15 | | - self.sender_currency = sender_currency |
16 | | - self.status = status |
17 | | - self.receiver_currency = receiver_currency |
18 | | - self.tid = tid |
19 | | - self.reference = reference |
20 | | - self.receiver = receiver |
21 | | - self.receipt_no = receipt_no |
22 | | - self.timestamp = timestamp |
23 | | - self.gross_amount = gross_amount |
24 | | - self.net_amount = net_amount |
25 | | - self.transacted_via = transacted_via |
26 | | - self.is_money_in=is_money_in |
27 | | - |
28 | | - def json(self): |
29 | | - return { |
30 | | - "status": self.status, |
31 | | - "sender_currency": self.sender_currency, |
32 | | - "receiver_currency": self.receiver_currency, |
33 | | - "tid": self.tid, |
34 | | - "reference": self.reference, |
35 | | - "receipt_no": self.receipt_no, |
36 | | - "timestamp": self.timestamp, |
37 | | - "gross_amount": self.gross_amount, |
38 | | - "net_amount": self.net_amount, |
39 | | - "transacted_via": self.transacted_via, |
40 | | - "is_money_in": self.is_money_in, |
41 | | - "sender": self.sender, |
42 | | - "receiver": self.receiver |
43 | | - } |
44 | | - |
45 | | - def get_time(self): |
46 | | - return datetime.fromtimestamp(self.timestamp) |
47 | | - |
48 | | - |
49 | 11 | class Soofa(object): |
50 | 12 | TRANSACTION_DOES_NOT_EXIST = 404 |
51 | 13 | PERMISSION_DENIED = 403 |
@@ -97,3 +59,9 @@ def get_balance(self): |
97 | 59 | return r.json() |
98 | 60 |
|
99 | 61 |
|
| 62 | +if __name__ == '__main__': |
| 63 | + soofa = Soofa("5002", '3ixwt45uq88wttqgixpyla8d27ob0w') |
| 64 | + exists = soofa.find("QTMB6") |
| 65 | + if exists: |
| 66 | + trx: Transaction = soofa.get_transaction() |
| 67 | + print(trx.json()) |
0 commit comments