Consume ticket overview capabilities separately
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FasdCockpitCommunication.TicketOverview
|
||||
@@ -10,7 +11,10 @@ namespace FasdCockpitCommunication.TicketOverview
|
||||
[JsonProperty("counts")]
|
||||
public Dictionary<string, int> Counts { get; set; } = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public Dictionary<string, int> ToDictionary(IEnumerable<string> expectedKeys)
|
||||
[JsonProperty("capabilities")]
|
||||
public TicketOverviewCapabilitiesResponse Capabilities { get; set; } = new TicketOverviewCapabilitiesResponse();
|
||||
|
||||
public cF4sdTicketOverviewCountsResult ToResult(IEnumerable<string> expectedKeys)
|
||||
{
|
||||
var comparer = StringComparer.OrdinalIgnoreCase;
|
||||
var output = new Dictionary<string, int>(comparer);
|
||||
@@ -28,7 +32,7 @@ namespace FasdCockpitCommunication.TicketOverview
|
||||
output[key] = 0;
|
||||
}
|
||||
|
||||
return output;
|
||||
return CreateResult(output);
|
||||
}
|
||||
|
||||
if (Counts != null)
|
||||
@@ -42,7 +46,25 @@ namespace FasdCockpitCommunication.TicketOverview
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
return CreateResult(output);
|
||||
}
|
||||
|
||||
private cF4sdTicketOverviewCountsResult CreateResult(Dictionary<string, int> counts)
|
||||
{
|
||||
return new cF4sdTicketOverviewCountsResult
|
||||
{
|
||||
Counts = counts,
|
||||
Capabilities = new cF4sdTicketOverviewCapabilities
|
||||
{
|
||||
TicketAndServiceRequestsEnabled = Capabilities?.TicketAndServiceRequestsEnabled ?? true
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class TicketOverviewCapabilitiesResponse
|
||||
{
|
||||
[JsonProperty("ticketAndServiceRequestsEnabled")]
|
||||
public bool TicketAndServiceRequestsEnabled { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user