From c0b171d89ba0387a6d168e5dc2d20672b9cfceca Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Thu, 20 Jun 2024 16:09:05 +0200 Subject: [PATCH] this is the way --- .../impl/openweathermap/OpenWeatherMapProvider.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/m724/wtapi/provider/impl/openweathermap/OpenWeatherMapProvider.java b/src/main/java/eu/m724/wtapi/provider/impl/openweathermap/OpenWeatherMapProvider.java index e6e4e51..c78eedf 100644 --- a/src/main/java/eu/m724/wtapi/provider/impl/openweathermap/OpenWeatherMapProvider.java +++ b/src/main/java/eu/m724/wtapi/provider/impl/openweathermap/OpenWeatherMapProvider.java @@ -22,12 +22,10 @@ import eu.m724.wtapi.provider.exception.QuotaExceededException; import eu.m724.wtapi.provider.exception.ServerProviderException; public class OpenWeatherMapProvider extends WeatherProvider { - private String requestUrlFormat; private String apiKey; public OpenWeatherMapProvider(String apiKey) { this.apiKey = apiKey; - this.requestUrlFormat = "https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=" + apiKey; } @Override @@ -44,8 +42,8 @@ public class OpenWeatherMapProvider extends WeatherProvider { @Override public CompletableFuture getWeather(Coordinates coordinates) { - String url = String.format( - requestUrlFormat, coordinates.latitude, coordinates.longitude); + String url = "https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s" + .formatted(coordinates.latitude, coordinates.longitude, apiKey); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url))