"""Normalized DTOs for ticket management endpoints."""
from __future__ import annotations
from pydantic import BaseModel


class PSAResourceSchema(BaseModel):
    member_id: int
    member_name: str
    member_identifier: str
    is_rf_user: bool = False


class PSATicketCreatedSchema(BaseModel):
    id: int
    summary: str
    board_name: str
    status_name: str
    priority_name: str
    company_name: str
    resources: list[PSAResourceSchema] = []


class PSATicketStatusUpdateSchema(BaseModel):
    ticket_id: int
    previous_status: str
    new_status: str
    new_status_id: int


class TicketCreatePayloadSchema(BaseModel):
    summary: str
    company_id: int
    board_id: int
    status_id: int
    priority_id: int
    description: str | None = None
    assigned_member_id: int | None = None


class TicketListResponseSchema(BaseModel):
    items: list = []
    total: int = 0
    page: int = 1
    page_size: int = 25


class AiParseRequestSchema(BaseModel):
    prompt: str


class AiParseResponseSchema(BaseModel):
    summary: str | None = None
    company_id: int | None = None
    board_id: int | None = None
    priority_id: int | None = None
    status_id: int | None = None
    assigned_member_id: int | None = None
    description: str | None = None
    missing_fields: list[str] = []
    warnings: list[str] = []


class PSAPrioritySchema(BaseModel):
    id: int
    name: str
