diff --git a/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs index 62849c2..07c408f 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs @@ -168,11 +168,11 @@ public void SummaryByAvailabilityReason() public void SummaryByChannel() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); var report = Client.EventReports.SummaryByChannel(evnt.Key); diff --git a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs index 606b2f5..d4f27a3 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs @@ -13,14 +13,13 @@ public class EventReportsTest : SeatsioClientTest public void ReportItemProperties() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - var extraData = new Dictionary {{"foo", "bar"}}; - Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1"); - - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { - new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"}) - }); + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); + var extraData = new Dictionary {{"foo", "bar"}}; + Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1", null, true); var report = Client.EventReports.ByLabel(evnt.Key); @@ -354,11 +353,11 @@ public void BySpecificAvailabilityReason() public void ByChannel() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); var report = Client.EventReports.ByChannel(evnt.Key); @@ -370,11 +369,11 @@ public void ByChannel() public void BySpecificChannel() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); var report = Client.EventReports.ByChannel(evnt.Key, "channelKey1"); diff --git a/SeatsioDotNet.Test/Events/BookObjectsTest.cs b/SeatsioDotNet.Test/Events/BookObjectsTest.cs index 9d8358c..f3cc9a2 100644 --- a/SeatsioDotNet.Test/Events/BookObjectsTest.cs +++ b/SeatsioDotNet.Test/Events/BookObjectsTest.cs @@ -92,11 +92,11 @@ public void KeepExtraData() public void ChannelKeys() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"}); @@ -107,11 +107,11 @@ public void ChannelKeys() public void IgnoreChannels() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); 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 c9f3993..18ab317 100644 --- a/SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs +++ b/SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs @@ -149,12 +149,12 @@ public void NoKeepExtraData() public void ChannelKeys() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-6"}) - }); - + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); + var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", channelKeys: new[] {"channelKey1"}); Assert.Equal(new[] {"A-6"}, bestAvailableResult.Objects); @@ -164,11 +164,11 @@ public void ChannelKeys() public void IgnoreChannels() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-5"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); 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 870d0c5..6c21095 100644 --- a/SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs +++ b/SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs @@ -31,11 +31,11 @@ public void Test() public void ChannelKeys() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); var result = Client.Events.ChangeObjectStatus(new[] { @@ -49,12 +49,12 @@ public void ChannelKeys() public void IgnoreChannels() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"}) - }); - + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); + var result = Client.Events.ChangeObjectStatus(new[] { new StatusChangeRequest(evnt.Key, new[] {"A-1"}, "lolzor", ignoreChannels: true), diff --git a/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs b/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs index ee379ce..2a76716 100644 --- a/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs +++ b/SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs @@ -13,7 +13,7 @@ public void UpdateChannels() var chartKey1 = CreateTestChart(); var event1 = Client.Events.Create(chartKey1); - var channels = new List() + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}), new("channelKey2", "channel 2", "#00FFFF", 2, new String[] { }) @@ -22,21 +22,7 @@ public void UpdateChannels() Client.Events.Channels.Replace(event1.Key, channels); var retrievedEvent = Client.Events.Retrieve(event1.Key); - Assert.Equal(2, retrievedEvent.Channels.Count); - - var channel1 = retrievedEvent.Channels[0]; - Assert.Equal("channelKey1", channel1.Key); - Assert.Equal("channel 1", channel1.Name); - Assert.Equal("#FFFF00", channel1.Color); - Assert.Equal(1, channel1.Index); - 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(channel2.Objects); + Assert.Equivalent(channels, retrievedEvent.Channels); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/Events/CreateEventTest.cs b/SeatsioDotNet.Test/Events/CreateEventTest.cs index bbd56db..cfcafb6 100644 --- a/SeatsioDotNet.Test/Events/CreateEventTest.cs +++ b/SeatsioDotNet.Test/Events/CreateEventTest.cs @@ -42,7 +42,8 @@ public void TableBookingModeCustomCanBeUsed() var chartKey = CreateTestChartWithTables(); var tableBookingConfig = TableBookingConfig.Custom(new() {{"T1", "BY_TABLE"}, {"T2", "BY_SEAT"}}); - var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithTableBookingConfig(tableBookingConfig)); + var evnt = Client.Events.Create(chartKey, + new CreateEventParams().WithTableBookingConfig(tableBookingConfig)); Assert.NotNull(evnt.Key); Assert.Equal("CUSTOM", evnt.TableBookingConfig.Mode); @@ -55,7 +56,8 @@ public void TableBookingModeInheritCanBeUsed() { var chartKey = CreateTestChartWithTables(); - var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithTableBookingConfig(TableBookingConfig.Inherit())); + var evnt = Client.Events.Create(chartKey, + new CreateEventParams().WithTableBookingConfig(TableBookingConfig.Inherit())); Assert.NotNull(evnt.Key); Assert.Equal("INHERIT", evnt.TableBookingConfig.Mode); @@ -82,29 +84,44 @@ public void CategoriesCanBePassedIn() var categories = new[] {eventCategory}; var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithCategories(categories)); - + Assert.Equal(TestChartCategories.Count + categories.Length, evnt.Categories.Count); Assert.Contains(eventCategory, evnt.Categories); - } - + } + [Fact] public void NameCanBePassedIn() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithName("My event")); - + Assert.Equal("My event", evnt.Name); - } - + } + [Fact] public void DateCanBePassedIn() { var chartKey = CreateTestChart(); var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithDate(new DateOnly(2022, 1, 10))); - + Assert.Equal(new DateOnly(2022, 1, 10), evnt.Date); } + + [Fact] + public void ChannelsCanBePassedIn() + { + var chartKey = CreateTestChart(); + var channels = new List + { + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}), + new("channelKey2", "channel 2", "#00FFFF", 2, new String[] {}) + }; + + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); + + Assert.Equivalent(channels, evnt.Channels); + } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/Events/CreateEventsTest.cs b/SeatsioDotNet.Test/Events/CreateEventsTest.cs index 6c2a3d2..3bb22f3 100644 --- a/SeatsioDotNet.Test/Events/CreateEventsTest.cs +++ b/SeatsioDotNet.Test/Events/CreateEventsTest.cs @@ -156,6 +156,24 @@ public void DateCanBePassedIn() var events = Client.Events.Create(chartKey, eventCreationParams); Assert.Equal(new DateOnly(2022, 1, 10), events[0].Date); + } + + [Fact] + public void ChannelsCanBePassedIn() + { + var chartKey = CreateTestChart(); + var channels = new List + { + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}), + new("channelKey2", "channel 2", "#00FFFF", 2, new String[] {}) + }; + + var events = Client.Events.Create(chartKey, new[] + { + new CreateEventParams().WithChannels(channels) + }); + + Assert.Equivalent(channels, events[0].Channels); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/Events/HoldObjectsTest.cs b/SeatsioDotNet.Test/Events/HoldObjectsTest.cs index 9032b70..22c3874 100644 --- a/SeatsioDotNet.Test/Events/HoldObjectsTest.cs +++ b/SeatsioDotNet.Test/Events/HoldObjectsTest.cs @@ -74,12 +74,12 @@ public void KeepExtraData() public void ChannelKeys() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - HoldToken holdToken = Client.HoldTokens.Create(); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); + HoldToken holdToken = Client.HoldTokens.Create(); Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, true, null, new[] {"channelKey1"}); @@ -90,12 +90,12 @@ public void ChannelKeys() public void IgnoreChannels() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - HoldToken holdToken = Client.HoldTokens.Create(); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); + HoldToken holdToken = Client.HoldTokens.Create(); 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 87b8572..26d3dba 100644 --- a/SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs +++ b/SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs @@ -71,11 +71,11 @@ public void KeepExtraData() public void ChannelKeys() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"}); @@ -88,11 +88,11 @@ public void ChannelKeys() public void IgnoreChannels() { var chartKey = CreateTestChart(); - var evnt = Client.Events.Create(chartKey); - Client.Events.Channels.Replace(evnt.Key, new List + var channels = new List { new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}) - }); + }; + var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels)); Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"}); diff --git a/SeatsioDotNet.Test/Seasons/CreateSeasonTest.cs b/SeatsioDotNet.Test/Seasons/CreateSeasonTest.cs index fa98bb8..63e5373 100644 --- a/SeatsioDotNet.Test/Seasons/CreateSeasonTest.cs +++ b/SeatsioDotNet.Test/Seasons/CreateSeasonTest.cs @@ -68,6 +68,21 @@ public void TableBookingConfigCanBePassedIn() var season = Client.Seasons.Create(chartKey, tableBookingConfig: TableBookingConfig.AllBySeat()); Assert.Equal(TableBookingConfig.AllBySeat().Mode, season.TableBookingConfig.Mode); + } + + [Fact] + public void ChannelsCanBePassedIn() + { + var chartKey = CreateTestChart(); + var channels = new List + { + new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}), + new("channelKey2", "channel 2", "#00FFFF", 2, new String[] {}) + }; + + var season = Client.Seasons.Create(chartKey, channels: channels); + + Assert.Equivalent(channels, season.Channels); } } } \ No newline at end of file diff --git a/SeatsioDotNet/Events/Channel.cs b/SeatsioDotNet/Events/Channel.cs index 7f822ba..8166280 100644 --- a/SeatsioDotNet/Events/Channel.cs +++ b/SeatsioDotNet/Events/Channel.cs @@ -9,7 +9,6 @@ public class Channel public string Color { get; set; } public int Index { get; set; } public IEnumerable Objects { get; set; } - public Channel() { } diff --git a/SeatsioDotNet/Events/CreateEventParams.cs b/SeatsioDotNet/Events/CreateEventParams.cs index 62e7501..f1ffb09 100644 --- a/SeatsioDotNet/Events/CreateEventParams.cs +++ b/SeatsioDotNet/Events/CreateEventParams.cs @@ -12,6 +12,7 @@ public class CreateEventParams public TableBookingConfig TableBookingConfig { get; set; } public Dictionary ObjectCategories { get; set; } public Category[] Categories { get; set; } + public List Channels { get; set; } public CreateEventParams WithKey(string key) { @@ -48,5 +49,11 @@ public CreateEventParams WithDate(DateOnly date) Date = date; return this; } + + public CreateEventParams WithChannels(List channels) + { + Channels = channels; + return this; + } } } \ No newline at end of file diff --git a/SeatsioDotNet/Events/Events.cs b/SeatsioDotNet/Events/Events.cs index fec18a7..c1c1633 100644 --- a/SeatsioDotNet/Events/Events.cs +++ b/SeatsioDotNet/Events/Events.cs @@ -59,6 +59,11 @@ public Event Create(string chartKey, CreateEventParams p) requestBody.Add("categories", p.Categories); } + if (p.Channels != null) + { + requestBody.Add("channels", p.Channels); + } + var restRequest = new RestRequest("/events", Method.Post).AddJsonBody(requestBody); return AssertOk(_restClient.Execute(restRequest)); } @@ -99,6 +104,11 @@ public Event[] Create(string chartKey, CreateEventParams[] eventCreationParams) if (param.Categories != null) { e.Add("categories", param.Categories); + } + + if (param.Channels != null) + { + e.Add("channels", param.Channels); } events.Add(e); diff --git a/SeatsioDotNet/Seasons/Seasons.cs b/SeatsioDotNet/Seasons/Seasons.cs index 2bc071a..85eb41f 100644 --- a/SeatsioDotNet/Seasons/Seasons.cs +++ b/SeatsioDotNet/Seasons/Seasons.cs @@ -17,7 +17,7 @@ public Seasons(RestClient restClient, SeatsioClient seatsioClient) _seatsioClient = seatsioClient; } - public Event Create(string chartKey, string key = null, int? numberOfEvents = null, IEnumerable eventKeys = null, TableBookingConfig tableBookingConfig = null) + public Event Create(string chartKey, string key = null, int? numberOfEvents = null, IEnumerable eventKeys = null, TableBookingConfig tableBookingConfig = null, IEnumerable channels = null) { Dictionary requestBody = new Dictionary(); requestBody.Add("chartKey", chartKey); @@ -40,6 +40,11 @@ public Event Create(string chartKey, string key = null, int? numberOfEvents = nu if (tableBookingConfig != null) { requestBody.Add("tableBookingConfig", tableBookingConfig.AsJsonObject()); + } + + if (channels != null) + { + requestBody.Add("channels", channels); } var restRequest = new RestRequest("/seasons", Method.Post).AddJsonBody(requestBody);