using System;
using System.Collections.Generic;

namespace StellaOps.Feedser.Source.CertBund.Internal;

internal static class CertBundDocumentMetadata
{
    public static Dictionary<string, string> CreateMetadata(CertBundFeedItem item)
    {
        var metadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
        {
            ["certbund.advisoryId"] = item.AdvisoryId,
            ["certbund.portalUri"] = item.PortalUri.ToString(),
            ["certbund.published"] = item.Published.ToString("O"),
        };

        if (!string.IsNullOrWhiteSpace(item.Category))
        {
            metadata["certbund.category"] = item.Category!;
        }

        if (!string.IsNullOrWhiteSpace(item.Title))
        {
            metadata["certbund.title"] = item.Title!;
        }

        return metadata;
    }
}
