-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
40 lines (25 loc) · 975 Bytes
/
models.py
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
import datetime
from pydantic import BaseModel
from typing import Optional
#This class describes the structure used to hold transactionary data
class Transaction(BaseModel):
def __init__(self, username: str, transaction_type: str, amount: int, currency :str, recipient: str):
self.username = username
self.transaction_type = transaction_type
self.amount = amount
self.currency = currency
self.recipient = recipient
# dd/mm/YY H:M:S formats date in preferable style
self.timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
def get_username(self):
return self.username
def get_transaction_type(self):
return self.transaction_type
def get_amount(self):
return self.amount
def get_currency(self):
return self.currency
def get_recipient(self):
return self.recipient
def get_timestamp(self):
return self.timestamp