"""Models for OxaPay System API."""

from pydantic import BaseModel, Field

from .common import DataResponse


class NetworkInfo(BaseModel):
    """Model for network information."""

    network: str = Field(..., description="Network identifier")
    name: str = Field(..., description="Network name")
    required_confirmations: int | None = Field(
        None,
        description="Minimum confirmations required",
    )
    withdraw_fee: float | None = Field(
        None,
        description="Withdrawal fee",
    )
    withdraw_min: float | None = Field(
        None,
        description="Minimum withdrawal amount",
    )
    deposit_min: float | None = Field(
        None,
        description="Minimum deposit amount",
    )
    static_fixed_fee: float | None = Field(
        None,
        description="Fixed fee for static address",
    )
    keys: list[str] | None = Field(
        None,
        description="List of required keys",
    )


class CurrencyInfo(BaseModel):
    """Model for currency information."""

    symbol: str = Field(..., description="Currency symbol")
    name: str = Field(..., description="Currency name")
    status: bool = Field(..., description="Whether the currency is active")
    networks: dict[str, NetworkInfo] = Field(
        ...,
        description="Available networks",
    )


class SupportedCurrenciesResponse(DataResponse[dict[str, CurrencyInfo]]):
    """Response model for supported currencies."""


class FiatCurrencyInfo(BaseModel):
    """Model for fiat currency information."""

    symbol: str = Field(..., description="Currency symbol")
    name: str = Field(..., description="Currency name")
    price: float = Field(..., description="Current price")
    display_precision: float | None = Field(
        None,
        description="Decimal precision used when displaying the currency",
    )


class SupportedFiatsResponse(DataResponse[dict[str, FiatCurrencyInfo]]):
    """Response model for supported fiat currencies."""


class PriceResponse(DataResponse[dict[str, float]]):
    """Response model for cryptocurrency prices."""


class SystemStatusResponse(DataResponse[dict[str, str]]):
    """Response model for system status."""


class NetworksData(BaseModel):
    """Model for networks list data."""

    networks: list[str] = Field(
        ...,
        description="Array of network names",
        validation_alias="list",
    )


class NetworksResponse(DataResponse[NetworksData]):
    """Response model for supported networks."""
