2021-08-20 12:44:03 +01:00
|
|
|
from sqlite3 import Row
|
2021-08-20 14:46:08 +01:00
|
|
|
from pydantic import BaseModel
|
2021-08-20 12:44:03 +01:00
|
|
|
import time
|
|
|
|
|
|
|
|
|
2021-08-20 14:46:08 +01:00
|
|
|
class Charges(BaseModel):
|
2021-08-20 12:44:03 +01:00
|
|
|
id: str
|
|
|
|
user: str
|
|
|
|
description: str
|
|
|
|
onchainwallet: str
|
|
|
|
onchainaddress: str
|
|
|
|
lnbitswallet: str
|
|
|
|
payment_request: str
|
|
|
|
payment_hash: str
|
|
|
|
webhook: str
|
|
|
|
completelink: str
|
|
|
|
completelinktext: str
|
|
|
|
time: int
|
|
|
|
amount: int
|
|
|
|
balance: int
|
|
|
|
timestamp: int
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_row(cls, row: Row) -> "Charges":
|
|
|
|
return cls(**dict(row))
|
|
|
|
|
|
|
|
@property
|
|
|
|
def time_elapsed(self):
|
|
|
|
if (self.timestamp + (self.time * 60)) >= time.time():
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
|
|
|
@property
|
|
|
|
def paid(self):
|
|
|
|
if self.balance >= self.amount:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|