diff --git a/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs index b3b27ca..49c6491 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs @@ -22,12 +22,14 @@ public void SummaryByStatus() Assert.Equal(new Dictionary {{"9", 1}}, report[Booked].byCategoryKey); Assert.Equal(new Dictionary {{"Cat1", 1}}, report[Booked].byCategoryLabel); Assert.Equal(new Dictionary {{NotSelectable, 1}}, report[Booked].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 1}}, report[Booked].byChannel); Assert.Equal(231, report[Free].Count); Assert.Equal(new Dictionary {{"NO_SECTION", 231}}, report[Free].bySection); Assert.Equal(new Dictionary {{"9", 115}, {"10", 116}}, report[Free].byCategoryKey); Assert.Equal(new Dictionary {{"Cat1", 115}, {"Cat2", 116}}, report[Free].byCategoryLabel); Assert.Equal(new Dictionary {{Selectable, 231}}, report[Free].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 231}}, report[Free].byChannel); } [Fact] @@ -43,11 +45,13 @@ public void SummaryByCategoryKey() Assert.Equal(new Dictionary {{"NO_SECTION", 116}}, report["9"].bySection); Assert.Equal(new Dictionary {{Booked, 1}, {Free, 115}}, report["9"].byStatus); Assert.Equal(new Dictionary {{Selectable, 115}, {NotSelectable, 1}}, report["9"].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 116}}, report["9"].byChannel); Assert.Equal(116, report["10"].Count); Assert.Equal(new Dictionary {{"NO_SECTION", 116}}, report["10"].bySection); Assert.Equal(new Dictionary {{Free, 116}}, report["10"].byStatus); Assert.Equal(new Dictionary {{Selectable, 116}}, report["10"].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 116}}, report["10"].byChannel); } [Fact] @@ -63,11 +67,14 @@ public void SummaryByCategoryLabel() Assert.Equal(new Dictionary {{"NO_SECTION", 116}}, report["Cat1"].bySection); Assert.Equal(new Dictionary {{Booked, 1}, {Free, 115}}, report["Cat1"].byStatus); Assert.Equal(new Dictionary {{Selectable, 115}, {NotSelectable, 1}}, report["Cat1"].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 116}}, report["Cat1"].byChannel); + Assert.Equal(116, report["Cat2"].Count); Assert.Equal(new Dictionary {{"NO_SECTION", 116}}, report["Cat2"].bySection); Assert.Equal(new Dictionary {{Free, 116}}, report["Cat2"].byStatus); Assert.Equal(new Dictionary {{Selectable, 116}}, report["Cat2"].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 116}}, report["Cat2"].byChannel); } [Fact] @@ -84,6 +91,7 @@ public void SummaryBySection() Assert.Equal(new Dictionary {{"9", 116}, {"10", 116}}, report["NO_SECTION"].byCategoryKey); Assert.Equal(new Dictionary {{"Cat1", 116}, {"Cat2", 116}}, report["NO_SECTION"].byCategoryLabel); Assert.Equal(new Dictionary {{Selectable, 231}, {NotSelectable, 1}}, report["NO_SECTION"].bySelectability); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 232}}, report["NO_SECTION"].byChannel); } [Fact] @@ -99,11 +107,43 @@ public void SummaryBySelectability() Assert.Equal(new Dictionary {{"NO_SECTION", 231}}, report[Selectable].bySection); Assert.Equal(new Dictionary {{Free, 231}}, report[Selectable].byStatus); Assert.Equal(new Dictionary {{"9", 115}, {"10", 116}}, report[Selectable].byCategoryKey); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 231}}, report[Selectable].byChannel); Assert.Equal(1, report[NotSelectable].Count); Assert.Equal(new Dictionary {{"NO_SECTION", 1}}, report[NotSelectable].bySection); Assert.Equal(new Dictionary {{Booked, 1}}, report[NotSelectable].byStatus); Assert.Equal(new Dictionary {{"9", 1}}, report[NotSelectable].byCategoryKey); + Assert.Equal(new Dictionary {{"NO_CHANNEL", 1}}, report[NotSelectable].byChannel); + } + + [Fact] + public void SummaryByChannel() + { + var chartKey = CreateTestChart(); + var evnt = Client.Events.Create(chartKey); + var channels = new Dictionary() + { + {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} + }; + Client.Events.UpdateChannels(evnt.Key, channels); + Client.Events.AssignObjectsToChannel(evnt.Key, new + { + channelKey1 = new[] {"A-1", "A-2"} + }); + + var report = Client.EventReports.SummaryByChannel(evnt.Key); + + Assert.Equal(230, report["NO_CHANNEL"].Count); + Assert.Equal(new Dictionary {{"NO_SECTION", 230}}, report["NO_CHANNEL"].bySection); + Assert.Equal(new Dictionary {{Free, 230}}, report["NO_CHANNEL"].byStatus); + Assert.Equal(new Dictionary {{"9", 114}, {"10", 116}}, report["NO_CHANNEL"].byCategoryKey); + Assert.Equal(new Dictionary {{Selectable, 230}}, report["NO_CHANNEL"].bySelectability); + + Assert.Equal(2, report["channelKey1"].Count); + Assert.Equal(new Dictionary {{"NO_SECTION", 2}}, report["channelKey1"].bySection); + Assert.Equal(new Dictionary {{Free, 2}}, report["channelKey1"].byStatus); + Assert.Equal(new Dictionary {{"9", 2}}, report["channelKey1"].byCategoryKey); + Assert.Equal(new Dictionary {{Selectable, 2}}, report["channelKey1"].bySelectability); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs index 61b2b0e..944290c 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs @@ -17,6 +17,16 @@ public void ReportItemProperties() var extraData = new Dictionary {{"foo", "bar"}}; Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1"); + var channels = new Dictionary() + { + {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} + }; + Client.Events.UpdateChannels(evnt.Key, channels); + Client.Events.AssignObjectsToChannel(evnt.Key, new + { + channelKey1 = new[] {"A-1"} + }); + var report = Client.EventReports.ByLabel(evnt.Key); var reportItem = report["A-1"].First(); @@ -42,6 +52,7 @@ public void ReportItemProperties() Assert.Equal("A-2", reportItem.RightNeighbour); Assert.False(reportItem.IsSelectable); Assert.False(reportItem.IsDisabledBySocialDistancing); + Assert.Equal("channelKey1", reportItem.Channel); } [Fact] @@ -272,5 +283,46 @@ public void BySpecificSelectability() Assert.Equal(2, report.Count()); } + + [Fact] + public void ByChannel() + { + var chartKey = CreateTestChart(); + var evnt = Client.Events.Create(chartKey); + var channels = new Dictionary() + { + {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} + }; + Client.Events.UpdateChannels(evnt.Key, channels); + Client.Events.AssignObjectsToChannel(evnt.Key, new + { + channelKey1 = new[] {"A-1", "A-2"} + }); + + var report = Client.EventReports.ByChannel(evnt.Key); + + Assert.Equal(32, report["NO_CHANNEL"].Count()); + Assert.Equal(2, report["channelKey1"].Count()); + } + + [Fact] + public void BySpecificChannel() + { + var chartKey = CreateTestChart(); + var evnt = Client.Events.Create(chartKey); + var channels = new Dictionary() + { + {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} + }; + Client.Events.UpdateChannels(evnt.Key, channels); + Client.Events.AssignObjectsToChannel(evnt.Key, new + { + channelKey1 = new[] {"A-1", "A-2"} + }); + + var report = Client.EventReports.ByChannel(evnt.Key, "channelKey1"); + + Assert.Equal(2, report.Count()); + } } -} +} \ No newline at end of file diff --git a/SeatsioDotNet/EventReports/EventReportItem.cs b/SeatsioDotNet/EventReports/EventReportItem.cs index e2b183c..35e3d6d 100644 --- a/SeatsioDotNet/EventReports/EventReportItem.cs +++ b/SeatsioDotNet/EventReports/EventReportItem.cs @@ -33,5 +33,6 @@ public class EventReportItem public string RightNeighbour { get; set; } public bool IsSelectable { get; set; } public bool? IsDisabledBySocialDistancing { get; set; } + public string Channel { get; set; } } } diff --git a/SeatsioDotNet/EventReports/EventReportSummaryItem.cs b/SeatsioDotNet/EventReports/EventReportSummaryItem.cs index 1e77457..108ff99 100644 --- a/SeatsioDotNet/EventReports/EventReportSummaryItem.cs +++ b/SeatsioDotNet/EventReports/EventReportSummaryItem.cs @@ -10,5 +10,6 @@ public class EventReportSummaryItem public Dictionary byCategoryLabel { get; set; } public Dictionary bySection { get; set; } public Dictionary bySelectability { get; set; } + public Dictionary byChannel { get; set; } } } \ No newline at end of file diff --git a/SeatsioDotNet/EventReports/EventReports.cs b/SeatsioDotNet/EventReports/EventReports.cs index d5bea6f..8610602 100644 --- a/SeatsioDotNet/EventReports/EventReports.cs +++ b/SeatsioDotNet/EventReports/EventReports.cs @@ -106,6 +106,21 @@ public Dictionary SummaryBySelectability(string public IEnumerable BySelectability(string eventKey, string selectability) { return FetchReport("bySelectability", eventKey, selectability); + } + + public Dictionary> ByChannel(string eventKey) + { + return FetchReport("byChannel", eventKey); + } + + public Dictionary SummaryByChannel(string eventKey) + { + return FetchSummaryReport("byChannel", eventKey); + } + + public IEnumerable ByChannel(string eventKey, string channelKey) + { + return FetchReport("byChannel", eventKey, channelKey); } private Dictionary> FetchReport(string reportType, string eventKey) diff --git a/SeatsioDotNet/SeatsioDotNet.csproj b/SeatsioDotNet/SeatsioDotNet.csproj index 9c342db..94e1cd0 100644 --- a/SeatsioDotNet/SeatsioDotNet.csproj +++ b/SeatsioDotNet/SeatsioDotNet.csproj @@ -2,7 +2,7 @@ Library true - 71.0.0 + 71.1.0 mroloux;bverbeken Official Seats.io .NET API client Official Seats.io .NET API client