"""Common models and mixins for OxaPay API."""

from typing import Any, Generic, TypeVar

from pydantic import BaseModel, Field

T = TypeVar("T")


class BaseResponse(BaseModel):
    """Base response model matching v1 API structure."""

    status: int = Field(..., description="The status code of the response (e.g. 200)")
    message: str = Field(
        ...,
        description="A message providing additional information about the result",
    )
    version: str | None = Field(None, description="API version")
    error: dict[str, Any] | None = Field(None, description="Error details if any")


class DataResponse(BaseResponse, Generic[T]):
    """Generic response model wrapping a data object."""

    data: T = Field(..., description="The data payload")


class TrackIdMixin(BaseModel):
    """Mixin for models with a track_id field."""

    track_id: str = Field(
        ...,
        description="Unique identifier",
        validation_alias="trackId",
    )


class AmountCurrencyMixin(BaseModel):
    """Mixin for models with amount and currency fields."""

    amount: float = Field(..., description="Amount")
    currency: str = Field(..., description="Currency symbol")


class PaymentDetailsMixin(BaseModel):
    """Mixin for payment details (pay_amount, pay_currency, network)."""

    pay_amount: float | None = Field(
        None,
        description="Payment amount in payment currency",
        validation_alias="payAmount",
    )
    pay_currency: str | None = Field(
        None,
        description="Payment currency symbol",
        validation_alias="payCurrency",
    )
    network: str | None = Field(None, description="Blockchain network")


class AddressMixin(BaseModel):
    """Mixin for models with an address field."""

    address: str | None = Field(None, description="Wallet address")
