public async Task <WeatherResponse> GetWeatherForDay(DateTime day, GeoPair geoPair)
        {
            var url    = this.BuildUrl(day, geoPair);
            var client = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                var jsonString = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <WeatherResponse>(jsonString));
            }
            return(null);
        }
        public async Task <List <WeatherResponse> > GetPastWeekWeatherAsync(GeoPair geoPair)
        {
            DateTime today        = DateTime.Today;
            var      responseList = new List <WeatherResponse>();

            for (int index = 0; index > -7; index--)
            {
                var response = await this.GetWeatherForDay(today.AddDays(index), geoPair);

                // todo - implement retry logic mechanism.
                if (response == null)
                {
                    return(null);
                }
                responseList.Add(response);
            }
            return(responseList);
        }
 private string BuildUrl(DateTime day, GeoPair geoPair)
 {
     return($"{this.baseUrl}{this.forecastPath}{this.key}/{geoPair.Latitude},{geoPair.Longitude},{day.ToUnixTimeSeconds()}");
 }