-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
48 lines (35 loc) · 1.08 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
from datetime import datetime, timezone
from typing import Optional
from fastapi import Query
from pydantic import BaseModel
class PaywallFileConfig(BaseModel):
url: str
headers: dict[str, str]
# todo: nice to have:
# expiration_time: Optional[int]
# max_number_of_downloads: Optional[int]
class PaywallExtra(BaseModel):
# possible types: 'url' and 'file'
type: Optional[str] = "url"
file_config: Optional[PaywallFileConfig] = None
class CreatePaywall(BaseModel):
url: str = Query(...)
memo: str = Query(...)
description: str = Query(None)
amount: int = Query(..., ge=0)
remembers: bool = Query(...)
extras: Optional[PaywallExtra] = None
class CreatePaywallInvoice(BaseModel):
amount: int = Query(..., ge=1)
class CheckPaywallInvoice(BaseModel):
payment_hash: str = Query(...)
class Paywall(BaseModel):
id: str
wallet: str
url: str
memo: str
description: Optional[str]
amount: int
remembers: bool
time: datetime = datetime.now(timezone.utc)
extras: Optional[PaywallExtra] = PaywallExtra()