forked from lnbits/myextension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
34 lines (27 loc) · 829 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
# Data models for your extension
from sqlite3 import Row
from typing import Optional, List
from pydantic import BaseModel
from fastapi import Request
from lnbits.lnurl import encode as lnurl_encode
from urllib.parse import urlparse
class CreateMyExtensionData(BaseModel):
wallet: Optional[str]
name: Optional[str]
total: Optional[int]
lnurlpayamount: Optional[int]
lnurlwithdrawamount: Optional[int]
ticker: Optional[int]
class MyExtension(BaseModel):
id: str
wallet: Optional[str]
name: Optional[str]
total: Optional[int]
lnurlpayamount: Optional[int]
lnurlwithdrawamount: Optional[int]
lnurlpay: Optional[str]
lnurlwithdraw: Optional[str]
ticker: Optional[int]
@classmethod
def from_row(cls, row: Row) -> "MyExtension":
return cls(**dict(row))