"""
DTOs for Packages (GBultos).
"""

from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field


class PackageBaseDTO(BaseModel):
    key: str = Field(..., description="Package key (primary identifier)", max_length=5)
    description_es: Optional[str] = Field(None, description="Description in Spanish", max_length=40)
    description_en: Optional[str] = Field(None, description="Description in English", max_length=40)
    weight_unit: Optional[float] = Field(None, description="Weight unit")
    plurals: Optional[str] = Field(None, max_length=4)
    plural_in: Optional[str] = Field(None, max_length=4)
    code_ace: Optional[str] = Field(None, max_length=4)
    code_aamex: Optional[str] = Field(None, max_length=9)


class PackageCreateDTO(PackageBaseDTO):
    """Schema for creating a package"""
    pass


class PackageUpdateDTO(PackageBaseDTO):
    """Schema for updating a package"""
    key: Optional[str] = Field(None, description="Package key (cannot be modified)", max_length=5)


class PackageResponseDTO(PackageBaseDTO):
    """Schema for package response"""
    id: int
    company_id: int
    tenant_id: int
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True
