"""Pydantic schemas for PSA ticket context enrichment."""
from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel


class TicketDetails(BaseModel):
    id: int
    summary: str
    status: str
    priority: str
    board: str
    sla: str | None = None
    date_entered: datetime
    resources: str | None = None


class CompanyInfo(BaseModel):
    id: int
    name: str
    site: str | None = None
    address: str | None = None
    phone: str | None = None
    type: str | None = None
    territory: str | None = None


class ContactInfo(BaseModel):
    name: str
    email: str | None = None
    phone: str | None = None
    title: str | None = None


class ConfigItem(BaseModel):
    device_identifier: str
    type: str | None = None
    os_type: str | None = None
    serial_number: str | None = None
    ip_address: str | None = None
    model_number: str | None = None


class TicketNote(BaseModel):
    text: str
    member: str | None = None
    date_created: datetime
    internal_analysis_flag: bool = False


class RelatedTicket(BaseModel):
    id: int
    summary: str
    status: str
    priority: str
    board: str


class TicketContext(BaseModel):
    ticket: TicketDetails
    company: CompanyInfo
    contact: ContactInfo | None = None
    configurations: list[ConfigItem] = []
    notes: list[TicketNote] = []
    related_tickets: list[RelatedTicket] = []
    fetched_at: datetime
