47 lines
835 B
Python
47 lines
835 B
Python
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
from datetime import datetime
|
|
import enum
|
|
|
|
|
|
class WalletType(str, enum.Enum):
|
|
SPOT = "spot"
|
|
TRADING = "trading"
|
|
|
|
|
|
class WalletBase(BaseModel):
|
|
wallet_type: WalletType
|
|
balance: float = Field(..., ge=0)
|
|
|
|
|
|
class WalletCreate(WalletBase):
|
|
user_id: int
|
|
|
|
|
|
class WalletUpdate(BaseModel):
|
|
balance: Optional[float] = Field(None, ge=0)
|
|
|
|
|
|
class WalletInDBBase(WalletBase):
|
|
id: int
|
|
user_id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class Wallet(WalletInDBBase):
|
|
pass
|
|
|
|
|
|
class WalletWithBalance(BaseModel):
|
|
wallet_type: WalletType
|
|
balance: float
|
|
|
|
|
|
class WalletTransfer(BaseModel):
|
|
from_wallet_type: WalletType
|
|
to_wallet_type: WalletType
|
|
amount: float = Field(..., gt=0) |