33 lines
861 B
Python
33 lines
861 B
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
class TopupStatus(str, Enum):
|
|
pending = "pending"
|
|
confirmed = "confirmed"
|
|
rejected = "rejected"
|
|
|
|
# Für Ausgaben und Admin-Create weiterhin kompatibel:
|
|
class TopupBase(BaseModel):
|
|
user_id: Optional[int] = None # <- optional gemacht
|
|
amount_cents: int
|
|
paypal_email: Optional[str] = None
|
|
note: Optional[str] = None
|
|
|
|
class TopupCreate(TopupBase):
|
|
# user_id kann für Admin-Aufrufe gesetzt werden, für User-Create weggelassen
|
|
pass
|
|
|
|
class TopupStatusUpdate(BaseModel):
|
|
status: TopupStatus
|
|
|
|
class TopupOut(TopupBase):
|
|
id: int
|
|
status: TopupStatus
|
|
created_at: datetime
|
|
confirmed_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True # pydantic v2 (ersetzt orm_mode)
|