"""
Pydantic Models and Schemas
"""

from pydantic import BaseModel, ConfigDict
from typing import Optional
from datetime import datetime


class CustomerBase(BaseModel):
    """Base customer schema"""
    name: str
    email: Optional[str] = None
    phone: Optional[str] = None
    address: Optional[str] = None


class CustomerCreate(CustomerBase):
    """Schema for creating a customer"""
    pass


class Customer(CustomerBase):
    """Full customer schema"""
    id: int
    created_at: str  # Changed from datetime to str for serialization
    updated_at: Optional[str] = None  # Changed from datetime to str for serialization
    
    model_config = ConfigDict(from_attributes=True)


class HardwareBase(BaseModel):
    """Base hardware schema"""
    serial_number: str
    model: str
    customer_id: int


class HardwareCreate(HardwareBase):
    """Schema for creating hardware"""
    pass


class Hardware(HardwareBase):
    """Full hardware schema"""
    id: int
    created_at: datetime
    
    class Config:
        from_attributes = True


class VendorBase(BaseModel):
    """Base vendor schema"""
    name: str
    cvr_number: Optional[str] = None
    domain: Optional[str] = None
    email: Optional[str] = None
    phone: Optional[str] = None
    contact_person: Optional[str] = None
    category: Optional[str] = None
    notes: Optional[str] = None


class VendorCreate(VendorBase):
    """Schema for creating a vendor"""
    pass


class VendorUpdate(BaseModel):
    """Schema for updating a vendor"""
    name: Optional[str] = None
    cvr_number: Optional[str] = None
    domain: Optional[str] = None
    email: Optional[str] = None
    phone: Optional[str] = None
    contact_person: Optional[str] = None
    category: Optional[str] = None
    notes: Optional[str] = None
    is_active: Optional[bool] = None


class Vendor(VendorBase):
    """Full vendor schema"""
    id: int
    is_active: bool = True
    created_at: datetime
    updated_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True
