Skip to content

Commit

Permalink
Added support for bookWholeTables to chart reports
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Oct 30, 2020
1 parent 31dde13 commit 5600999
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
50 changes: 45 additions & 5 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);
var report = Client.ChartReports.ByLabel(chartKey, null);

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

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

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

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

Assert.Single(report["A-1"]);
Assert.Single(report["A-2"]);
Expand All @@ -54,7 +54,7 @@ public void ByLabel()
public void ByCategoryKey()
{
var chartKey = CreateTestChart();
var report = Client.ChartReports.ByCategoryKey(chartKey);
var report = Client.ChartReports.ByCategoryKey(chartKey, null);
Assert.Equal(2, report.Count);
Assert.Equal(17, report["9"].Count());
Assert.Equal(17, report["10"].Count());
Expand All @@ -64,10 +64,50 @@ public void ByCategoryKey()
public void ByCategoryLabel()
{
var chartKey = CreateTestChart();
var report = Client.ChartReports.ByCategoryLabel(chartKey);
var report = Client.ChartReports.ByCategoryLabel(chartKey, null);
Assert.Equal(2, report.Count);
Assert.Equal(17, report["Cat1"].Count());
Assert.Equal(17, report["Cat2"].Count());
}

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

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

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);
}

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

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

CustomAssert.ContainsOnly(new [] {"T1-1", "T1-2", "T1-3", "T1-4", "T1-5", "T1-6", "T2"}, report.Keys);
}

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

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

CustomAssert.ContainsOnly(new [] {"T1", "T2"}, report.Keys);
}

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

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

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"}, report.Keys);
}
}
}
1 change: 1 addition & 0 deletions SeatsioDotNet.Test/resources/sampleChartWithTables.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"uuid": "uuid1432"
}
],
"bookAsAWhole": true,
"rotationAngle": 0,
"openSpaces": 0,
"label": "T2",
Expand Down
20 changes: 13 additions & 7 deletions SeatsioDotNet/ChartReports/ChartReports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,32 @@ public ChartReports(RestClient restClient)
_restClient = restClient;
}

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

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

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

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

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

return AssertOk(_restClient.Execute<Dictionary<string, IEnumerable<ChartReportItem>>>(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>73.0.0</Version>
<Version>74.0.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 5600999

Please sign in to comment.