diff --git a/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java b/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java index 801d660..fd33eab 100644 --- a/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java +++ b/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java @@ -14,7 +14,8 @@ import java.util.HashSet; public class APIFootballUpdater { - private final String exceededLimitError = "{\"api\":{\"results\":0,\"error\":\"You have reached the request limit for the day\"}}"; + private final String exceededLimitDayError = "{\"api\":{\"results\":0,\"error\":\"You have reached the request limit for the day\"}}"; + private final String exceededLimitMinuteError = "{\"api\":{\"results\":0,\"error\":\"Too many requests. Your rate limit is 10 requests per minute.\"}}"; private final String wrongEndpointError = "{\"api\":{\"results\":0,\"error\":\"This endpoint does not exist or your parameters are incorrect, contact our support.\"}}"; public APIFootballUpdater() { @@ -24,7 +25,7 @@ public class APIFootballUpdater { public void updateFixtures(int league) throws Exception { String apiFootballUrl = "https://v2.api-football.com/fixtures/league/" + league + "?timezone=Europe/Berlin"; String content = getRawData(apiFootballUrl); - if(!content.equals(this.exceededLimitError)) { + if(!content.equals(this.exceededLimitDayError)) { S3Provider prov = new S3Provider(); prov.writeFixturesToS3(league, content); } @@ -47,10 +48,8 @@ public class APIFootballUpdater { public void updateRounds(int league) throws Exception { String apiFootballUrl = "https://v2.api-football.com/fixtures/rounds/" + league; String content = getRawData(apiFootballUrl); - if(!content.equals(this.exceededLimitError)) { - S3Provider prov = new S3Provider(); - prov.writeRoundsToS3(league, content); - } + S3Provider prov = new S3Provider(); + prov.writeRoundsToS3(league, content); } public String getRawData(String requestUrl) throws Exception { @@ -98,6 +97,12 @@ public class APIFootballUpdater { if (result.toString().equals(wrongEndpointError)) { throw new Exception(requestUrl + " gave error:" + wrongEndpointError); } + if (result.toString().equals(exceededLimitDayError)) { + throw new Exception(requestUrl + " gave error:" + exceededLimitDayError); + } + if (result.toString().equals(exceededLimitMinuteError)) { + throw new Exception(requestUrl + " gave error:" + exceededLimitMinuteError); + } return result.toString(); } diff --git a/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java b/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java index b28d84b..bd9070e 100644 --- a/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java +++ b/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java @@ -7,7 +7,7 @@ public class APIFootballUpdaterTest { @Test public void updateFixturesTest() throws Exception { APIFootballUpdater updater = new APIFootballUpdater(); - updater.updateFixtures(1240); +// updater.updateFixtures(1240); } @Test