from datetime import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field


class PedimentoTransportMeansBase(BaseModel):
    """Base schema for Pedimento Transport Means"""

    pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
    tenant_id: Optional[int] = Field(None, description="Tenant ID")
    destination: Optional[int] = Field(None, description="Destination")
    entry_exit: Optional[str] = Field(None, max_length=3, description="Entry/exit")
    arrival: str = Field(..., max_length=3, description="Arrival")
    departure: str = Field(..., max_length=3, description="Departure")


class PedimentoTransportMeansCreate(BaseModel):
    """Schema for creating a new Pedimento Transport Means - pedimento_id and tenant_id are set by backend"""

    destination: Optional[int] = Field(None, description="Destination")
    entry_exit: Optional[str] = Field(None, max_length=3, description="Entry/exit")
    arrival: str = Field(..., max_length=3, description="Arrival")
    departure: str = Field(..., max_length=3, description="Departure")


class PedimentoTransportMeansUpdate(BaseModel):
    """Schema for updating a Pedimento Transport Means"""

    destination: Optional[int] = None
    entry_exit: Optional[str] = Field(None, max_length=3)
    arrival: Optional[str] = Field(None, max_length=3)
    departure: Optional[str] = Field(None, max_length=3)


class PedimentoTransportMeansResponse(PedimentoTransportMeansBase):
    """Schema for Pedimento Transport Means response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)
