from typing import Optional

from pydantic import BaseModel, Field


class TransporterBaseDTO(BaseModel):
    transporter_key: str = Field(..., description="Transporter key (primary identifier)")
    transporter_id: Optional[int] = Field(None, description="Internal transporter integer ID")
    name: Optional[str] = None
    short_name: Optional[str] = None
    responsible: Optional[str] = None
    rfc: Optional[str] = None
    streets: Optional[str] = None
    postal_code: Optional[str] = None
    city: Optional[str] = None
    state: Optional[str] = None
    country: Optional[str] = None
    loader_code: Optional[str] = None
    caat_code: Optional[str] = None
    transport_code: Optional[str] = None
    transport_interface_type: Optional[str] = None
    ftp_server: Optional[str] = None
    ftp_user: Optional[str] = None
    ftp_password: Optional[str] = None
    ftp_directory: Optional[str] = None
    filler_code: Optional[str] = None
    has_express_line: Optional[bool] = False


class TransporterCreateDTO(TransporterBaseDTO):
    """Schema for creating a transporter"""
    pass


class TransporterUpdateDTO(TransporterBaseDTO):
    """Schema for updating a transporter"""
    transporter_key: Optional[str] = Field(None, description="Transporter key (cannot be modified)")


class TransporterResponseDTO(TransporterBaseDTO):
    """Schema for transporter response"""
    company_id: int
    tenant_id: int

    class Config:
        from_attributes = True
