using System.Text.Json.Serialization;

namespace ClaudeDo.Worker.Tickets;

/// Antwort-Hülle jeder Bandel.APIs-Route.
public sealed record BandelEnvelope<T>(
    [property: JsonPropertyName("success")] bool Success,
    [property: JsonPropertyName("data")] T? Data,
    [property: JsonPropertyName("message")] string? Message,
    [property: JsonPropertyName("errorCode")] string? ErrorCode);

/// GET /api/ticketsystem/pat/me
public sealed record TicketIdentity(
    [property: JsonPropertyName("userName")] string UserName,
    [property: JsonPropertyName("isPat")] bool IsPat,
    [property: JsonPropertyName("scopes")] IReadOnlyList<string> Scopes);

/// Ein Board-Item (Ausschnitt aus GetTicketSummaryDto — nur was der Import braucht).
public sealed record TicketBoardItem(
    [property: JsonPropertyName("id")] int Id,
    [property: JsonPropertyName("title")] string Title,
    [property: JsonPropertyName("description")] string? Description,
    [property: JsonPropertyName("statusId")] int StatusId,
    [property: JsonPropertyName("statusName")] string? StatusName,
    [property: JsonPropertyName("assigneeID")] int? AssigneeId,
    [property: JsonPropertyName("assigneeName")] string? AssigneeName);

/// GET /api/Navigation/sidebar — Abteilung mit ihren Projekten.
public sealed record SidebarDepartment(
    [property: JsonPropertyName("departmentId")] int DepartmentId,
    [property: JsonPropertyName("departmentName")] string DepartmentName,
    [property: JsonPropertyName("projects")] IReadOnlyList<SidebarProject> Projects);

public sealed record SidebarProject(
    [property: JsonPropertyName("id")] int Id,
    [property: JsonPropertyName("title")] string Title);

/// Flachgeklopftes Projekt für die UI-Auswahl.
public sealed record TicketProject(int Id, string Title, string DepartmentName);

public sealed class TicketApiException : Exception
{
    public TicketApiException(string message) : base(message) { }
}
