forked from lnbits/lnurldevice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
56 lines (44 loc) · 1.13 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
from sqlite3 import Row
from typing import List, Optional
from lnurl.types import LnurlPayMetadata
from pydantic import BaseModel, Json
class LnurldeviceSwitch(BaseModel):
amount: float = 0.0
duration: int = 0
pin: int = 0
lnurl: Optional[str]
class CreateLnurldevice(BaseModel):
title: str
wallet: str
currency: str
device: str
profit: float
switches: Optional[List[LnurldeviceSwitch]]
class Lnurldevice(BaseModel):
id: str
key: str
title: str
wallet: str
profit: float
currency: str
device: str
switches: Optional[Json[List[LnurldeviceSwitch]]]
timestamp: str
@classmethod
def from_row(cls, row: Row) -> "Lnurldevice":
return cls(**dict(row))
@property
def lnurlpay_metadata(self) -> LnurlPayMetadata:
return LnurlPayMetadata(json.dumps([["text/plain", self.title]]))
class LnurldevicePayment(BaseModel):
id: str
deviceid: str
payhash: str
payload: str
pin: int
sats: int
timestamp: str
@classmethod
def from_row(cls, row: Row) -> "LnurldevicePayment":
return cls(**dict(row))