# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import (
    PaymentDetailStatus,
    PaymentProviderProviderType,
    ProviderCredentialCreateRequestProviderType,
    TransactionTransactionType,
    WithdrawalDetailStatus,
)


class Balance(BaseModel):
    """
    Serializer for TenantBalance model.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    balance_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    balance_display: Any = ...
    total_deposited: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    total_withdrawn: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    last_transaction_at: datetime.datetime | None = None
    is_empty: bool = ...



class PaymentProvider(BaseModel):
    """
    Serializer for PaymentProvider model.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    name: Any = ...
    provider_type: PaymentProviderProviderType = Field(
    description='* `nowpayments` - NowPayments * ...',
)
    is_active: bool = ...



class ProviderCredentialList(BaseModel):
    """
    Serializer for listing provider credentials.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    provider: PaymentProvider = ...
    name: Any = Field(description='Friendly name')
    credential_prefix: Any = ...
    is_sandbox: bool = ...
    is_active: bool = ...
    is_default: bool = Field(description='Use as default for this provider')
    is_healthy: bool = ...
    total_payments: int = ...
    total_volume_usd: Any = Field(pattern='^-?\\d{0,13}(?:\\.\\d{0,2})?$')
    last_used_at: datetime.datetime | None = None
    consecutive_errors: int = ...
    created_at: datetime.datetime = ...



class PaginatedProviderCredentialListList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[ProviderCredentialList] = Field(description='Array of items for current page')



class ProviderCredentialCreateRequest(BaseModel):
    """
    Serializer for creating provider credentials.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    provider_type: ProviderCredentialCreateRequestProviderType = Field(
    description='* `nowpayments` - nowpayments * ...',
)
    name: str = Field(min_length=1, max_length=100)
    credential_key: str = Field(min_length=1, max_length=500)
    is_sandbox: bool | None = None
    is_default: bool | None = None
    metadata: dict[str, Any] | None = None



class ProviderCredentialDetail(BaseModel):
    """
    Serializer for credential details.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    provider: PaymentProvider = ...
    name: Any = Field(description='Friendly name')
    credential_prefix: Any = ...
    is_sandbox: bool = ...
    is_active: bool = ...
    is_default: bool = Field(description='Use as default for this provider')
    is_healthy: bool = ...
    total_payments: int = ...
    total_volume_usd: Any = Field(pattern='^-?\\d{0,13}(?:\\.\\d{0,2})?$')
    last_used_at: datetime.datetime | None = None
    consecutive_errors: int = ...
    created_at: datetime.datetime = ...
    last_error: str | None = None
    last_error_at: datetime.datetime | None = None
    metadata: dict[str, Any] | None = None



class ProviderCredentialTestResponseRequest(BaseModel):
    """
    Serializer for credential test response.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    message: str = Field(min_length=1)



class ProviderCredentialTestResponse(BaseModel):
    """
    Serializer for credential test response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    message: str = ...



class Currency(BaseModel):
    """
    Serializer for Currency model.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    code: Any = ...
    name: Any = ...
    token: Any = ...
    network: Any | None = None
    symbol: Any = ...
    decimal_places: int = ...
    display_name: Any = ...
    min_amount_usd: Any = Field(pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    sort_order: int = ...



class PaginatedCurrencyList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[Currency] = Field(description='Array of items for current page')



class CurrencyEstimateResponse(BaseModel):
    """
    Serializer for currency estimate response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    currency_code: str = ...
    amount_usd: str = ...
    estimated_crypto_amount: str = ...
    rate: str = ...
    service_fee_usd: str = ...
    service_fee_pct: str = ...
    net_amount_usd: str = ...



class PaymentList(BaseModel):
    """
    Serializer for listing payments.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    internal_payment_id: Any = ...
    amount_usd: Any = Field(pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    amount_display: Any = ...
    currency_code: Any = ...
    currency_token: Any = ...
    pay_amount: Any | None = Field(
    None,
    description='Expected crypto amount',
    pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$',
)
    crypto_amount_display: Any = ...
    status: PaymentDetailStatus = Field(description='* `pending` - Pending * `confirm...')
    status_color: Any = ...
    is_active: bool = ...
    is_completed: bool = ...
    client_reference_id: Any | None = None
    created_at: datetime.datetime = ...
    expires_at: datetime.datetime | None = None
    completed_at: datetime.datetime | None = None



class PaginatedPaymentListList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[PaymentList] = Field(description='Array of items for current page')



class PaymentDetail(BaseModel):
    """
    Serializer for payment details.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    internal_payment_id: Any = ...
    amount_usd: Any = Field(pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    amount_display: Any = ...
    currency_code: Any = ...
    currency_token: Any = ...
    pay_amount: Any | None = Field(
    None,
    description='Expected crypto amount',
    pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$',
)
    crypto_amount_display: Any = ...
    status: PaymentDetailStatus = Field(description='* `pending` - Pending * `confirm...')
    status_color: Any = ...
    is_active: bool = ...
    is_completed: bool = ...
    client_reference_id: Any | None = None
    created_at: datetime.datetime = ...
    expires_at: datetime.datetime | None = None
    completed_at: datetime.datetime | None = None
    provider_payment_id: str | None = Field(None, max_length=255)
    pay_address: str | None = Field(None, max_length=255)
    payment_url: str | None = Field(None, max_length=200)
    transaction_hash: str | None = Field(None, max_length=256)
    confirmations_count: int | None = Field(None, ge=0, le=2147483647)
    actual_amount: Any | None = Field(
    None,
    description='Actually received crypto amount',
    pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$',
)
    actual_amount_usd: Any | None = Field(
    None,
    description='Actually received USD equivalent',
    pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$',
)
    description: str | None = None
    callback_url: str | None = Field(None, max_length=200)
    credential_name: Any = ...
    provider_name: Any = ...
    status_changed_at: datetime.datetime | None = None



class PaymentStatusRequest(BaseModel):
    """
    Serializer for payment status response.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    payment_id: str | None = None
    internal_payment_id: str | None = Field(None, min_length=1)
    status: str | None = Field(None, min_length=1)
    previous_status: str | None = Field(None, min_length=1)
    actual_amount: Any | None = Field(None, pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$')
    actual_amount_usd: Any | None = Field(None, pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    transaction_hash: str | None = Field(None, min_length=1)
    confirmations: int | None = None
    completed_at: str | None = Field(None, min_length=1)
    error: str | None = Field(None, min_length=1)



class PaymentStatus(BaseModel):
    """
    Serializer for payment status response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    payment_id: str | None = None
    internal_payment_id: str | None = None
    status: str | None = None
    previous_status: str | None = None
    actual_amount: Any | None = Field(None, pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$')
    actual_amount_usd: Any | None = Field(None, pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    transaction_hash: str | None = None
    confirmations: int | None = None
    completed_at: str | None = None
    error: str | None = None



class PaymentCreateRequest(BaseModel):
    """
    Serializer for creating payments.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    amount_usd: Any = Field(pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    currency_code: str = Field(min_length=3, max_length=20)
    description: str | None = Field(None, max_length=500)
    client_reference_id: str | None = Field(None, max_length=255)
    callback_url: str | None = None
    credential_id: str | None = None



class PaymentCreateResponse(BaseModel):
    """
    Serializer for payment creation response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    payment: PaymentDetail | None = None
    error: str | None = None



class Transaction(BaseModel):
    """
    Serializer for Transaction model.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    transaction_type: TransactionTransactionType = Field(
    description='* `deposit` - Deposit * `withdra...',
)
    amount_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    amount_display: Any = ...
    balance_after: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    payment_id: Any | None = None
    withdrawal_request_id: Any | None = None
    description: Any = ...
    is_credit: bool = ...
    is_debit: bool = ...
    type_color: Any = ...
    created_at: datetime.datetime = ...



class PaginatedTransactionList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[Transaction] = Field(description='Array of items for current page')



class WithdrawalList(BaseModel):
    """
    Serializer for listing withdrawals.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    internal_withdrawal_id: Any = ...
    amount_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    amount_display: Any = ...
    currency_code: Any = ...
    wallet_address: Any = ...
    total_fee_usd: Any = Field(pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    fees_display: Any = ...
    final_amount_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    final_amount_display: Any = ...
    status: WithdrawalDetailStatus = Field(description='* `pending` - Pending * `approve...')
    status_color: Any = ...
    can_be_cancelled: bool = ...
    created_at: datetime.datetime = ...
    completed_at: datetime.datetime | None = None



class PaginatedWithdrawalListList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[WithdrawalList] = Field(description='Array of items for current page')



class WithdrawalDetail(BaseModel):
    """
    Serializer for withdrawal details.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    internal_withdrawal_id: Any = ...
    amount_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    amount_display: Any = ...
    currency_code: Any = ...
    wallet_address: Any = ...
    total_fee_usd: Any = Field(pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    fees_display: Any = ...
    final_amount_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    final_amount_display: Any = ...
    status: WithdrawalDetailStatus = Field(description='* `pending` - Pending * `approve...')
    status_color: Any = ...
    can_be_cancelled: bool = ...
    created_at: datetime.datetime = ...
    completed_at: datetime.datetime | None = None
    network_fee_usd: Any | None = Field(None, pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    service_fee_usd: Any | None = Field(None, pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    crypto_amount: Any | None = Field(None, pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$')
    transaction_hash: str | None = Field(None, max_length=256)
    admin_notes: str | None = None
    approved_at: datetime.datetime | None = None
    rejected_at: datetime.datetime | None = None
    cancelled_at: datetime.datetime | None = None
    status_changed_at: datetime.datetime | None = None



class WithdrawalDetailRequest(BaseModel):
    """
    Serializer for withdrawal details.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    network_fee_usd: Any | None = Field(None, pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    service_fee_usd: Any | None = Field(None, pattern='^-?\\d{0,8}(?:\\.\\d{0,2})?$')
    crypto_amount: Any | None = Field(None, pattern='^-?\\d{0,12}(?:\\.\\d{0,8})?$')
    transaction_hash: str | None = Field(None, max_length=256)
    admin_notes: str | None = None
    approved_at: datetime.datetime | None = None
    rejected_at: datetime.datetime | None = None
    cancelled_at: datetime.datetime | None = None
    status_changed_at: datetime.datetime | None = None



class WithdrawalCancelResponseRequest(BaseModel):
    """
    Serializer for withdrawal cancellation response.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    message: str = Field(min_length=1)
    withdrawal: WithdrawalDetailRequest | None = None



class WithdrawalCancelResponse(BaseModel):
    """
    Serializer for withdrawal cancellation response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    message: str = ...
    withdrawal: WithdrawalDetail | None = None



class WithdrawalCreateRequest(BaseModel):
    """
    Serializer for creating withdrawals.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    amount_usd: Any = Field(pattern='^-?\\d{0,10}(?:\\.\\d{0,2})?$')
    currency_code: str = Field(min_length=3, max_length=20)
    wallet_address: str = Field(min_length=26, max_length=255)



class WithdrawalCreateResponse(BaseModel):
    """
    Serializer for withdrawal creation response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    success: bool = ...
    withdrawal: WithdrawalDetail | None = None
    error: str | None = None



