forked from pieterjm/DeviceTimer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
67 lines (58 loc) · 1.41 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
57
58
59
60
61
62
63
64
65
66
67
import json
from sqlite3 import Row
from typing import List, Optional
from enum import Enum
from lnurl.types import LnurlPayMetadata
from pydantic import BaseModel, Json
class PaymentAllowed(Enum):
OPEN = 1
CLOSED = 2
WAIT = 3
class LnurldeviceSwitch(BaseModel):
id: Optional[str]
amount: float = 0.0
gpio_pin: int = 21
gpio_duration: int = 2100
lnurl: Optional[str]
label: Optional[str]
class CreateLnurldevice(BaseModel):
title: str
wallet: str
currency: str
available_start: str
available_stop: str
timeout: int
timezone: str
maxperday: Optional[int]
closed_url: Optional[str]
wait_url: Optional[str]
switches: Optional[List[LnurldeviceSwitch]]
class Lnurldevice(BaseModel):
id: str
key: str
title: str
wallet: str
currency: str
switches: Optional[Json[List[LnurldeviceSwitch]]]
timestamp: str
available_start: str
available_stop: str
timeout: int
timezone: str
maxperday: Optional[int]
closed_url: Optional[str]
wait_url: Optional[str]
@classmethod
def from_row(cls, row: Row) -> "Lnurldevice":
return cls(**dict(row))
class LnurldevicePayment(BaseModel):
id: str
deviceid: str
payhash: str
payload: str
switchid: str
sats: int
timestamp: str
@classmethod
def from_row(cls, row: Row) -> "LnurldevicePayment":
return cls(**dict(row))