Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion src/main/java/seatsio/events/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.google.gson.JsonObject;

import java.util.Map;
import java.util.Set;

import static seatsio.json.JsonObjectBuilder.aJsonObject;

public record Channel(String key, String name, String color, Integer index, Set<String> objects) {
public record Channel(String key, String name, String color, Integer index, Set<String> objects, Map<String, Integer> areaPlaces) {

public JsonObject toJson() {
return aJsonObject()
Expand All @@ -15,6 +16,7 @@ public JsonObject toJson() {
.withProperty("color", color)
.withPropertyIfNotNull("index", index)
.withPropertyIfNotNull("objects", objects)
.withPropertyIfNotNull("areaPlaces", areaPlaces)
.build();
}
}
8 changes: 6 additions & 2 deletions src/main/java/seatsio/events/ChannelCreationParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.google.gson.JsonObject;

import java.util.Map;
import java.util.Set;

import static seatsio.json.JsonObjectBuilder.aJsonObject;

public record ChannelCreationParams(String key, String name, String color, Integer index, Set<String> objects) {
public record ChannelCreationParams(String key, String name, String color, Integer index, Set<String> objects, Map<String, Integer> areaPlaces) {

Comment thread
linear-code[bot] marked this conversation as resolved.
public JsonObject toJson() {
return aJsonObject()
Expand All @@ -15,6 +16,7 @@ public JsonObject toJson() {
.withProperty("color", color)
.withPropertyIfNotNull("index", index)
.withPropertyIfNotNull("objects", objects)
.withPropertyIfNotNull("areaPlaces", areaPlaces)
.build();
}

Expand All @@ -25,6 +27,7 @@ public static class Builder {
private String color;
private Integer index;
private Set<String> objects;
private Map<String, Integer> areaPlaces;

Comment thread
linear-code[bot] marked this conversation as resolved.
public Builder withKey(String channelKey) {
this.key = channelKey;
Expand Down Expand Up @@ -57,7 +60,8 @@ public ChannelCreationParams build() {
this.name,
this.color,
this.index,
this.objects
this.objects,
this.areaPlaces
);
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/seatsio/events/Channels.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static java.util.stream.Collectors.toList;
Expand All @@ -21,8 +22,8 @@ public Channels(String baseUrl, UnirestWrapper unirest) {
this.unirest = unirest;
}

public void add(String eventKey, String channelKey, String name, String color, Integer index, Set<String> objects) {
this.add(eventKey, List.of(new ChannelCreationParams(channelKey, name, color, index, objects)));
public void add(String eventKey, String channelKey, String name, String color, Integer index, Set<String> objects, Map<String, Integer> areaPlaces) {
this.add(eventKey, List.of(new ChannelCreationParams(channelKey, name, color, index, objects, areaPlaces)));
}
Comment thread
mroloux marked this conversation as resolved.

public void add(String eventKey, Collection<ChannelCreationParams> paramsList) {
Expand Down Expand Up @@ -51,22 +52,24 @@ public void update(String eventKey, String channelKey, String name, String color
);
}

public void addObjects(String eventKey, String channelKey, Set<String> objects) {
public void addObjects(String eventKey, String channelKey, Set<String> objects, Map<String, Integer> areaPlaces) {
unirest.stringResponse(UnirestWrapper.post(baseUrl + "/events/{eventKey}/channels/{channelKey}/objects")
.routeParam("eventKey", eventKey)
.routeParam("channelKey", channelKey)
.body(aJsonObject()
.withProperty("objects", objects)
.withPropertyIfNotNull("objects", objects)
.withPropertyIfNotNull("areaPlaces", areaPlaces)
.buildAsString())
);
}

public void removeObjects(String eventKey, String channelKey, Set<String> objects) {
public void removeObjects(String eventKey, String channelKey, Set<String> objects, Map<String, Integer> areaPlaces) {
unirest.stringResponse(UnirestWrapper.delete(baseUrl + "/events/{eventKey}/channels/{channelKey}/objects")
.routeParam("eventKey", eventKey)
.routeParam("channelKey", channelKey)
.body(aJsonObject()
.withProperty("objects", objects)
.withPropertyIfNotNull("objects", objects)
.withPropertyIfNotNull("areaPlaces", areaPlaces)
.buildAsString())
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/BookObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void keepExtraData() {
public void channelKeys() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));

client.events.book(event.key(), List.of("A-1"), null, null, true, null, Set.of("channelKey1"));
Expand All @@ -117,7 +117,7 @@ public void channelKeys() {
public void ignoreChannels() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));

client.events.book(event.key(), List.of("A-1"), null, null, null, true, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void keepExtraDataNotPassIn() {
public void channelKeys() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("B-6"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("B-6"), Map.of())
)));

BestAvailableResult bestAvailableResult = client.events.changeObjectStatus(event.key(), new BestAvailableParams(1), "foo", null, null, null, null, Set.of("channelKey1"));
Expand All @@ -193,7 +193,7 @@ public void channelKeys() {
public void ignoreChannels() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-5"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-5"), Map.of())
)));

BestAvailableResult bestAvailableResult = client.events.changeObjectStatus(event.key(), new BestAvailableParams(1), "foo", null, null, null, true, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import seatsio.seasons.CreateSeasonParams;

import java.util.List;
import java.util.Map;
Comment thread
mroloux marked this conversation as resolved.
Outdated
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -39,7 +40,7 @@ public void test() {
public void channelKeys() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of())
)));

List<ChangeObjectStatusResult> result = client.events.changeObjectStatus(List.of(
Expand All @@ -53,7 +54,7 @@ public void channelKeys() {
public void ignoreChannels() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of())
)));

List<ChangeObjectStatusResult> result = client.events.changeObjectStatus(List.of(
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/ChangeObjectStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void extraData() {
public void channelKeys() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));

client.events.changeObjectStatus(event.key(), List.of("A-1"), "someStatus", null, null, true, null, Set.of("channelKey1"));
Expand All @@ -214,7 +214,7 @@ public void channelKeys() {
public void ignoreChannels() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));

client.events.changeObjectStatus(event.key(), List.of("A-1"), "someStatus", null, null, null, true, null);
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/seatsio/events/CreateEventTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seatsio.events;

import org.junit.jupiter.api.Test;
import seatsio.SeatsioClient;
import seatsio.SeatsioClientTest;
Comment thread
linear-code[bot] marked this conversation as resolved.
import seatsio.charts.Category;
import seatsio.charts.CategoryKey;
Expand Down Expand Up @@ -102,15 +103,15 @@ public void categoriesCanBePassedIn() {
public void channelsCanBePassedIn() {
String chartKey = createTestChart();
List<Channel> channels = List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1")),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of()),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"), Map.of())
);

Event event = client.events.create(chartKey, new CreateEventParams().withChannels(channels));

assertThat(event.channels()).containsExactly(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1")),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of()),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"), Map.of())
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/seatsio/events/CreateEventsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public void dateCanBePassedIn() {
public void channelsCanBePassedIn() {
String chartKey = createTestChart();
List<Channel> channels = List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1")),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of()),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"), Map.of())
);

List<Event> events = client.events.create(chartKey, List.of(
Expand All @@ -129,8 +129,8 @@ public void channelsCanBePassedIn() {
assertThat(events)
.extracting("channels")
.containsExactly(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1")),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of()),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"), Map.of())
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/HoldObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void labels() {
public void channelKeys() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));
HoldToken holdToken = client.holdTokens.create();

Expand All @@ -82,7 +82,7 @@ public void channelKeys() {
public void ignoreChannels() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));
HoldToken holdToken = client.holdTokens.create();

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/ReleaseObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void keepExtraData() {
public void channelKeys() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));

client.events.book(event.key(), List.of("A-1"), null, null, true, null, Set.of("channelKey1"));
Expand All @@ -84,7 +84,7 @@ public void channelKeys() {
public void ignoreChannels() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey, new CreateEventParams().withChannels(List.of(
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1", "A-2"), Map.of())
)));
client.events.book(event.key(), List.of("A-1"), null, null, true, true, null);

Expand Down
21 changes: 11 additions & 10 deletions src/test/java/seatsio/events/channels/AddChannelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import seatsio.events.Event;

import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -18,13 +19,13 @@ public void addChannel() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey);

client.events.channels.add(event.key(), "channelKey1", "channel 1", "#FFFF98", 1, Set.of("A-1", "A-2"));
client.events.channels.add(event.key(), "channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-3"));
client.events.channels.add(event.key(), "channelKey1", "channel 1", "#FFFF98", 1, Set.of("A-1", "A-2"), null);
client.events.channels.add(event.key(), "channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-3"), null);

Event retrievedEvent = client.events.retrieve(event.key());
assertThat(retrievedEvent.channels()).containsExactly(
new Channel("channelKey1", "channel 1", "#FFFF98", 1, Set.of("A-1", "A-2")),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-3"))
new Channel("channelKey1", "channel 1", "#FFFF98", 1, Set.of("A-1", "A-2"), Map.of()),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-3"), Map.of())
);
}

Expand All @@ -43,8 +44,8 @@ public void addChannels() {

Event retrievedEvent = client.events.retrieve(event.key());
assertThat(retrievedEvent.channels()).containsExactly(
new Channel("channelKey1", "channel 1", "#FFFF98", 1, Set.of("A-1", "A-2")),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-3"))
new Channel("channelKey1", "channel 1", "#FFFF98", 1, Set.of("A-1", "A-2"), Map.of()),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-3"), Map.of())
);
}

Expand All @@ -53,11 +54,11 @@ public void indexIsOptional() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey);

client.events.channels.add(event.key(), "channelKey1", "channel 1", "#FFFF98", null, Set.of("A-1", "A-2"));
client.events.channels.add(event.key(), "channelKey1", "channel 1", "#FFFF98", null, Set.of("A-1", "A-2"), null);

Event retrievedEvent = client.events.retrieve(event.key());
assertThat(retrievedEvent.channels()).containsExactly(
new Channel("channelKey1", "channel 1", "#FFFF98", null, Set.of("A-1", "A-2"))
new Channel("channelKey1", "channel 1", "#FFFF98", null, Set.of("A-1", "A-2"), Map.of())
);
}

Expand All @@ -66,11 +67,11 @@ public void objectsAreOptional() {
String chartKey = createTestChart();
Event event = client.events.create(chartKey);

client.events.channels.add(event.key(), "channelKey1", "channel 1", "#FFFF98", 1, null);
client.events.channels.add(event.key(), "channelKey1", "channel 1", "#FFFF98", 1, null, null);

Event retrievedEvent = client.events.retrieve(event.key());
assertThat(retrievedEvent.channels()).containsExactly(
new Channel("channelKey1", "channel 1", "#FFFF98", 1, Set.of())
new Channel("channelKey1", "channel 1", "#FFFF98", 1, Set.of(), Map.of())
);
}

Expand Down
Loading
Loading