from typing import Optional

from pydantic import BaseModel, Field


class TrailerBaseDTO(BaseModel):
    trailer_number: str = Field(..., description="Trailer number (primary identifier)")
    ace_trailer_number: Optional[str] = None
    trailer_type_key: Optional[str] = None
    seal: Optional[str] = None
    entity_code: Optional[str] = None
    plate_number: Optional[str] = None
    state: Optional[str] = None
    country: Optional[str] = None
    container_key: Optional[str] = None


class TrailerCreateDTO(TrailerBaseDTO):
    """Schema for creating a trailer"""
    pass


class TrailerUpdateDTO(TrailerBaseDTO):
    """Schema for updating a trailer"""
    trailer_number: Optional[str] = Field(None, description="Trailer number (cannot be modified)")


class TrailerResponseDTO(TrailerBaseDTO):
    """Schema for trailer response"""
    company_id: int
    tenant_id: int

    class Config:
        from_attributes = True
