from datetime import datetime
from typing import Optional

from pydantic import BaseModel, ConfigDict


class PedimentoPackagesBase(BaseModel):
    """Base schema for Pedimento Packages"""

    pedimento_id: Optional[int] = None
    quantity: Optional[int] = None
    brand: Optional[str] = None
    number: Optional[str] = None
    vehicles: Optional[int] = None


class PedimentoPackagesCreate(PedimentoPackagesBase):
    """Schema for creating Pedimento Packages"""

    pass


class PedimentoPackagesUpdate(BaseModel):
    """Schema for updating Pedimento Packages"""

    quantity: Optional[int] = None
    brand: Optional[str] = None
    number: Optional[str] = None
    vehicles: Optional[int] = None


class PedimentoPackagesResponse(PedimentoPackagesBase):
    """Schema for Pedimento Packages response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)


class PedimentoTransportCarrierBase(BaseModel):
    """Base schema for Pedimento Transport Carrier"""

    pedimento_id: Optional[int] = None
    carrier: Optional[str] = None
    rfc: Optional[str] = None
    curp: Optional[str] = None
    name: Optional[str] = None
    address: Optional[str] = None
    city: Optional[str] = None
    state: Optional[str] = None
    country: Optional[str] = None
    tax_id: Optional[str] = None
    total_packages: Optional[int] = None
    identification: Optional[str] = None


class PedimentoTransportCarrierCreate(PedimentoTransportCarrierBase):
    """Schema for creating Pedimento Transport Carrier"""

    pass


class PedimentoTransportCarrierUpdate(BaseModel):
    """Schema for updating Pedimento Transport Carrier"""

    carrier: Optional[str] = None
    rfc: Optional[str] = None
    curp: Optional[str] = None
    name: Optional[str] = None
    address: Optional[str] = None
    city: Optional[str] = None
    state: Optional[str] = None
    country: Optional[str] = None
    tax_id: Optional[str] = None
    total_packages: Optional[int] = None
    identification: Optional[str] = None


class PedimentoTransportCarrierResponse(PedimentoTransportCarrierBase):
    """Schema for Pedimento Transport Carrier response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)


class PedimentoSealBase(BaseModel):
    """Base schema for Pedimento Seal"""

    pedimento_id: Optional[int] = None
    number: Optional[str] = None
    identification: Optional[str] = None


class PedimentoSealCreate(PedimentoSealBase):
    """Schema for creating Pedimento Seal"""

    pass


class PedimentoSealUpdate(BaseModel):
    """Schema for updating Pedimento Seal"""

    number: Optional[str] = None
    identification: Optional[str] = None


class PedimentoSealResponse(PedimentoSealBase):
    """Schema for Pedimento Seal response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)


class PedimentoContainerBase(BaseModel):
    """Base schema for Pedimento Container"""

    pedimento_id: Optional[int] = None
    number: Optional[str] = None
    identification: Optional[str] = None
    type: Optional[str] = None


class PedimentoContainerCreate(PedimentoContainerBase):
    """Schema for creating Pedimento Container"""

    pass


class PedimentoContainerUpdate(BaseModel):
    """Schema for updating Pedimento Container"""

    number: Optional[str] = None
    identification: Optional[str] = None
    type: Optional[str] = None


class PedimentoContainerResponse(PedimentoContainerBase):
    """Schema for Pedimento Container response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)


class PedimentoGuideBase(BaseModel):
    """Base schema for Pedimento Guide"""

    pedimento_id: Optional[int] = None
    guide: Optional[str] = None
    identifier: Optional[str] = None


class PedimentoGuideCreate(PedimentoGuideBase):
    """Schema for creating Pedimento Guide"""

    pass


class PedimentoGuideUpdate(BaseModel):
    """Schema for updating Pedimento Guide"""

    guide: Optional[str] = None
    identifier: Optional[str] = None


class PedimentoGuideResponse(PedimentoGuideBase):
    """Schema for Pedimento Guide response"""

    id: int
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)
