Example #1
0
        private async Task <SunriseSunsetResponse> Request()
        {
            var client = new RestSharp.RestClient(Api);

            client.UseSerializer(SerializerFactory);

            var request = new RestSharp.RestRequest("json")
                          .AddParameter("lat", Latitude)
                          .AddParameter("lng", Longitude);

            var response = await client.ExecuteGetAsync <SunriseSunsetResponse>(request);

            if (!response.IsSuccessful || response.Data?.Status != "OK")
            {
                return(null);
            }

            _cache[DateTime.UtcNow.Date] = response.Data;
            return(response.Data);
        }