Skip to content

Commit

Permalink
Chart summary reports take bookWholeTables parameter (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Feb 1, 2022
1 parent 01e1c2d commit 636129c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
11 changes: 11 additions & 0 deletions SeatsioDotNet.Test/ChartReports/ChartReportsSummaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public void SummaryByObjectType()
report["generalAdmission"].byCategoryKey);
Assert.Equal(new Dictionary<string, int> {{"Cat1", 100}, {"Cat2", 100}},
report["generalAdmission"].byCategoryLabel);
}

[Fact]
public void SummaryByObjectType_BookWholeTablesTrue()
{
var chartKey = CreateTestChartWithTables();

var report = Client.ChartReports.SummaryByObjectType(chartKey, "true");

Assert.Equal(0, report["seat"].Count);
Assert.Equal(2, report["table"].Count);
}

[Fact]
Expand Down
16 changes: 8 additions & 8 deletions SeatsioDotNet.Test/ChartReports/ChartReportsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void ReportItemProperties()
{
var chartKey = CreateTestChart();

var report = Client.ChartReports.ByLabel(chartKey, null);
var report = Client.ChartReports.ByLabel(chartKey);

var reportItem = report["A-1"].First();
Assert.Equal("A-1", reportItem.Label);
Expand All @@ -35,7 +35,7 @@ public void ReportItemPropertiesForGA()
{
var chartKey = CreateTestChart();

var report = Client.ChartReports.ByLabel(chartKey, null);
var report = Client.ChartReports.ByLabel(chartKey);

var reportItem = report["GA1"].First();
Assert.Equal(100, reportItem.Capacity);
Expand All @@ -48,7 +48,7 @@ public void ByLabel()
{
var chartKey = CreateTestChart();

var report = Client.ChartReports.ByLabel(chartKey, null);
var report = Client.ChartReports.ByLabel(chartKey);

Assert.Single(report["A-1"]);
Assert.Single(report["A-2"]);
Expand All @@ -59,7 +59,7 @@ public void ByObjectType()
{
var chartKey = CreateTestChart();

var report = Client.ChartReports.ByObjectType(chartKey, null);
var report = Client.ChartReports.ByObjectType(chartKey);

Assert.Equal(32, report["seat"].Count());
Assert.Equal(2, report["generalAdmission"].Count());
Expand All @@ -71,7 +71,7 @@ public void ByObjectType()
public void ByCategoryKey()
{
var chartKey = CreateTestChart();
var report = Client.ChartReports.ByCategoryKey(chartKey, null);
var report = Client.ChartReports.ByCategoryKey(chartKey);
Assert.Equal(3, report.Count);
Assert.Equal(17, report["9"].Count());
Assert.Equal(17, report["10"].Count());
Expand All @@ -82,7 +82,7 @@ public void ByCategoryKey()
public void ByCategoryLabel()
{
var chartKey = CreateTestChart();
var report = Client.ChartReports.ByCategoryLabel(chartKey, null);
var report = Client.ChartReports.ByCategoryLabel(chartKey);
Assert.Equal(3, report.Count);
Assert.Equal(17, report["Cat1"].Count());
Assert.Equal(17, report["Cat2"].Count());
Expand All @@ -93,7 +93,7 @@ public void ByCategoryLabel()
public void BySection()
{
var chartKey = CreateTestChartWithSections();
var report = Client.ChartReports.BySection(chartKey, null);
var report = Client.ChartReports.BySection(chartKey);
Assert.Equal(3, report.Count);
Assert.Equal(36, report["Section A"].Count());
Assert.Equal(35, report["Section B"].Count());
Expand All @@ -105,7 +105,7 @@ public void ByLabel_BookWholeTablesModeNull()
{
var chartKey = CreateTestChartWithTables();

var report = Client.ChartReports.ByLabel(chartKey, null);
var report = Client.ChartReports.ByLabel(chartKey);

CustomAssert.ContainsOnly(new [] {"T1-1", "T1-2", "T1-3", "T1-4", "T1-5", "T1-6", "T2-1", "T2-2", "T2-3", "T2-4", "T2-5", "T2-6", "T1", "T2"}, report.Keys);
}
Expand Down
34 changes: 20 additions & 14 deletions SeatsioDotNet/ChartReports/ChartReports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@ public ChartReports(RestClient restClient)
_restClient = restClient;
}

public Dictionary<string, IEnumerable<ChartObjectInfo>> ByLabel(string chartKey, string bookWholeTablesMode)
public Dictionary<string, IEnumerable<ChartObjectInfo>> ByLabel(string chartKey, string bookWholeTablesMode = null)
{
return FetchReport("byLabel", chartKey, bookWholeTablesMode);
}

public Dictionary<string, IEnumerable<ChartObjectInfo>> ByObjectType(string chartKey, string bookWholeTablesMode)
public Dictionary<string, IEnumerable<ChartObjectInfo>> ByObjectType(string chartKey, string bookWholeTablesMode = null)
{
return FetchReport("byObjectType", chartKey, bookWholeTablesMode);
}

public Dictionary<string, ChartReportSummaryItem> SummaryByObjectType(string chartKey)
public Dictionary<string, ChartReportSummaryItem> SummaryByObjectType(string chartKey, string bookWholeTablesMode = null)
{
return FetchSummaryReport("byObjectType", chartKey);
return FetchSummaryReport("byObjectType", chartKey, bookWholeTablesMode);
}

public Dictionary<string, IEnumerable<ChartObjectInfo>> ByCategoryKey(string chartKey, string bookWholeTablesMode)
public Dictionary<string, IEnumerable<ChartObjectInfo>> ByCategoryKey(string chartKey, string bookWholeTablesMode = null)
{
return FetchReport("byCategoryKey", chartKey, bookWholeTablesMode);
}

public Dictionary<string, ChartReportSummaryItem> SummaryByCategoryKey(string chartKey)
public Dictionary<string, ChartReportSummaryItem> SummaryByCategoryKey(string chartKey, string bookWholeTablesMode = null)
{
return FetchSummaryReport("byCategoryKey", chartKey);
return FetchSummaryReport("byCategoryKey", chartKey, bookWholeTablesMode);
}

public Dictionary<string, IEnumerable<ChartObjectInfo>> ByCategoryLabel(string chartKey, string bookWholeTablesMode)
public Dictionary<string, IEnumerable<ChartObjectInfo>> ByCategoryLabel(string chartKey, string bookWholeTablesMode = null)
{
return FetchReport("byCategoryLabel", chartKey, bookWholeTablesMode);
}

public Dictionary<string, ChartReportSummaryItem> SummaryByCategoryLabel(string chartKey)
public Dictionary<string, ChartReportSummaryItem> SummaryByCategoryLabel(string chartKey, string bookWholeTablesMode = null)
{
return FetchSummaryReport("byCategoryLabel", chartKey);
return FetchSummaryReport("byCategoryLabel", chartKey, bookWholeTablesMode);
}

public Dictionary<string, IEnumerable<ChartObjectInfo>> BySection(string chartKey, string bookWholeTablesMode)
public Dictionary<string, IEnumerable<ChartObjectInfo>> BySection(string chartKey, string bookWholeTablesMode = null)
{
return FetchReport("bySection", chartKey, bookWholeTablesMode);
}

public Dictionary<string, ChartReportSummaryItem> SummaryBySection(string eventKey)
public Dictionary<string, ChartReportSummaryItem> SummaryBySection(string eventKey, string bookWholeTablesMode = null)
{
return FetchSummaryReport("bySection", eventKey);
return FetchSummaryReport("bySection", eventKey, bookWholeTablesMode);
}

private Dictionary<string, IEnumerable<ChartObjectInfo>> FetchReport(string reportType, string chartKey, string bookWholeTablesMode)
Expand All @@ -72,11 +72,17 @@ private Dictionary<string, IEnumerable<ChartObjectInfo>> FetchReport(string repo
return AssertOk(_restClient.Execute<Dictionary<string, IEnumerable<ChartObjectInfo>>>(restRequest));
}

private Dictionary<string, ChartReportSummaryItem> FetchSummaryReport(string reportType, string chartKey)
private Dictionary<string, ChartReportSummaryItem> FetchSummaryReport(string reportType, string chartKey, string bookWholeTablesMode)
{
var restRequest = new RestRequest("/reports/charts/{key}/{reportType}/summary", Method.GET)
.AddUrlSegment("key", chartKey)
.AddUrlSegment("reportType", reportType);

if (bookWholeTablesMode != null)
{
restRequest.AddQueryParameter("bookWholeTables", bookWholeTablesMode);
}

return AssertOk(_restClient.Execute<Dictionary<string, ChartReportSummaryItem>>(restRequest));
}

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>84.2.0</Version>
<Version>84.3.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 636129c

Please sign in to comment.