mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-12 09:56:18 +00:00
[AB-97] adding wind speed to weather command
fixing command failing non gracefully in case the location for weather was not found
This commit is contained in:
@@ -102,6 +102,7 @@ public class OpenWeatherMap extends AbstractConditionableCommand {
|
||||
.rain3H(weatherResult.getRainInfo() != null ? weatherResult.getRainInfo().getRain3H() : null)
|
||||
.snow1H(weatherResult.getSnowInfo() != null ? weatherResult.getSnowInfo().getSnow1H() : null)
|
||||
.snow3H(weatherResult.getSnowInfo() != null ? weatherResult.getSnowInfo().getSnow3H() : null)
|
||||
.windSpeed(weatherResult.getWind() != null ? weatherResult.getWind().getSpeed() : null)
|
||||
.visibility(weatherResult.getVisibility())
|
||||
.locationName(chosenLocation.getName())
|
||||
.countryKey(chosenLocation.getCountryKey())
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.sheldan.abstracto.webservices.openeweathermap.service;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import dev.sheldan.abstracto.webservices.openweathermap.exception.LocationNotFoundException;
|
||||
import dev.sheldan.abstracto.webservices.openweathermap.model.GeoCodingLocation;
|
||||
import dev.sheldan.abstracto.webservices.openweathermap.model.GeoCodingResult;
|
||||
import dev.sheldan.abstracto.webservices.openweathermap.model.WeatherResult;
|
||||
@@ -44,6 +45,9 @@ public class OpenWeatherMapServiceBean implements OpenWeatherMapService {
|
||||
.get()
|
||||
.build();
|
||||
Response response = okHttpClient.newCall(request).execute();
|
||||
if(response.code() == 400) {
|
||||
throw new LocationNotFoundException();
|
||||
}
|
||||
List<GeoCodingLocation> result = gson.fromJson(response.body().string(), geoCodingType);
|
||||
return GeoCodingResult
|
||||
.builder()
|
||||
|
||||
@@ -34,4 +34,5 @@ public class WeatherResponseModel {
|
||||
private String countryKey;
|
||||
private Color embedColor;
|
||||
private Long locationId;
|
||||
private Float windSpeed;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ public class WeatherResult {
|
||||
private WeatherResultRain rainInfo;
|
||||
@SerializedName("snow")
|
||||
private WeatherResultSnow snowInfo;
|
||||
@SerializedName("wind")
|
||||
private WeatherResultWind wind;
|
||||
@SerializedName("dt")
|
||||
private Long dayTime;
|
||||
@SerializedName("clouds")
|
||||
|
||||
Reference in New Issue
Block a user