Skip to content

Commit

Permalink
Support overriding or using the season status in batch (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Nov 22, 2024
1 parent de25062 commit 3c23209
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,38 @@ public async Task Release()

Assert.Equal(EventObjectInfo.Free, result[0].Objects["A-1"].Status);
Assert.Equal(EventObjectInfo.Free, (await Client.Events.RetrieveObjectInfoAsync(evnt.Key, "A-1")).Status);
}

[Fact]
public async Task OverrideSeasonStatus()
{
var chartKey = CreateTestChart();
var season = await Client.Seasons.CreateAsync(chartKey, null, null, new[] {"event1"});
await Client.Events.BookAsync(season.Key, new[] {"A-1"});

var result = await Client.Events.ChangeObjectStatusAsync(new[]
{
new StatusChangeRequest(type: StatusChangeRequest.OVERRIDE_SEASON_STATUS, eventKey: "event1", objects: new[] {"A-1"}),
});

Assert.Equal(EventObjectInfo.Free, result[0].Objects["A-1"].Status);
Assert.Equal(EventObjectInfo.Free, (await Client.Events.RetrieveObjectInfoAsync("event1", "A-1")).Status);
}

[Fact]
public async Task UseSeasonStatus()
{
var chartKey = CreateTestChart();
var season = await Client.Seasons.CreateAsync(chartKey, null, null, new[] {"event1"});
await Client.Events.BookAsync(season.Key, new[] {"A-1"});
await Client.Events.OverrideSeasonObjectStatusAsync("event1", new[] {"A-1"});

var result = await Client.Events.ChangeObjectStatusAsync(new[]
{
new StatusChangeRequest(type: StatusChangeRequest.USE_SEASON_STATUS, eventKey: "event1", objects: new[] {"A-1"}),
});

Assert.Equal(EventObjectInfo.Booked, result[0].Objects["A-1"].Status);
Assert.Equal(EventObjectInfo.Booked, (await Client.Events.RetrieveObjectInfoAsync("event1", "A-1")).Status);
}
}
2 changes: 1 addition & 1 deletion SeatsioDotNet/Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ private Dictionary<string, object> ChangeObjectStatusRequest(string type, IEnume
{"objects", objects.Select(o => o.AsDictionary())},
};

if (type != StatusChangeRequest.RELEASE)
if (status != null)
{
requestBody.Add("status", status);
}
Expand Down
2 changes: 2 additions & 0 deletions SeatsioDotNet/Events/StatusChangeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class StatusChangeRequest
{
public const string CHANGE_STATUS_TO = "CHANGE_STATUS_TO";
public const string RELEASE = "RELEASE";
public const string OVERRIDE_SEASON_STATUS = "OVERRIDE_SEASON_STATUS";
public const string USE_SEASON_STATUS = "USE_SEASON_STATUS";

public string Type { get; }
public string EventKey { get; }
Expand Down

0 comments on commit 3c23209

Please sign in to comment.