Skip to content

Commit

Permalink
Added ignoreSocialDistancing parameter to status change calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Dec 13, 2020
1 parent 449e222 commit 357174d
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 31 deletions.
22 changes: 22 additions & 0 deletions SeatsioDotNet.Test/Events/BookObjectsTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FluentAssertions;
using SeatsioDotNet.Charts;
using SeatsioDotNet.Events;
using SeatsioDotNet.HoldTokens;
using Xunit;
Expand Down Expand Up @@ -121,6 +122,27 @@ public void IgnoreChannels()

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, true);

Assert.Equal(ObjectStatus.Booked, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();

var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
Client.Events.Update(evnt.Key, null, null, null, "ruleset");

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, null, null, null, true);

Assert.Equal(ObjectStatus.Booked, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using SeatsioDotNet.Events;
using System.Collections.Generic;
using SeatsioDotNet.Charts;
using SeatsioDotNet.Events;
using SeatsioDotNet.HoldTokens;
using Xunit;

Expand Down Expand Up @@ -67,6 +69,27 @@ public void Release()
Assert.Equal(ObjectStatus.Free, Client.Events.RetrieveObjectStatus(event2.Key, "A-1").Status);
Assert.Equal(ObjectStatus.Free, Client.Events.RetrieveObjectStatus(event2.Key, "A-2").Status);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();
var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
var event1 = Client.Events.Create(chartKey, null, null, "ruleset");
var event2 = Client.Events.Create(chartKey, null, null, "ruleset");

Client.Events.Book(new[] {event1.Key, event2.Key}, new[] {"A-1"}, null, null, null, null, null, true);

Assert.Equal(ObjectStatus.Booked, Client.Events.RetrieveObjectStatus(event1.Key, "A-1").Status);
Assert.Equal(ObjectStatus.Booked, Client.Events.RetrieveObjectStatus(event2.Key, "A-1").Status);
}

}
}
20 changes: 20 additions & 0 deletions SeatsioDotNet.Test/Events/ChangeObjectStatusTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FluentAssertions;
using SeatsioDotNet.Charts;
using SeatsioDotNet.Events;
using SeatsioDotNet.HoldTokens;
using Xunit;
Expand Down Expand Up @@ -159,5 +160,24 @@ public void NoKeepExtraData()

Assert.Null(Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").ExtraData);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();
var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
var evnt = Client.Events.Create(chartKey, null, null, "ruleset");

Client.Events.ChangeObjectStatus(evnt.Key, new[] {"A-1"}, "someStatus", null, null, null, null, null, true);

Assert.Null(Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").ExtraData);
}
}
}
23 changes: 23 additions & 0 deletions SeatsioDotNet.Test/Events/HoldObjectsTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FluentAssertions;
using SeatsioDotNet.Charts;
using SeatsioDotNet.Events;
using SeatsioDotNet.HoldTokens;
using Xunit;
Expand Down Expand Up @@ -109,5 +110,27 @@ public void IgnoreChannels()

Assert.Equal(ObjectStatus.Held, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();

var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
Client.Events.Update(evnt.Key, null, null, null, "ruleset");
HoldToken holdToken = Client.HoldTokens.Create();

Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, null, null, null, true);

Assert.Equal(ObjectStatus.Held, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}
}
}
63 changes: 34 additions & 29 deletions SeatsioDotNet/Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,24 @@ public ObjectStatus RetrieveObjectStatus(string eventKey, string objectLabel)
return AssertOk(_restClient.Execute<ObjectStatus>(restRequest));
}

public ChangeObjectStatusResult Book(string eventKey, IEnumerable<string> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Book(string eventKey, IEnumerable<string> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult Book(string[] eventKeys, IEnumerable<string> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Book(string[] eventKeys, IEnumerable<string> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult Book(string eventKey, IEnumerable<ObjectProperties> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Book(string eventKey, IEnumerable<ObjectProperties> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult Book(string[] eventKeys, IEnumerable<ObjectProperties> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Book(string[] eventKeys, IEnumerable<ObjectProperties> objects, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData,ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Booked, holdToken, orderId, keepExtraData,ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public BestAvailableResult Book(string eventKey, BestAvailable bestAvailable, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
Expand Down Expand Up @@ -189,49 +189,49 @@ public ChangeObjectStatusResult Release(string[] eventKeys, IEnumerable<ObjectPr
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Free, holdToken, orderId, keepExtraData,ignoreChannels, channelKeys);
}

public ChangeObjectStatusResult Hold(string eventKey, IEnumerable<string> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Hold(string eventKey, IEnumerable<string> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult Hold(string[] eventKeys, IEnumerable<string> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Hold(string[] eventKeys, IEnumerable<string> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult Hold(string eventKey, IEnumerable<ObjectProperties> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Hold(string eventKey, IEnumerable<ObjectProperties> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData,ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKey, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData,ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult Hold(string[] eventKeys, IEnumerable<ObjectProperties> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult Hold(string[] eventKeys, IEnumerable<ObjectProperties> objects, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(eventKeys, objects, ObjectStatus.Held, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public BestAvailableResult Hold(string eventKey, BestAvailable bestAvailable, string holdToken, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
{
return ChangeObjectStatus(eventKey, bestAvailable, ObjectStatus.Held, holdToken, orderId, keepExtraData,ignoreChannels, channelKeys);
}

public ChangeObjectStatusResult ChangeObjectStatus(string eventKey, IEnumerable<string> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null,bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult ChangeObjectStatus(string eventKey, IEnumerable<string> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null,bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(new[] {eventKey}, objects.Select(o => new ObjectProperties(o)), status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(new[] {eventKey}, objects.Select(o => new ObjectProperties(o)), status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult ChangeObjectStatus(string eventKey, IEnumerable<ObjectProperties> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult ChangeObjectStatus(string eventKey, IEnumerable<ObjectProperties> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(new[] {eventKey}, objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(new[] {eventKey}, objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult ChangeObjectStatus(IEnumerable<string> events, IEnumerable<string> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult ChangeObjectStatus(IEnumerable<string> events, IEnumerable<string> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
return ChangeObjectStatus(events, objects.Select(o => new ObjectProperties(o)), status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
return ChangeObjectStatus(events, objects.Select(o => new ObjectProperties(o)), status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
}

public ChangeObjectStatusResult ChangeObjectStatus(IEnumerable<string> events, IEnumerable<ObjectProperties> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null)
public ChangeObjectStatusResult ChangeObjectStatus(IEnumerable<string> events, IEnumerable<ObjectProperties> objects, string status, string holdToken = null, string orderId = null, bool? keepExtraData = null, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
var requestBody = ChangeObjectStatusRequest(events, objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
var requestBody = ChangeObjectStatusRequest(events, objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
var restRequest = new RestRequest("/seasons/actions/change-object-status", Method.POST)
.AddQueryParameter("expand", "objects")
.AddJsonBody(requestBody);
Expand All @@ -247,21 +247,21 @@ public List<ChangeObjectStatusResult> ChangeObjectStatus(StatusChangeRequest[] r
return AssertOk(_restClient.Execute<ChangeObjectStatusInBatchResult>(restRequest)).Results;
}

private Dictionary<string, object> ChangeObjectStatusRequest(string evnt, IEnumerable<ObjectProperties> objects, string status, string holdToken, string orderId, bool? keepExtraData, bool? ignoreChannels = null, string[] channelKeys = null)
private Dictionary<string, object> ChangeObjectStatusRequest(string evnt, IEnumerable<ObjectProperties> objects, string status, string holdToken, string orderId, bool? keepExtraData, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
var request = ChangeObjectStatusRequest(objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
var request = ChangeObjectStatusRequest(objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
request.Add("event", evnt);
return request;
}

private Dictionary<string, object> ChangeObjectStatusRequest(IEnumerable<string> events, IEnumerable<ObjectProperties> objects, string status, string holdToken, string orderId, bool? keepExtraData, bool? ignoreChannels = null, string[] channelKeys = null)
private Dictionary<string, object> ChangeObjectStatusRequest(IEnumerable<string> events, IEnumerable<ObjectProperties> objects, string status, string holdToken, string orderId, bool? keepExtraData, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
var request = ChangeObjectStatusRequest(objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
var request = ChangeObjectStatusRequest(objects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing);
request.Add("events", events);
return request;
}

private Dictionary<string, object> ChangeObjectStatusRequest(IEnumerable<ObjectProperties> objects, string status, string holdToken, string orderId, bool? keepExtraData, bool? ignoreChannels = null, string[] channelKeys = null)
private Dictionary<string, object> ChangeObjectStatusRequest(IEnumerable<ObjectProperties> objects, string status, string holdToken, string orderId, bool? keepExtraData, bool? ignoreChannels = null, string[] channelKeys = null, bool? ignoreSocialDistancing = null)
{
var requestBody = new Dictionary<string, object>()
{
Expand Down Expand Up @@ -294,6 +294,11 @@ private Dictionary<string, object> ChangeObjectStatusRequest(IEnumerable<ObjectP
requestBody.Add("channelKeys", channelKeys);
}

if (ignoreSocialDistancing != null)
{
requestBody.Add("ignoreSocialDistancing", ignoreSocialDistancing);
}

return requestBody;
}

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>76.0.0</Version>
<Version>76.1.0</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 357174d

Please sign in to comment.