From 8231138b666ac160b421cbddcfed82bcfe553310 Mon Sep 17 00:00:00 2001
From: dehi <40899632+dehidehidehi@users.noreply.github.com>
Date: Sat, 11 Feb 2023 00:04:15 +0100
Subject: [PATCH] Added missing EventResponse.Type entries
According to Lichess documentation: https://lichess.org/api#tag/Board/operation/apiStreamEvent
**Note**: by default the current state of this project would interpret `CHALLENGE_CANCELED`, `CHALLENGE_DECLINED`, and `GAME_FINISH` as `MalformedEvents`
---
.../chess/lichess4j/model/EventResponse.java | 30 +++++++++++++++----
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/lichess4j/src/main/java/net/marvk/chess/lichess4j/model/EventResponse.java b/lichess4j/src/main/java/net/marvk/chess/lichess4j/model/EventResponse.java
index b8c3120..3b5d0f5 100644
--- a/lichess4j/src/main/java/net/marvk/chess/lichess4j/model/EventResponse.java
+++ b/lichess4j/src/main/java/net/marvk/chess/lichess4j/model/EventResponse.java
@@ -3,17 +3,35 @@
import com.google.gson.annotations.SerializedName;
import lombok.Data;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Lichess Event Stream Documentation
+ */
@Data
public class EventResponse {
private final Type type;
private final Challenge challenge;
- @SerializedName("game")
- private final GameStart gameStart;
+ private final Game game;
+ /**
+ * Lichess Event Stream Documentation
+ */
public enum Type {
- @SerializedName("challenge")
- CHALLENGE,
- @SerializedName("gameStart")
- GAME_START;
+ @SerializedName("challenge") CHALLENGE,
+ @SerializedName("challengeCanceled") CHALLENGE_CANCELED,
+ @SerializedName("challengeDeclined") CHALLENGE_DECLINED,
+ @SerializedName("gameFinish") GAME_FINISH,
+ @SerializedName("gameStart") GAME_START;
+
+ /**
+ * Returns all values of the enum as a list.
+ * Alternative to {@link Type#values()}.
+ */
+ public static List toList() {
+ return Arrays.stream(Type.values()).collect(Collectors.toList());
+ }
}
}