public async Task <WeatherBitResponse> GetCurrentWeatherForecastAsync(string city, CancellationToken cancellationToken) { var url = $"{_httpClient.BaseAddress}?city={city}&key={_weatherBitSettings.Key}"; HttpResponseMessage result = await _httpClient.GetAsync(url, cancellationToken); if (result.IsSuccessStatusCode) { string json = await result.Content.ReadAsStringAsync(); WeatherBitResponse weatherBitResponse = JsonSerializer.Deserialize <WeatherBitResponse>(json); return(weatherBitResponse); } else { throw new ServiceProviderApiException(ServiceProviderCode.WeatherBit, result.StatusCode.ToString(), city); } }
public async Task <ServiceProviderWeatherResponse> GetCurrentWeatherForecastAsync(string city, CancellationToken cancellationToken) { WeatherBitResponse weatherBitResponse = await _weatherBitServiceProvider.GetCurrentWeatherForecastAsync(city, cancellationToken); return(_mapper.Map <ServiceProviderWeatherResponse>(weatherBitResponse)); }