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;
|
import eu.m724.wtapi.provider.exception.ServerProviderException;
|
||||||
|
|
||||||
public class OpenWeatherMapProvider extends WeatherProvider {
|
public class OpenWeatherMapProvider extends WeatherProvider {
|
||||||
private String requestUrlFormat;
|
|
||||||
private String apiKey;
|
private String apiKey;
|
||||||
|
|
||||||
public OpenWeatherMapProvider(String apiKey) {
|
public OpenWeatherMapProvider(String apiKey) {
|
||||||
this.apiKey = apiKey;
|
this.apiKey = apiKey;
|
||||||
this.requestUrlFormat = "https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=" + apiKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,8 +42,8 @@ public class OpenWeatherMapProvider extends WeatherProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Weather> getWeather(Coordinates coordinates) {
|
public CompletableFuture<Weather> getWeather(Coordinates coordinates) {
|
||||||
String url = String.format(
|
String url = "https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s"
|
||||||
requestUrlFormat, coordinates.latitude, coordinates.longitude);
|
.formatted(coordinates.latitude, coordinates.longitude, apiKey);
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.newBuilder()
|
HttpRequest request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create(url))
|
.uri(URI.create(url))
|
||||||
|
|
Loading…
Reference in a new issue