"""Provider-agnostic PSA data types."""
from __future__ import annotations

from pydantic import BaseModel


class ConnectionTestResult(BaseModel):
    success: bool
    message: str
    server_version: str | None = None


class PSATicket(BaseModel):
    id: str
    summary: str
    company_name: str | None = None
    company_id: str | None = None
    board_name: str | None = None
    board_id: int | None = None
    status_name: str | None = None
    status_id: int | None = None
    priority_name: str | None = None
    priority_id: int | None = None
    closed: bool = False


class PSANote(BaseModel):
    id: str
    text: str
    note_type: str
    created_at: str | None = None


class PSAStatus(BaseModel):
    id: int
    name: str
    is_closed: bool = False


class PSACompany(BaseModel):
    id: str
    name: str
    status: str | None = None


class PSAMember(BaseModel):
    id: str
    identifier: str  # CW login username
    name: str
    email: str | None = None


class PSAConfiguration(BaseModel):
    id: str
    name: str
    type: str | None = None
    company_name: str | None = None


class PSATimeEntry(BaseModel):
    id: str
    ticket_id: str
    member_id: str | None = None
    hours: float
    notes: str | None = None
    work_type: str | None = None
    created_at: str | None = None


class PSABoard(BaseModel):
    id: int
    name: str
    inactive: bool = False


class PaginatedTicketResult(BaseModel):
    items: list[PSATicket]
    total: int
    page: int
    page_size: int


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


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


class TicketCreatePayload(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 NoteType:
    INTERNAL_ANALYSIS = "internal_analysis"
    RESOLUTION = "resolution"
    DESCRIPTION = "description"
