"""API request models."""

from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from .enums import DocumentKind


class DocumentUploadRequest(BaseModel):
    """Request model for document upload"""

    tenant_id: str = Field(..., description="Tenant identifier")
    kind: DocumentKind = Field(..., description="Document type")
    source: str = Field(..., description="Document source")


class ExtractionRequest(BaseModel):
    """Request model for document extraction"""

    strategy: str = Field(default="hybrid", description="Extraction strategy")


class RAGSearchRequest(BaseModel):
    """Request model for RAG search"""

    query: str = Field(..., min_length=1, description="Search query")
    tax_year: str | None = Field(None, description="Tax year filter")
    jurisdiction: str | None = Field(None, description="Jurisdiction filter")
    k: int = Field(default=10, ge=1, le=100, description="Number of results")


class ScheduleComputeRequest(BaseModel):
    """Request model for schedule computation"""

    tax_year: str = Field(..., pattern=r"^\d{4}-\d{2}$", description="Tax year")
    taxpayer_id: str = Field(..., description="Taxpayer identifier")
    schedule_id: str = Field(..., description="Schedule identifier")


class HMRCSubmissionRequest(BaseModel):
    """Request model for HMRC submission"""

    tax_year: str = Field(..., pattern=r"^\d{4}-\d{2}$", description="Tax year")
    taxpayer_id: str = Field(..., description="Taxpayer identifier")
    dry_run: bool = Field(default=True, description="Dry run flag")


class FirmSyncRequest(BaseModel):
    """Request to sync firm data"""

    model_config = ConfigDict(extra="forbid")

    firm_id: str = Field(..., description="Firm identifier")
    system: str = Field(..., description="Practice management system to sync with")
    sync_type: str = Field(
        default="full", description="Type of sync: full, incremental"
    )
    force_refresh: bool = Field(
        default=False, description="Force refresh of cached data"
    )
    connection_config: dict[str, Any] = Field(
        ...,
        description="Configuration for connecting to the practice management system",
    )
