From 56009994a7a8ab7fbe34f3fdfafc174f9f7b156a Mon Sep 17 00:00:00 2001 From: mroloux Date: Fri, 30 Oct 2020 16:03:03 +0100 Subject: [PATCH] Added support for bookWholeTables to chart reports --- .../ChartReports/ChartReportsTest.cs | 50 +++++++++++++++++-- .../resources/sampleChartWithTables.json | 1 + SeatsioDotNet/ChartReports/ChartReports.cs | 20 +++++--- SeatsioDotNet/SeatsioDotNet.csproj | 2 +- 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/SeatsioDotNet.Test/ChartReports/ChartReportsTest.cs b/SeatsioDotNet.Test/ChartReports/ChartReportsTest.cs index 7c96096..8d27c0c 100644 --- a/SeatsioDotNet.Test/ChartReports/ChartReportsTest.cs +++ b/SeatsioDotNet.Test/ChartReports/ChartReportsTest.cs @@ -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); @@ -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); @@ -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"]); @@ -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()); @@ -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); + } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/resources/sampleChartWithTables.json b/SeatsioDotNet.Test/resources/sampleChartWithTables.json index d72b1eb..549956a 100644 --- a/SeatsioDotNet.Test/resources/sampleChartWithTables.json +++ b/SeatsioDotNet.Test/resources/sampleChartWithTables.json @@ -170,6 +170,7 @@ "uuid": "uuid1432" } ], + "bookAsAWhole": true, "rotationAngle": 0, "openSpaces": 0, "label": "T2", diff --git a/SeatsioDotNet/ChartReports/ChartReports.cs b/SeatsioDotNet/ChartReports/ChartReports.cs index 5ebd991..5b95431 100644 --- a/SeatsioDotNet/ChartReports/ChartReports.cs +++ b/SeatsioDotNet/ChartReports/ChartReports.cs @@ -13,26 +13,32 @@ public ChartReports(RestClient restClient) _restClient = restClient; } - public Dictionary> ByLabel(string chartKey) + public Dictionary> ByLabel(string chartKey, string bookWholeTablesMode) { - return FetchReport("byLabel", chartKey); + return FetchReport("byLabel", chartKey, bookWholeTablesMode); } - public Dictionary> ByCategoryKey(string chartKey) + public Dictionary> ByCategoryKey(string chartKey, string bookWholeTablesMode) { - return FetchReport("byCategoryKey", chartKey); + return FetchReport("byCategoryKey", chartKey, bookWholeTablesMode); } - public Dictionary> ByCategoryLabel(string chartKey) + public Dictionary> ByCategoryLabel(string chartKey, string bookWholeTablesMode) { - return FetchReport("byCategoryLabel", chartKey); + return FetchReport("byCategoryLabel", chartKey, bookWholeTablesMode); } - private Dictionary> FetchReport(string reportType, string chartKey) + private Dictionary> 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>>(restRequest)); } } diff --git a/SeatsioDotNet/SeatsioDotNet.csproj b/SeatsioDotNet/SeatsioDotNet.csproj index 8f95e50..130df57 100644 --- a/SeatsioDotNet/SeatsioDotNet.csproj +++ b/SeatsioDotNet/SeatsioDotNet.csproj @@ -2,7 +2,7 @@ Library true - 73.0.0 + 74.0.0 mroloux;bverbeken Official Seats.io .NET API client Official Seats.io .NET API client