Skip to content

Commit

Permalink
Best available call now supports ticket types
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Jul 29, 2020
1 parent ea52d39 commit bd84ac0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
27 changes: 21 additions & 6 deletions SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,29 @@ public void ExtraData()
new Dictionary<string, object> {{"foo", "baz"}}
};

var bestAvailableResult =
Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(2, null, extraData), "foo");
var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(2, extraData: extraData), "foo");

Assert.Equal(new[] {"B-4", "B-5"}, bestAvailableResult.Objects);
Assert.Equal(new Dictionary<string, object> {{"foo", "bar"}},
Client.Events.RetrieveObjectStatus(evnt.Key, "B-4").ExtraData);
Assert.Equal(new Dictionary<string, object> {{"foo", "baz"}},
Client.Events.RetrieveObjectStatus(evnt.Key, "B-5").ExtraData);
Assert.Equal(new Dictionary<string, object> {{"foo", "bar"}}, Client.Events.RetrieveObjectStatus(evnt.Key, "B-4").ExtraData);
Assert.Equal(new Dictionary<string, object> {{"foo", "baz"}}, Client.Events.RetrieveObjectStatus(evnt.Key, "B-5").ExtraData);
}

[Fact]
public void TicketTypes()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var extraData = new[]
{
new Dictionary<string, object> {{"foo", "bar"}},
new Dictionary<string, object> {{"foo", "baz"}}
};

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(2, ticketTypes: new[]{"adult", "child"}), "foo");

Assert.Equal(new[] {"B-4", "B-5"}, bestAvailableResult.Objects);
Assert.Equal("adult", Client.Events.RetrieveObjectStatus(evnt.Key, "B-4").TicketType);
Assert.Equal("child", Client.Events.RetrieveObjectStatus(evnt.Key, "B-5").TicketType);
}

[Fact]
Expand Down
20 changes: 7 additions & 13 deletions SeatsioDotNet/Events/BestAvailable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,14 @@ public class BestAvailable
public int Number { get; }
public IEnumerable<string> Categories { get; }
public IEnumerable<Dictionary<string, object>> ExtraData { get; }
public string[] TicketTypes { get; }

public BestAvailable(int number)
{
Number = number;
}

public BestAvailable(int number, IEnumerable<string> categories)
{
Categories = categories;
Number = number;
}

public BestAvailable(int number, IEnumerable<string> categories, IEnumerable<Dictionary<string, object>> extraData)
public BestAvailable(int number, IEnumerable<string> categories = null, IEnumerable<Dictionary<string, object>> extraData = null, string[] ticketTypes = null)
{
Categories = categories;
Number = number;
ExtraData = extraData;
TicketTypes = ticketTypes;
}

public Dictionary<string, object> AsDictionary()
Expand All @@ -36,11 +27,14 @@ public Dictionary<string, object> AsDictionary()
{
dictionary.Add("categories", Categories);
}

if (ExtraData != null)
{
dictionary.Add("extraData", ExtraData);
}
if (TicketTypes != null)
{
dictionary.Add("ticketTypes", TicketTypes);
}

return dictionary;
}
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>70.12.0</Version>
<Version>70.13.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 bd84ac0

Please sign in to comment.