from pydantic import BaseModel, Field, ConfigDict
from decimal import Decimal
from datetime import datetime
from app.models.transaction import TransactionType, TransactionStatus


class WalletResponse(BaseModel):
    id: int
    user_id: int
    balance: Decimal
    escrow: Decimal
    currency: str
    created_at: datetime
    updated_at: datetime

    model_config = ConfigDict(from_attributes=True)


class DepositRequest(BaseModel):
    amount: Decimal = Field(..., gt=0, le=10000)


class WithdrawalRequest(BaseModel):
    amount: Decimal = Field(..., gt=0)


class TransactionResponse(BaseModel):
    id: int
    user_id: int
    type: TransactionType
    amount: Decimal
    balance_after: Decimal
    reference_id: int | None
    description: str
    status: TransactionStatus
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)
