-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
52 lines (40 loc) · 1.19 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
from datetime import datetime, timezone
from enum import Enum
from lnbits.core.models import PaymentState
from lnbits.helpers import urlsafe_short_hash
from pydantic import BaseModel, Field
class UploadPayment(BaseModel):
payment_hash: str
payment_request: str
class PrintStatus(str, Enum):
WAITING = "waiting"
PRINTING = "printing"
SUCCESS = "success"
FAILED = "failed"
def __str__(self) -> str:
return self.value
class Printer(BaseModel):
id: str = Field(default_factory=urlsafe_short_hash)
user_id: str
wallet: str
host: str
name: str
amount: int
width: int
height: int
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
class CreatePrinter(BaseModel):
name: str
wallet: str
host: str
amount: int
width: int
height: int
class Print(BaseModel):
printer: str
payment_hash: str
file: str
payment_status: PaymentState = PaymentState.PENDING
print_status: PrintStatus = PrintStatus.WAITING
updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))