public async Task <WeatherData> GetWeather(double latitude, double longitude) { UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = $"weather/latest/by-lat-lng", Query = $"lat={latitude.ToString(CultureInfo.InvariantCulture)}&lng={longitude.ToString(CultureInfo.InvariantCulture)}" }; var header = new Dictionary <string, string> { { "x-api-key", _serviceKey } }; AmbeeDTO weatherResponse = await _requestService.GetAsync <AmbeeDTO>(builder.Uri, header); AmbeeMapper ambeeMapper = new AmbeeMapper(); WeatherData weather = ambeeMapper.ToDomainEntity(weatherResponse, _runtimeContext.CityName, _isImperial); return(weather); }
public async Task <WeatherForecast> GetForecast(double latitude, double longitude, int days) { UriBuilder builder = new UriBuilder(_baseEndpoint) { Path = $"weather/forecast/by-lat-lng", Query = $"lat={latitude.ToString(CultureInfo.InvariantCulture)}&lng={longitude.ToString(CultureInfo.InvariantCulture)}&filter=daily" }; var header = new Dictionary <string, string> { { "x-api-key", _serviceKey } }; AmbeeForecastDTO weatherResponse = await _requestService.GetAsync <AmbeeForecastDTO>(builder.Uri, header); AmbeeMapper ambeeMapper = new AmbeeMapper(); WeatherForecast weatherForecast = ambeeMapper.ToDomainEntities(weatherResponse, _runtimeContext.CityName, _isImperial); weatherForecast.WeatherList = weatherForecast.WeatherList.GetRange(0, days); return(weatherForecast); }