[LIB-8] Add Event Rounds and Seedings functional
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonSnookerScore.java
index aa27161..6666165 100644 (file)
@@ -29,7 +29,9 @@ import org.hedgecode.snooker.api.PlayerCategory;
 import org.hedgecode.snooker.api.Players;
 import org.hedgecode.snooker.api.RankingType;
 import org.hedgecode.snooker.api.Rankings;
+import org.hedgecode.snooker.api.Rounds;
 import org.hedgecode.snooker.api.Season;
+import org.hedgecode.snooker.api.Seedings;
 import org.hedgecode.snooker.api.SnookerScoreAPI;
 import org.hedgecode.snooker.gson.SnookerGsonBuilder;
 import org.hedgecode.snooker.request.RequestException;
@@ -288,6 +290,52 @@ public class JsonSnookerScore implements SnookerScoreAPI {
     }
 
     @Override
+    public Rounds getEventRounds(int eventId) throws APIException {
+        Rounds rounds;
+        try {
+            rounds = new JsonRounds(
+                    GSON.fromJson(
+                            JsonStringToken.token(
+                                    RequestType.request(
+                                            RequestType.EVENT_ROUNDS,
+                                            eventId
+                                    )
+                            ),
+                            JsonRound[].class
+                    )
+            );
+        } catch (RequestException e) {
+            throw new APIException(
+                    APIException.Type.REQUEST, e.getMessage()
+            );
+        }
+        return rounds;
+    }
+
+    @Override
+    public Seedings getEventSeedings(int eventId) throws APIException {
+        Seedings seedings;
+        try {
+            seedings = new JsonSeedings(
+                    GSON.fromJson(
+                            JsonStringToken.token(
+                                    RequestType.request(
+                                            RequestType.EVENT_SEEDING,
+                                            eventId
+                                    )
+                            ),
+                            JsonSeeding[].class
+                    )
+            );
+        } catch (RequestException e) {
+            throw new APIException(
+                    APIException.Type.REQUEST, e.getMessage()
+            );
+        }
+        return seedings;
+    }
+
+    @Override
     public void setCurrentSeason(Season season) throws APIException {
         throw new APIException(
                 APIException.Type.INFO, "This feature is only available in Cached API"