public async Task <List <SurfMoment> > GetSurfForecastFromApi(SurfSpot surfSpot) { var url = HttpHelpers.BuildUrl("www-2019-2133843493.us-east-1.elb.amazonaws.com", $"/api/spot/forecast/{Convert.ToInt32(surfSpot)}", useHttps: false); var result = await _httpClientFactory.CreateClient().SendAndReceiveAs <List <SurfMoment> >(HttpMethod.Get, url); return(result); }
private async Task <WeatherResult> GetCurrentWeatherFromService(string zip) { var p = DefaultParams; p.Add("zip", $"{zip}"); var url = HttpHelpers.BuildUrl(DOMAIN, "/data/2.5/weather", queryParams: p, useHttps: false); var result = await _httpClientFactory.CreateClient().SendAndReceiveAs <WeatherResult>(HttpMethod.Get, url); await _currentWeatherCache.Set(result, zip); return(result); }
private async Task <HeadlinesResult> GetHeadlinesFromApi() { var p = new Dictionary <string, string> { { "apiKey", _apiKey }, { "sources", AcceptableSourcesStr } }; var url = HttpHelpers.BuildUrl("newsapi.org", "v2/top-headlines", queryParams: p, useHttps: true); var result = await _httpClientFactory.CreateClient().SendAndReceiveAs <HeadlinesApiResult>(HttpMethod.Get, url); var headlines = result.Articles.Select(x => new Headline { SourceName = x.Source.Name, Title = x.Title, }).ToList(); return(new HeadlinesResult { Headlines = headlines }); }
public async Task <WaterTemperatureResult> GetWaterTempFromApi(SurfCounty surfCounty) { var url = HttpHelpers.BuildUrl("www-2019-2133843493.us-east-1.elb.amazonaws.com", $"/api/county/water-temperature/{surfCounty.Value}", useHttps: false); return(await _httpClientFactory.CreateClient().SendAndReceiveAs <WaterTemperatureResult>(HttpMethod.Get, url)); }