public override async Task <(WeatherOutputModel, string)> GetCurrentWeather(string country, string city) { try { using var client = new HttpClient(); var response = await client.GetAsync($"{_config.BaseURL}?appid={_config.AppId}&q={city},{country}&units={_config.Units.ToString()}"); if (!response.IsSuccessStatusCode) { return(null, ErrorMessages.CannotGetWeatherData("OpenWeatherMap", $"{city},{country}")); } var content = await response.Content.ReadAsStringAsync(); return(TransformResponse(content)); } catch (Exception) { return(null, ErrorMessages.UncaughtError); } }
public override async Task <(WeatherOutputModel, string)> GetCurrentWeather(string country, string city) { try { using var client = new HttpClient(); var response = await client.GetAsync($"{_config.BaseURL}?access_key={_config.AccessToken}&query={city}&units={GetUnitsParametrer(_config.Units)}"); if (!response.IsSuccessStatusCode) { return(null, ErrorMessages.CannotGetWeatherData("WeatherStack", city)); } var content = await response.Content.ReadAsStringAsync(); return(TransformResponse(content)); } catch (Exception) { return(null, ErrorMessages.UncaughtError); } }