Skip to content

Commit

Permalink
Added call to update multiple extra data objects at once
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Aug 29, 2018
1 parent cf64fae commit 530323b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
24 changes: 24 additions & 0 deletions SeatsioDotNet.Test/Events/UpdateExtraDatasTest.cs
Original file line number Diff line number Diff line change
@@ -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<string, object> {{"foo1", "bar1"}};
var extraData2 = new Dictionary<string, object> {{"foo2", "bar2"}};
var extraDatas = new Dictionary<string, Dictionary<string, object>> {{"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);
}
}
}
11 changes: 10 additions & 1 deletion SeatsioDotNet/Events/Events.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using RestSharp;
using SeatsioDotNet.Util;
using static SeatsioDotNet.Util.RestUtil;
Expand Down Expand Up @@ -106,7 +107,7 @@ public ChangeObjectStatusResult Book(string[] eventKeys, IEnumerable<ObjectPrope
{
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Booked, holdToken, orderId);
}

public BestAvailableResult Book(string eventKey, BestAvailable bestAvailable, string holdToken = null, string orderId = null)
{
return ChangeObjectStatus(eventKey, bestAvailable, ObjectStatus.Booked, holdToken, orderId);
Expand Down Expand Up @@ -228,6 +229,14 @@ public void UpdateExtraData(string eventKey, string objectLabel, Dictionary<stri
AssertOk(_restClient.Execute<BestAvailableResult>(restRequest));
}

public void UpdateExtraDatas(string eventKey, Dictionary<string, Dictionary<string, object>> 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<BestAvailableResult>(restRequest));
}

public void MarkAsForSale(string eventKey, IEnumerable<string> objects, IEnumerable<string> categories)
{
var requestBody = ForSaleRequest(objects, categories);
Expand Down
2 changes: 1 addition & 1 deletion SeatsioDotNet/SeatsioDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<Version>35</Version>
<Version>36</Version>
<Authors>mroloux;bverbeken</Authors>
<Title>Official Seats.io .NET API client</Title>
<Description>Official Seats.io .NET API client</Description>
Expand Down

0 comments on commit 530323b

Please sign in to comment.