Skip to content

Commit

Permalink
Added event report by channel
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Oct 2, 2020
1 parent a5e89b1 commit 939d461
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 2 deletions.
40 changes: 40 additions & 0 deletions SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public void SummaryByStatus()
Assert.Equal(new Dictionary<string, int> {{"9", 1}}, report[Booked].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{"Cat1", 1}}, report[Booked].byCategoryLabel);
Assert.Equal(new Dictionary<string, int> {{NotSelectable, 1}}, report[Booked].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 1}}, report[Booked].byChannel);

Assert.Equal(231, report[Free].Count);
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 231}}, report[Free].bySection);
Assert.Equal(new Dictionary<string, int> {{"9", 115}, {"10", 116}}, report[Free].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{"Cat1", 115}, {"Cat2", 116}}, report[Free].byCategoryLabel);
Assert.Equal(new Dictionary<string, int> {{Selectable, 231}}, report[Free].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 231}}, report[Free].byChannel);
}

[Fact]
Expand All @@ -43,11 +45,13 @@ public void SummaryByCategoryKey()
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 116}}, report["9"].bySection);
Assert.Equal(new Dictionary<string, int> {{Booked, 1}, {Free, 115}}, report["9"].byStatus);
Assert.Equal(new Dictionary<string, int> {{Selectable, 115}, {NotSelectable, 1}}, report["9"].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 116}}, report["9"].byChannel);

Assert.Equal(116, report["10"].Count);
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 116}}, report["10"].bySection);
Assert.Equal(new Dictionary<string, int> {{Free, 116}}, report["10"].byStatus);
Assert.Equal(new Dictionary<string, int> {{Selectable, 116}}, report["10"].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 116}}, report["10"].byChannel);
}

[Fact]
Expand All @@ -63,11 +67,14 @@ public void SummaryByCategoryLabel()
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 116}}, report["Cat1"].bySection);
Assert.Equal(new Dictionary<string, int> {{Booked, 1}, {Free, 115}}, report["Cat1"].byStatus);
Assert.Equal(new Dictionary<string, int> {{Selectable, 115}, {NotSelectable, 1}}, report["Cat1"].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 116}}, report["Cat1"].byChannel);


Assert.Equal(116, report["Cat2"].Count);
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 116}}, report["Cat2"].bySection);
Assert.Equal(new Dictionary<string, int> {{Free, 116}}, report["Cat2"].byStatus);
Assert.Equal(new Dictionary<string, int> {{Selectable, 116}}, report["Cat2"].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 116}}, report["Cat2"].byChannel);
}

[Fact]
Expand All @@ -84,6 +91,7 @@ public void SummaryBySection()
Assert.Equal(new Dictionary<string, int> {{"9", 116}, {"10", 116}}, report["NO_SECTION"].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{"Cat1", 116}, {"Cat2", 116}}, report["NO_SECTION"].byCategoryLabel);
Assert.Equal(new Dictionary<string, int> {{Selectable, 231}, {NotSelectable, 1}}, report["NO_SECTION"].bySelectability);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 232}}, report["NO_SECTION"].byChannel);
}

[Fact]
Expand All @@ -99,11 +107,43 @@ public void SummaryBySelectability()
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 231}}, report[Selectable].bySection);
Assert.Equal(new Dictionary<string, int> {{Free, 231}}, report[Selectable].byStatus);
Assert.Equal(new Dictionary<string, int> {{"9", 115}, {"10", 116}}, report[Selectable].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 231}}, report[Selectable].byChannel);

Assert.Equal(1, report[NotSelectable].Count);
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 1}}, report[NotSelectable].bySection);
Assert.Equal(new Dictionary<string, int> {{Booked, 1}}, report[NotSelectable].byStatus);
Assert.Equal(new Dictionary<string, int> {{"9", 1}}, report[NotSelectable].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{"NO_CHANNEL", 1}}, report[NotSelectable].byChannel);
}

[Fact]
public void SummaryByChannel()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{"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<string, int> {{"NO_SECTION", 230}}, report["NO_CHANNEL"].bySection);
Assert.Equal(new Dictionary<string, int> {{Free, 230}}, report["NO_CHANNEL"].byStatus);
Assert.Equal(new Dictionary<string, int> {{"9", 114}, {"10", 116}}, report["NO_CHANNEL"].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{Selectable, 230}}, report["NO_CHANNEL"].bySelectability);

Assert.Equal(2, report["channelKey1"].Count);
Assert.Equal(new Dictionary<string, int> {{"NO_SECTION", 2}}, report["channelKey1"].bySection);
Assert.Equal(new Dictionary<string, int> {{Free, 2}}, report["channelKey1"].byStatus);
Assert.Equal(new Dictionary<string, int> {{"9", 2}}, report["channelKey1"].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{Selectable, 2}}, report["channelKey1"].bySelectability);
}
}
}
54 changes: 53 additions & 1 deletion SeatsioDotNet.Test/EventReports/EventReportsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ public void ReportItemProperties()
var extraData = new Dictionary<string, object> {{"foo", "bar"}};
Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1");

var channels = new Dictionary<string, Channel>()
{
{"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();
Expand All @@ -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]
Expand Down Expand Up @@ -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<string, Channel>()
{
{"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<string, Channel>()
{
{"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());
}
}
}
}
1 change: 1 addition & 0 deletions SeatsioDotNet/EventReports/EventReportItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
1 change: 1 addition & 0 deletions SeatsioDotNet/EventReports/EventReportSummaryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class EventReportSummaryItem
public Dictionary<string, int> byCategoryLabel { get; set; }
public Dictionary<string, int> bySection { get; set; }
public Dictionary<string, int> bySelectability { get; set; }
public Dictionary<string, int> byChannel { get; set; }
}
}
15 changes: 15 additions & 0 deletions SeatsioDotNet/EventReports/EventReports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ public Dictionary<string, EventReportSummaryItem> SummaryBySelectability(string
public IEnumerable<EventReportItem> BySelectability(string eventKey, string selectability)
{
return FetchReport("bySelectability", eventKey, selectability);
}

public Dictionary<string, IEnumerable<EventReportItem>> ByChannel(string eventKey)
{
return FetchReport("byChannel", eventKey);
}

public Dictionary<string, EventReportSummaryItem> SummaryByChannel(string eventKey)
{
return FetchSummaryReport("byChannel", eventKey);
}

public IEnumerable<EventReportItem> ByChannel(string eventKey, string channelKey)
{
return FetchReport("byChannel", eventKey, channelKey);
}

private Dictionary<string, IEnumerable<EventReportItem>> FetchReport(string reportType, string eventKey)
Expand Down
2 changes: 1 addition & 1 deletion SeatsioDotNet/SeatsioDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<Version>71.0.0</Version>
<Version>71.1.0</Version>
<Authors>mroloux;bverbeken</Authors>
<Title>Official Seats.io .NET API client</Title>
<Description>Official Seats.io .NET API client</Description>
Expand Down

0 comments on commit 939d461

Please sign in to comment.