using System; using System.Collections.Generic; using Newtonsoft.Json; namespace FasdCockpitCommunication.TicketOverview { internal sealed class TicketOverviewCountsResponse { [JsonProperty("counts")] public Dictionary Counts { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); public Dictionary ToDictionary(IEnumerable expectedKeys) { var comparer = StringComparer.OrdinalIgnoreCase; var output = new Dictionary(comparer); if (expectedKeys != null) { foreach (var key in expectedKeys) { if (string.IsNullOrWhiteSpace(key)) continue; if (Counts != null && Counts.TryGetValue(key, out var count)) output[key] = count; else output[key] = 0; } return output; } if (Counts != null) { foreach (var kvp in Counts) { if (string.IsNullOrWhiteSpace(kvp.Key)) continue; output[kvp.Key] = kvp.Value; } } return output; } } }