public OpenWeatherMapApi(WeatherApiRequest weatherApiRequest) { _weatherApiRequest = weatherApiRequest; if (_weatherApiRequest.NoOfDays < 0 || _weatherApiRequest.NoOfDays > 5) { throw new Exception(Constants.MAX_NUMBER_OF_DAYS_SUPPORTED_ERROR); } }
private IWeatherApi GetWeatherApi() { WeatherApiRequest weatherApiRequest = new WeatherApiRequest() { ApiKey = _appsettingsManager.ApiKey, NoOfDays = _appsettingsManager.NumberOfDays, HotWeatherThreshold = _appsettingsManager.HotWeatherThreshold, MessageForRain = _appsettingsManager.MessageForRain, MessageForHotWeather = _appsettingsManager.MessageForHotWeather, MessageForNormalWeather = _appsettingsManager.MessageForNormalWeather }; return(new WeatherApiFactory().GetWeatherApi(_appsettingsManager.ExternalWeatherApiName, weatherApiRequest)); }
public IWeatherApi GetWeatherApi(string externalWeatherApiName, WeatherApiRequest weatherApiRequest) { if (weatherApiRequest == null) { throw new ArgumentNullException("weatherApiRequest", "weatherApiRequest is a required parameter."); } switch (externalWeatherApiName) { case "OpenWeatherMap": _weatherApi = new OpenWeatherMapApi(weatherApiRequest); break; default: throw new Exception(string.Format("External Weather API {0} is not supported.", externalWeatherApiName)); } return(_weatherApi); }
public IActionResult GetFeature([FromQuery] WeatherApiRequest req) { var features = new FeatureRepository(_fmiService).GetSnowDepthAndTemperature(req.city, req.startTime, req.endTime); return(Ok(features)); }