Skip to content

Commit

Permalink
add methods to put up objects for resale (#202)
Browse files Browse the repository at this point in the history
* add methods to put up objects for resale

* use new RELEASE statusChangeCommand type instead of hardcoded FREE status, when releasing objects (#199)

* instead of passing in FREE as a status, we now use RELEASE as statusChangeCommand type.

* refactoring - rename

* refactoring - rename

* version bump

* fixed build

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
bverbeken and github-actions[bot] authored Oct 4, 2024
1 parent 814ea35 commit 3049773
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/seatsio/events/EventObjectInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class EventObjectInfo extends ValueObject {
public static final String FREE = "free";
public static final String BOOKED = "booked";
public static final String HELD = "reservedByToken";
public static final String RESALE = "resale";

public String status;
public String label;
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/seatsio/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static seatsio.events.EventObjectInfo.BOOKED;
import static seatsio.events.EventObjectInfo.HELD;
import static seatsio.events.EventObjectInfo.*;
import static seatsio.json.JsonArrayBuilder.aJsonArray;
import static seatsio.json.JsonObjectBuilder.aJsonObject;
import static seatsio.json.SeatsioGson.gson;
Expand Down Expand Up @@ -260,6 +259,14 @@ public ChangeObjectStatusResult hold(List<String> eventKeys, List<?> objects, St
return changeObjectStatus(eventKeys, objects, HELD, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys);
}

public ChangeObjectStatusResult putUpForResale(String eventKey, List<?> objects) {
return changeObjectStatus(eventKey, objects, RESALE, null, null, null, null, null);
}

public ChangeObjectStatusResult putUpForResale(List<String> eventKeys, List<?> objects) {
return changeObjectStatus(eventKeys, objects, RESALE, null, null, null, null, null);
}

public ChangeObjectStatusResult release(String eventKey, List<?> objects) {
return release(eventKey, objects, null, null, null, null, null);
}
Expand Down
40 changes: 40 additions & 0 deletions src/test/java/seatsio/events/PutUpForResaleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package seatsio.events;

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

import java.util.List;

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

public class PutUpForResaleTest extends SeatsioClientTest {

@Test
public void putUpForResaleForSingleEvent() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey);

ChangeObjectStatusResult result = client.events.putUpForResale(event.key, List.of("A-1", "A-2"));

assertThat(client.events.retrieveObjectInfo(event.key, "A-1").status).isEqualTo(RESALE);
assertThat(client.events.retrieveObjectInfo(event.key, "A-2").status).isEqualTo(RESALE);
assertThat(result.objects).containsOnlyKeys("A-1", "A-2");
}

@Test
public void putUpForResaleForEventGroup() {
String chartKey = createTestChart();
Event event1 = client.events.create(chartKey);
Event event2 = client.events.create(chartKey);

ChangeObjectStatusResult result = client.events.putUpForResale(List.of(event1.key, event2.key), List.of("A-1", "A-2"));

assertThat(client.events.retrieveObjectInfo(event1.key, "A-1").status).isEqualTo(RESALE);
assertThat(client.events.retrieveObjectInfo(event1.key, "A-2").status).isEqualTo(RESALE);
assertThat(client.events.retrieveObjectInfo(event2.key, "A-1").status).isEqualTo(RESALE);
assertThat(client.events.retrieveObjectInfo(event2.key, "A-2").status).isEqualTo(RESALE);
assertThat(result.objects).containsOnlyKeys("A-1", "A-2");
}

}

0 comments on commit 3049773

Please sign in to comment.