lnbits-legend/lnbits/extensions/paywall/models.py

24 lines
507 B
Python
Raw Normal View History

import json
from sqlite3 import Row
from typing import NamedTuple, Optional
2020-04-05 12:20:03 +02:00
class Paywall(NamedTuple):
id: str
wallet: str
url: str
memo: str
description: str
2020-04-05 12:20:03 +02:00
amount: int
time: int
remembers: bool
extras: Optional[dict]
@classmethod
def from_row(cls, row: Row) -> "Paywall":
data = dict(row)
data["remembers"] = bool(data["remembers"])
data["extras"] = json.loads(data["extras"]) if data["extras"] else None
return cls(**data)