-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
63 lines (51 loc) · 1.45 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
# 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
# Raises - called raisenow as raises is a reserved keyword in Python
class CreateRaiseNowData(BaseModel):
name: str
wallet: Optional[str]
description: Optional[str]
background_image: Optional[str]
header_image: Optional[str]
live_dates: Optional[str]
total: Optional[int]
live_dates: Optional[str]
class RaiseNow(BaseModel):
id: str
name: str
wallet: Optional[str]
description: Optional[str]
background_image: Optional[str]
header_image: Optional[str]
live_dates: Optional[str]
total: Optional[int]
live_dates: Optional[str]
lnurlpay: Optional[str]
@classmethod
def from_row(cls, row: Row) -> "raisenow":
return cls(**dict(row))
# Participants
class CreateParticipantData(BaseModel):
name: str
raisenow: str
description: Optional[str]
profile_image: Optional[str]
total: Optional[int]
lnaddress: Optional[str]
class Participant(BaseModel):
id: str
name: str
raisenow: str
description: Optional[str]
profile_image: Optional[str]
total: Optional[int]
lnaddress: Optional[str]
lnurlpay: Optional[str]
@classmethod
def from_row(cls, row: Row) -> "raisenow":
return cls(**dict(row))