Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
164 changes: 82 additions & 82 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 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,16 @@

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 Channel(String key, String name, String color, Integer index, Set<String> objects) {
this(key, name, color, index, objects, Map.of());
Comment thread
linear-code[bot] marked this conversation as resolved.
Comment thread
mroloux marked this conversation as resolved.
}

public JsonObject toJson() {
return aJsonObject()
Expand All @@ -15,6 +20,7 @@ public JsonObject toJson() {
.withProperty("color", color)
.withPropertyIfNotNull("index", index)
.withPropertyIfNotNull("objects", objects)
.withPropertyIfNotNull("areaPlaces", areaPlaces)
.build();
}
}
13 changes: 11 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 All @@ -51,13 +54,19 @@ public Builder withObjects(Set<String> objectLabels) {
return this;
}

public Builder withAreaPlaces(Map<String, Integer> areaPlaces) {
this.areaPlaces = areaPlaces;
return this;
}

public ChannelCreationParams build() {
return new ChannelCreationParams(
this.key,
this.name,
this.color,
this.index,
this.objects
this.objects,
this.areaPlaces
);
}
}
Expand Down
26 changes: 23 additions & 3 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 @@ -22,7 +23,11 @@ public Channels(String baseUrl, UnirestWrapper 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)));
add(eventKey, channelKey, name, color, index, objects, null);
}

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 All @@ -40,33 +45,48 @@ public void remove(String eventKey, String channelKey) {
}

public void update(String eventKey, String channelKey, String name, String color, Set<String> objects) {
update(eventKey, channelKey, name, color, objects, null);
}

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

public void addObjects(String eventKey, String channelKey, Set<String> objects) {
addObjects(eventKey, channelKey, objects, null);
}

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) {
removeObjects(eventKey, channelKey, objects, null);
}

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
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
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/CreateEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ 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("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of("GA1", 3)),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
);

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("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of("GA1", 3)),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seatsio/events/CreateEventsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ 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("channelKey1", "channel 1", "#FFFF99", 1, Set.of("A-1"), Map.of("GA1", 3)),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
);

Expand All @@ -129,7 +129,7 @@ public void channelsCanBePassedIn() {
assertThat(events)
.extracting("channels")
.containsExactly(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("GA1", 3)),
new Channel("channelKey2", "channel 2", "#FFFF99", 2, Set.of("A-2"))
));
}
Expand Down
Loading
Loading