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

namespace StellaOps.Feedser.Source.CertBund.Internal;

public sealed record CertBundAdvisoryDto
{
    [JsonPropertyName("advisoryId")]
    public string AdvisoryId { get; init; } = string.Empty;

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

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

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

    [JsonPropertyName("severity")]
    public string? Severity { get; init; }

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

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

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

    [JsonPropertyName("portalUri")]
    public Uri PortalUri { get; init; } = new("https://wid.cert-bund.de/");

    [JsonPropertyName("detailUri")]
    public Uri DetailUri { get; init; } = new("https://wid.cert-bund.de/");

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

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

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

public sealed record CertBundProductDto
{
    [JsonPropertyName("vendor")]
    public string? Vendor { get; init; }

    [JsonPropertyName("name")]
    public string? Name { get; init; }

    [JsonPropertyName("versions")]
    public string? Versions { get; init; }
}

public sealed record CertBundReferenceDto
{
    [JsonPropertyName("url")]
    public string Url { get; init; } = string.Empty;

    [JsonPropertyName("label")]
    public string? Label { get; init; }
}
