Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support event is in the past #137

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/seatsio/events/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Event extends ValueObject {
public boolean isEventInSeason;
public Map<String, CategoryKey> objectCategories;
public List<Category> categories;
public boolean isInThePast;

public boolean isSeason() {
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seatsio/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public void update(String key, UpdateEventParams params) {
.withPropertyIfNotNull("date", params.date == null ? null : gson().toJsonTree(params.date))
.withPropertyIfNotNull("tableBookingConfig", params.tableBookingConfig)
.withPropertyIfNotNull("objectCategories", params.objectCategories, CategoryKey::toJson)
.withPropertyIfNotNull("categories", categoriesAsJson(params.categories));
.withPropertyIfNotNull("categories", categoriesAsJson(params.categories))
.withPropertyIfNotNull("isInThePast", params.isInThePast);
unirest.stringResponse(post(baseUrl + "/events/{key}")
.routeParam("key", key)
.body(request.build().toString()));
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seatsio/events/UpdateEventParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
public class UpdateEventParams extends EventParams<UpdateEventParams> {

public String chartKey;
public Boolean isInThePast;

public UpdateEventParams withChartKey(String chartKey) {
this.chartKey = chartKey;
return this;
}

public UpdateEventParams withIsInThePast(Boolean isInThePast) {
this.isInThePast = isInThePast;
return this;
}
}
14 changes: 14 additions & 0 deletions src/test/java/seatsio/events/UpdateEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import seatsio.charts.Category;
import seatsio.charts.CategoryKey;
import seatsio.charts.Chart;
import seatsio.seasons.Season;
import seatsio.seasons.SeasonParams;

import java.time.LocalDate;
import java.util.List;
Expand Down Expand Up @@ -147,4 +149,16 @@ public void updateDate() {
assertThat(retrievedEvent.date).isEqualTo(LocalDate.of(2022, 1, 6));
}

@Test
public void updateIsInThePast() {
String chartKey = createTestChart();
Season season = client.seasons.create(chartKey, new SeasonParams().eventKeys(List.of("event1")));
Event event = client.events.retrieve("event1");
assertThat(event.isInThePast).isFalse();

client.events.update("event1", new UpdateEventParams().withIsInThePast(true));

Event retrievedEvent = client.events.retrieve(event.key);
assertThat(retrievedEvent.isInThePast).isTrue();
}
}