diff --git a/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs index 574cb23..62849c2 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs @@ -29,8 +29,8 @@ public void SummaryByStatus() Assert.Equal(new() {{"Cat1", 115}, {"Cat2", 116}}, report[Free].byCategoryLabel); Assert.Equal(new() {{Available, 231}}, report[Free].byAvailability); Assert.Equal(new() {{NoChannel, 231}}, report[Free].byChannel); - } - + } + [Fact] public void SummaryByObjectType() { @@ -52,8 +52,8 @@ public void SummaryByObjectType() Assert.Equal(new() {{"Cat1", 100}, {"Cat2", 100}}, report["generalAdmission"].byCategoryLabel); Assert.Equal(new() {{Available, 200}}, report["generalAdmission"].byAvailability); Assert.Equal(new() {{NoChannel, 200}}, report["generalAdmission"].byChannel); - } - + } + [Fact] public void SummaryByCategoryKey() { @@ -74,10 +74,10 @@ public void SummaryByCategoryKey() Assert.Equal(new() {{Free, 116}}, report["10"].byStatus); Assert.Equal(new() {{Available, 116}}, report["10"].byAvailability); Assert.Equal(new() {{NoChannel, 116}}, report["10"].byChannel); - + Assert.Equal(0, report["NO_CATEGORY"].Count); - } - + } + [Fact] public void SummaryByCategoryLabel() { @@ -99,7 +99,7 @@ public void SummaryByCategoryLabel() Assert.Equal(new() {{Free, 116}}, report["Cat2"].byStatus); Assert.Equal(new() {{Available, 116}}, report["Cat2"].byAvailability); Assert.Equal(new() {{NoChannel, 116}}, report["Cat2"].byChannel); - + Assert.Equal(0, report["NO_CATEGORY"].Count); } @@ -119,7 +119,7 @@ public void SummaryBySection() Assert.Equal(new() {{Available, 231}, {NotAvailable, 1}}, report[NoSection].byAvailability); Assert.Equal(new() {{NoChannel, 232}}, report[NoSection].byChannel); } - + [Fact] public void SummaryByAvailability() { @@ -140,8 +140,8 @@ public void SummaryByAvailability() Assert.Equal(new() {{Booked, 1}}, report[NotAvailable].byStatus); Assert.Equal(new() {{"9", 1}}, report[NotAvailable].byCategoryKey); Assert.Equal(new() {{NoChannel, 1}}, report[NotAvailable].byChannel); - } - + } + [Fact] public void SummaryByAvailabilityReason() { @@ -162,23 +162,18 @@ public void SummaryByAvailabilityReason() Assert.Equal(new() {{Booked, 1}}, report[Booked].byStatus); Assert.Equal(new() {{"9", 1}}, report[Booked].byCategoryKey); Assert.Equal(new() {{NoChannel, 1}}, report[Booked].byChannel); - } - + } + [Fact] public void SummaryByChannel() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new[] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); - + var report = Client.EventReports.SummaryByChannel(evnt.Key); Assert.Equal(230, report[NoChannel].Count); diff --git a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs index 804c7b8..8d9c5be 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs @@ -17,14 +17,9 @@ public void ReportItemProperties() var extraData = new Dictionary {{"foo", "bar"}}; Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1"); - var channels = new Dictionary() + Client.Events.Channels.Replace(evnt.Key, new List { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new - { - channelKey1 = new[] {"A-1"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"}) }); var report = Client.EventReports.ByLabel(evnt.Key); @@ -356,14 +351,9 @@ public void ByChannel() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new[] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); var report = Client.EventReports.ByChannel(evnt.Key); @@ -377,14 +367,9 @@ public void BySpecificChannel() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new[] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); var report = Client.EventReports.ByChannel(evnt.Key, "channelKey1"); diff --git a/SeatsioDotNet.Test/Events/BookObjectsTest.cs b/SeatsioDotNet.Test/Events/BookObjectsTest.cs index 92aa21c..ee5a9ae 100644 --- a/SeatsioDotNet.Test/Events/BookObjectsTest.cs +++ b/SeatsioDotNet.Test/Events/BookObjectsTest.cs @@ -93,14 +93,9 @@ public void ChannelKeys() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() + Client.Events.Channels.Replace(evnt.Key, new List { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) } - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new - { - channelKey1 = new [] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"}); @@ -113,14 +108,9 @@ public void IgnoreChannels() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) } - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new [] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, true); diff --git a/SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs b/SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs index 443e99d..c9f3993 100644 --- a/SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs +++ b/SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs @@ -150,14 +150,9 @@ public void ChannelKeys() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() + Client.Events.Channels.Replace(evnt.Key, new List { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new - { - channelKey1 = new[] {"A-6"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-6"}) }); var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", channelKeys: new[] {"channelKey1"}); @@ -170,14 +165,9 @@ public void IgnoreChannels() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new[] {"A-5"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-5"}) }); var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", ignoreChannels: true); diff --git a/SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs b/SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs index 3935ab8..870d0c5 100644 --- a/SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs +++ b/SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs @@ -32,14 +32,9 @@ public void ChannelKeys() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() + Client.Events.Channels.Replace(evnt.Key, new List { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new - { - channelKey1 = new[] {"A-1"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"}) }); var result = Client.Events.ChangeObjectStatus(new[] @@ -55,14 +50,9 @@ public void IgnoreChannels() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - {"channelKey1", new Channel("channel 1", "#FFFF00", 1)} - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new[] {"A-1"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"}) }); var result = Client.Events.ChangeObjectStatus(new[] diff --git a/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs b/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs index e68bd7c..ee379ce 100644 --- a/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs +++ b/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs @@ -3,21 +3,20 @@ using SeatsioDotNet.Events; using Xunit; - namespace SeatsioDotNet.Test.Events { public class ReplaceChannelsTest : SeatsioClientTest { - [Fact] - public void UpdateChannels() { + public void UpdateChannels() + { var chartKey1 = CreateTestChart(); var event1 = Client.Events.Create(chartKey1); - var channels = new Dictionary() + var channels = new List() { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) }, - { "channelKey2", new Channel("channel 2", "#00FFFF", 2) } + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}), + new("channelKey2", "channel 2", "#00FFFF", 2, new String[] { }) }; Client.Events.Channels.Replace(event1.Key, channels); @@ -30,16 +29,14 @@ public void UpdateChannels() { Assert.Equal("channel 1", channel1.Name); Assert.Equal("#FFFF00", channel1.Color); Assert.Equal(1, channel1.Index); - Assert.Empty(channel1.Objects); - + Assert.Equal(new List() {"A-1", "A-2"}, channel1.Objects); var channel2 = retrievedEvent.Channels[1]; Assert.Equal("channelKey2", channel2.Key); Assert.Equal("channel 2", channel2.Name); Assert.Equal("#00FFFF", channel2.Color); Assert.Equal(2, channel2.Index); - Assert.Empty(channel1.Objects); + Assert.Empty(channel2.Objects); } - } -} +} \ No newline at end of file diff --git a/SeatsioDotNet.Test/Events/Channels/SetObjectsForChannelTest.cs b/SeatsioDotNet.Test/Events/Channels/SetObjectsForChannelTest.cs deleted file mode 100644 index 41dd013..0000000 --- a/SeatsioDotNet.Test/Events/Channels/SetObjectsForChannelTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using SeatsioDotNet.Events; -using Xunit; - - -namespace SeatsioDotNet.Test.Events -{ - public class SetObjectsForChannelTest : SeatsioClientTest - { - - [Fact] - public void SetObjectsForChannel() { - var chartKey1 = CreateTestChart(); - var event1 = Client.Events.Create(chartKey1); - var channels = new Dictionary() - { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) }, - { "channelKey2", new Channel("channel 2", "#00FFFF", 2) } - }; - Client.Events.Channels.Replace(event1.Key, channels); - - Client.Events.Channels.SetObjects(event1.Key, new - { - channelKey1 = new [] {"A-1", "A-2"}, - channelKey2 = new [] {"A-3"}, - }); - - var retrievedChannels = Client.Events.Retrieve(event1.Key).Channels; - Assert.Equal(new [] {"A-1", "A-2"}, retrievedChannels[0].Objects); - Assert.Equal(new [] {"A-3"}, retrievedChannels[1].Objects); - } - } -} diff --git a/SeatsioDotNet.Test/Events/HoldObjectsTest.cs b/SeatsioDotNet.Test/Events/HoldObjectsTest.cs index 814e758..7412cfb 100644 --- a/SeatsioDotNet.Test/Events/HoldObjectsTest.cs +++ b/SeatsioDotNet.Test/Events/HoldObjectsTest.cs @@ -76,14 +76,9 @@ public void ChannelKeys() var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); HoldToken holdToken = Client.HoldTokens.Create(); - var channels = new Dictionary() + Client.Events.Channels.Replace(evnt.Key, new List { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) } - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new - { - channelKey1 = new [] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, true, null, new[] {"channelKey1"}); @@ -97,14 +92,9 @@ public void IgnoreChannels() var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); HoldToken holdToken = Client.HoldTokens.Create(); - var channels = new Dictionary() - { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) } - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new [] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, true, true); diff --git a/SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs b/SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs index 3646be9..87b8572 100644 --- a/SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs +++ b/SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs @@ -72,14 +72,9 @@ public void ChannelKeys() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() + Client.Events.Channels.Replace(evnt.Key, new List { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) } - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new - { - channelKey1 = new [] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"}); @@ -94,14 +89,9 @@ public void IgnoreChannels() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey); - var channels = new Dictionary() - { - { "channelKey1", new Channel("channel 1", "#FFFF00", 1) } - }; - Client.Events.Channels.Replace(evnt.Key, channels); - Client.Events.Channels.SetObjects(evnt.Key, new + Client.Events.Channels.Replace(evnt.Key, new List { - channelKey1 = new [] {"A-1", "A-2"} + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) }); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"}); diff --git a/SeatsioDotNet/Events/Channel.cs b/SeatsioDotNet/Events/Channel.cs index 1b11005..7f822ba 100644 --- a/SeatsioDotNet/Events/Channel.cs +++ b/SeatsioDotNet/Events/Channel.cs @@ -10,24 +10,17 @@ public class Channel public int Index { get; set; } public IEnumerable Objects { get; set; } - public Channel() {} + public Channel() + { + } - public Channel(string name, string color, int index) + public Channel(string key, string name, string color, int index, IEnumerable objects) { + Key = key; Name = name; Color = color; Index = index; + Objects = objects; } - - public object AsJsonObject() - { - return new - { - name = Name, - index = Index, - color = Color - }; - } - } -} +} \ No newline at end of file diff --git a/SeatsioDotNet/Events/Channels.cs b/SeatsioDotNet/Events/Channels.cs index db53e9f..57a424f 100644 --- a/SeatsioDotNet/Events/Channels.cs +++ b/SeatsioDotNet/Events/Channels.cs @@ -13,41 +13,19 @@ public Channels(RestClient restClient) _restClient = restClient; } - public void Replace(string eventKey, Dictionary channels) + public void Replace(string eventKey, List channels) { - var requestBody = UpdateChannelsRequest(channels); - var restRequest = new RestRequest("/events/{key}/channels/update", Method.Post) + var requestBody = ReplaceChannelsRequest(channels); + var restRequest = new RestRequest("/events/{key}/channels/replace", Method.Post) .AddUrlSegment("key", eventKey) .AddJsonBody(requestBody); AssertOk(_restClient.Execute(restRequest)); } - private Dictionary UpdateChannelsRequest(Dictionary channels) - { - var channelsJson = new Dictionary(); - foreach (KeyValuePair entry in channels) - { - channelsJson.Add(entry.Key, entry.Value.AsJsonObject()); - } - - var request = new Dictionary(); - request.Add("channels", channelsJson); - return request; - } - - public void SetObjects(string eventKey, object channelsConfig) - { - var requestBody = AssignObjectsToChannelsRequest(channelsConfig); - var restRequest = new RestRequest("/events/{key}/channels/assign-objects", Method.Post) - .AddUrlSegment("key", eventKey) - .AddJsonBody(requestBody); - AssertOk(_restClient.Execute(restRequest)); - } - - private Dictionary AssignObjectsToChannelsRequest(object channelsConfig) + private Dictionary ReplaceChannelsRequest(List channels) { var request = new Dictionary(); - request.Add("channelConfig", channelsConfig); + request.Add("channels", channels); return request; }