From 2355d3e7746221eaf3b9a35f3bc34c047555005f Mon Sep 17 00:00:00 2001 From: mroloux Date: Fri, 23 Aug 2019 14:48:11 +0200 Subject: [PATCH] Exposed accessible flag on categories --- SeatsioDotNet.Test/Charts/CreateChartTest.cs | 8 +++++++- SeatsioDotNet.Test/Charts/UpdateChartTest.cs | 2 +- SeatsioDotNet/Charts/Category.cs | 12 ++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/SeatsioDotNet.Test/Charts/CreateChartTest.cs b/SeatsioDotNet.Test/Charts/CreateChartTest.cs index 6fb55ea..6ef23a3 100644 --- a/SeatsioDotNet.Test/Charts/CreateChartTest.cs +++ b/SeatsioDotNet.Test/Charts/CreateChartTest.cs @@ -59,7 +59,7 @@ public void Categories() var chart = Client.Charts.Create(null, null, new[] { new Category(1, "Category 1", "#aaaaaa"), - new Category(2, "Category 2", "#bbbbbb"), + new Category(2, "Category 2", "#bbbbbb", true), new Category("cat-3", "Category 3", "#cccccc") }); @@ -68,13 +68,19 @@ public void Categories() Assert.Equal("Untitled chart", retrievedChart.Name); var drawing = Client.Charts.RetrievePublishedVersion(chart.Key); var actualCategories = drawing.Categories; + Assert.Equal(3, actualCategories.Count); + Assert.Equal(1L, actualCategories[0].Key); Assert.Equal("Category 1", actualCategories[0].Label); Assert.Equal("#aaaaaa", actualCategories[0].Color); + Assert.False(actualCategories[0].Accessible); + Assert.Equal(2L, actualCategories[1].Key); Assert.Equal("Category 2", actualCategories[1].Label); Assert.Equal("#bbbbbb", actualCategories[1].Color); + Assert.True(actualCategories[1].Accessible); + Assert.Equal("cat-3", actualCategories[2].Key); } } diff --git a/SeatsioDotNet.Test/Charts/UpdateChartTest.cs b/SeatsioDotNet.Test/Charts/UpdateChartTest.cs index 5678c62..f81aab4 100644 --- a/SeatsioDotNet.Test/Charts/UpdateChartTest.cs +++ b/SeatsioDotNet.Test/Charts/UpdateChartTest.cs @@ -24,7 +24,7 @@ public void Categories() { var chart = Client.Charts.Create("aChart", "BOOTHS"); - Client.Charts.Update(chart.Key, categories: new[] {new Category(1, "Category 1", "#aaaaaa"), new Category("cat-2", "Category 2", "#bbbbbb")}); + Client.Charts.Update(chart.Key, categories: new[] {new Category(1, "Category 1", "#aaaaaa"), new Category("cat-2", "Category 2", "#bbbbbb", true)}); Chart retrievedChart = Client.Charts.Retrieve(chart.Key); Assert.Equal("aChart", retrievedChart.Name); diff --git a/SeatsioDotNet/Charts/Category.cs b/SeatsioDotNet/Charts/Category.cs index f920eff..d6fde12 100644 --- a/SeatsioDotNet/Charts/Category.cs +++ b/SeatsioDotNet/Charts/Category.cs @@ -7,23 +7,26 @@ public class Category public object Key { get; set; } public string Label { get; set; } public string Color { get; set; } + public bool? Accessible { get; set; } public Category() { } - public Category(int key, string label, string color) + public Category(int key, string label, string color, bool? accessible = false) { Key = key; Label = label; Color = color; + Accessible = accessible; } - public Category(string key, string label, string color) + public Category(string key, string label, string color, bool? accessible = false) { Key = key; Label = label; Color = color; + Accessible = accessible; } public Dictionary AsDictionary() @@ -43,6 +46,11 @@ public Dictionary AsDictionary() if (Color != null) { dictionary.Add("color", Color); + } + + if (Accessible != null) + { + dictionary.Add("accessible", Accessible); } return dictionary;