this is the way
This commit is contained in:
parent
b30e65b946
commit
c0b171d89b
1 changed files with 2 additions and 4 deletions
|
@ -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<Weather> 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))
|
||||
|
|
Loading…
Reference in a new issue