From 530323b686df7c40306af50143cf98d936a83c0f Mon Sep 17 00:00:00 2001 From: mroloux Date: Wed, 29 Aug 2018 12:54:52 +0200 Subject: [PATCH] Added call to update multiple extra data objects at once --- .../Events/UpdateExtraDatasTest.cs | 24 +++++++++++++++++++ SeatsioDotNet/Events/Events.cs | 11 ++++++++- SeatsioDotNet/SeatsioDotNet.csproj | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 SeatsioDotNet.Test/Events/UpdateExtraDatasTest.cs diff --git a/SeatsioDotNet.Test/Events/UpdateExtraDatasTest.cs b/SeatsioDotNet.Test/Events/UpdateExtraDatasTest.cs new file mode 100644 index 0000000..872ecd9 --- /dev/null +++ b/SeatsioDotNet.Test/Events/UpdateExtraDatasTest.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using SeatsioDotNet.Events; +using Xunit; + +namespace SeatsioDotNet.Test.Events +{ + public class UpdateExtraDatasTest : SeatsioClientTest + { + [Fact] + public void Test() + { + var chartKey = CreateTestChart(); + var evnt = Client.Events.Create(chartKey); + var extraData1 = new Dictionary {{"foo1", "bar1"}}; + var extraData2 = new Dictionary {{"foo2", "bar2"}}; + var extraDatas = new Dictionary> {{"A-1", extraData1}, {"A-2", extraData2}}; + + Client.Events.UpdateExtraDatas(evnt.Key, extraDatas); + + Assert.Equal(extraData1, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").ExtraData); + Assert.Equal(extraData2, Client.Events.RetrieveObjectStatus(evnt.Key, "A-2").ExtraData); + } + } +} \ No newline at end of file diff --git a/SeatsioDotNet/Events/Events.cs b/SeatsioDotNet/Events/Events.cs index 1ebf725..c436957 100644 --- a/SeatsioDotNet/Events/Events.cs +++ b/SeatsioDotNet/Events/Events.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; using RestSharp; using SeatsioDotNet.Util; using static SeatsioDotNet.Util.RestUtil; @@ -106,7 +107,7 @@ public ChangeObjectStatusResult Book(string[] eventKeys, IEnumerable(restRequest)); } + public void UpdateExtraDatas(string eventKey, Dictionary> extraData) + { + var restRequest = new RestRequest("/events/{key}/actions/update-extra-data", Method.POST) + .AddUrlSegment("key", eventKey) + .AddParameter("application/json", JsonConvert.SerializeObject(new {extraData}), ParameterType.RequestBody); // default serializer doesn't convert extraData to JSON properly + AssertOk(_restClient.Execute(restRequest)); + } + public void MarkAsForSale(string eventKey, IEnumerable objects, IEnumerable categories) { var requestBody = ForSaleRequest(objects, categories); diff --git a/SeatsioDotNet/SeatsioDotNet.csproj b/SeatsioDotNet/SeatsioDotNet.csproj index 069ba2a..854ebd5 100644 --- a/SeatsioDotNet/SeatsioDotNet.csproj +++ b/SeatsioDotNet/SeatsioDotNet.csproj @@ -2,7 +2,7 @@ Library true - 35 + 36 mroloux;bverbeken Official Seats.io .NET API client Official Seats.io .NET API client