X-Git-Url: https://git.hedgecode.org/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fsnooker%2Fjson%2FJsonSnookerScore.java;h=b9a0eae329f7c5ed57d86054187d610865ecba26;hb=1bee0678966fdb60e53ea1075a5fa6843afa0838;hp=aa27161262c401d84e42fe62eeeee0b8ff89af3b;hpb=8a35619be41b2db6d339f8f0a7f3ba0fc1ca1ed4;p=snooker-score-api.git diff --git a/src/main/java/org/hedgecode/snooker/json/JsonSnookerScore.java b/src/main/java/org/hedgecode/snooker/json/JsonSnookerScore.java index aa27161..b9a0eae 100644 --- a/src/main/java/org/hedgecode/snooker/json/JsonSnookerScore.java +++ b/src/main/java/org/hedgecode/snooker/json/JsonSnookerScore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017. Developed by Hedgecode. + * Copyright (c) 2017-2020. Developed by Hedgecode. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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"