using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace StellaOps.Feedser.Source.Cccs.Internal;

internal sealed record CccsAdvisoryDto
{
    [JsonPropertyName("sourceId")]
    public string SourceId { get; init; } = string.Empty;

    [JsonPropertyName("serialNumber")]
    public string SerialNumber { get; init; } = string.Empty;

    [JsonPropertyName("language")]
    public string Language { get; init; } = "en";

    [JsonPropertyName("title")]
    public string Title { get; init; } = string.Empty;

    [JsonPropertyName("summary")]
    public string? Summary { get; init; }

    [JsonPropertyName("canonicalUrl")]
    public string CanonicalUrl { get; init; } = string.Empty;

    [JsonPropertyName("contentHtml")]
    public string ContentHtml { get; init; } = string.Empty;

    [JsonPropertyName("published")]
    public DateTimeOffset? Published { get; init; }

    [JsonPropertyName("modified")]
    public DateTimeOffset? Modified { get; init; }

    [JsonPropertyName("alertType")]
    public string? AlertType { get; init; }

    [JsonPropertyName("subject")]
    public string? Subject { get; init; }

    [JsonPropertyName("products")]
    public IReadOnlyList<string> Products { get; init; } = Array.Empty<string>();

    [JsonPropertyName("references")]
    public IReadOnlyList<CccsReferenceDto> References { get; init; } = Array.Empty<CccsReferenceDto>();

    [JsonPropertyName("cveIds")]
    public IReadOnlyList<string> CveIds { get; init; } = Array.Empty<string>();
}

internal sealed record CccsReferenceDto(
    [property: JsonPropertyName("url")] string Url,
    [property: JsonPropertyName("label")] string? Label);
