mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-20 13:26:50 +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)
|
.rain3H(weatherResult.getRainInfo() != null ? weatherResult.getRainInfo().getRain3H() : null)
|
||||||
.snow1H(weatherResult.getSnowInfo() != null ? weatherResult.getSnowInfo().getSnow1H() : null)
|
.snow1H(weatherResult.getSnowInfo() != null ? weatherResult.getSnowInfo().getSnow1H() : null)
|
||||||
.snow3H(weatherResult.getSnowInfo() != null ? weatherResult.getSnowInfo().getSnow3H() : null)
|
.snow3H(weatherResult.getSnowInfo() != null ? weatherResult.getSnowInfo().getSnow3H() : null)
|
||||||
|
.windSpeed(weatherResult.getWind() != null ? weatherResult.getWind().getSpeed() : null)
|
||||||
.visibility(weatherResult.getVisibility())
|
.visibility(weatherResult.getVisibility())
|
||||||
.locationName(chosenLocation.getName())
|
.locationName(chosenLocation.getName())
|
||||||
.countryKey(chosenLocation.getCountryKey())
|
.countryKey(chosenLocation.getCountryKey())
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.sheldan.abstracto.webservices.openeweathermap.service;
|
|||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
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.GeoCodingLocation;
|
||||||
import dev.sheldan.abstracto.webservices.openweathermap.model.GeoCodingResult;
|
import dev.sheldan.abstracto.webservices.openweathermap.model.GeoCodingResult;
|
||||||
import dev.sheldan.abstracto.webservices.openweathermap.model.WeatherResult;
|
import dev.sheldan.abstracto.webservices.openweathermap.model.WeatherResult;
|
||||||
@@ -44,6 +45,9 @@ public class OpenWeatherMapServiceBean implements OpenWeatherMapService {
|
|||||||
.get()
|
.get()
|
||||||
.build();
|
.build();
|
||||||
Response response = okHttpClient.newCall(request).execute();
|
Response response = okHttpClient.newCall(request).execute();
|
||||||
|
if(response.code() == 400) {
|
||||||
|
throw new LocationNotFoundException();
|
||||||
|
}
|
||||||
List<GeoCodingLocation> result = gson.fromJson(response.body().string(), geoCodingType);
|
List<GeoCodingLocation> result = gson.fromJson(response.body().string(), geoCodingType);
|
||||||
return GeoCodingResult
|
return GeoCodingResult
|
||||||
.builder()
|
.builder()
|
||||||
|
|||||||
@@ -34,4 +34,5 @@ public class WeatherResponseModel {
|
|||||||
private String countryKey;
|
private String countryKey;
|
||||||
private Color embedColor;
|
private Color embedColor;
|
||||||
private Long locationId;
|
private Long locationId;
|
||||||
|
private Float windSpeed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class WeatherResult {
|
|||||||
private WeatherResultRain rainInfo;
|
private WeatherResultRain rainInfo;
|
||||||
@SerializedName("snow")
|
@SerializedName("snow")
|
||||||
private WeatherResultSnow snowInfo;
|
private WeatherResultSnow snowInfo;
|
||||||
|
@SerializedName("wind")
|
||||||
|
private WeatherResultWind wind;
|
||||||
@SerializedName("dt")
|
@SerializedName("dt")
|
||||||
private Long dayTime;
|
private Long dayTime;
|
||||||
@SerializedName("clouds")
|
@SerializedName("clouds")
|
||||||
|
|||||||
Reference in New Issue
Block a user