Skip to content

Commit

Permalink
Added call to override or use the season object status (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Oct 27, 2023
1 parent 6efd5b6 commit 6ae97ad
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/seatsio/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,24 @@ public ChangeObjectStatusResult changeObjectStatus(List<String> eventKeys, List<
return gson().fromJson(response, ChangeObjectStatusResult.class);
}

public void overrideSeasonObjectStatus(String eventKey, List<String> objects) {
unirest.stringResponse(post(baseUrl + "/events/{eventKey}/actions/override-season-status")
.routeParam("eventKey", eventKey)
.body(useOrOverrideSeasonObjectStatusRequest(objects).toString()));
}

public void useSeasonObjectStatus(String eventKey, List<String> objects) {
unirest.stringResponse(post(baseUrl + "/events/{eventKey}/actions/use-season-status")
.routeParam("eventKey", eventKey)
.body(useOrOverrideSeasonObjectStatusRequest(objects).toString()));
}

private static JsonObject useOrOverrideSeasonObjectStatusRequest(List<String> objects) {
return aJsonObject()
.withProperty("objects", aJsonArray().withItems(objects.toArray(new String[]{})).build())
.build();
}

public List<ChangeObjectStatusResult> changeObjectStatus(List<StatusChangeRequest> statusChangeRequests) {
List<JsonElement> statusChangeRequestsAsJson = statusChangeRequests
.stream()
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/seatsio/events/OverrideSeasonObjectStatusTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package seatsio.events;

import org.junit.jupiter.api.Test;
import seatsio.SeatsioClientTest;
import seatsio.seasons.SeasonParams;

import java.util.List;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
import static org.assertj.core.api.Assertions.assertThat;
import static seatsio.events.EventObjectInfo.FREE;

public class OverrideSeasonObjectStatusTest extends SeatsioClientTest {

@Test
public void test() {
String chartKey = createTestChart();
client.seasons.create(chartKey, new SeasonParams().key("aSeason").eventKeys(List.of("event1")));
client.events.book("aSeason", List.of("A-1"));

client.events.overrideSeasonObjectStatus("event1", List.of("A-1"));

assertThat(client.events.retrieveObjectInfo("event1", "A-1").status).isEqualTo(FREE);
}
}
25 changes: 25 additions & 0 deletions src/test/java/seatsio/events/UseSeasonObjectStatusTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package seatsio.events;

import org.junit.jupiter.api.Test;
import seatsio.SeatsioClientTest;
import seatsio.seasons.SeasonParams;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static seatsio.events.EventObjectInfo.BOOKED;

public class UseSeasonObjectStatusTest extends SeatsioClientTest {

@Test
public void test() {
String chartKey = createTestChart();
client.seasons.create(chartKey, new SeasonParams().key("aSeason").eventKeys(List.of("event1")));
client.events.book("aSeason", List.of("A-1"));
client.events.overrideSeasonObjectStatus("event1", List.of("A-1"));

client.events.useSeasonObjectStatus("event1", List.of("A-1"));

assertThat(client.events.retrieveObjectInfo("event1", "A-1").status).isEqualTo(BOOKED);
}
}

0 comments on commit 6ae97ad

Please sign in to comment.