Exemplo n.º 1
0
        private void PollWalgreens(Location location)
        {
            using var walgreensClient = new WalgreensHttpClient();
            var request = new WalgreensRequest()
            {
                ServiceId = "99",
                Position  = new Position()
                {
                    Latitude = location.Latitude, Longitude = location.Longitude
                },
                AppointmentAvailability = new AppointmentAvailability()
                {
                    StartDateTime = DateTime.Now.ToString("yyyy-MM-dd")
                },
                Radius = Settings.StoreSearchRadius
            };

            var result = walgreensClient.GetAvailabilityResponse(request);

            if (result.AppointmentsAvailable)
            {
                var msgBody = $"Go to this URL now and enter {result.ZipCode} in the search. ";
                msgBody += "https://www.walgreens.com/findcare/vaccination/covid-19/location-screening";
                OnAvailabilityFound?.Invoke("Walgreens", location, msgBody);
            }
        }
        public WalgreensResponse GetAvailabilityResponse(WalgreensRequest request)
        {
            var uri      = $"https://www.walgreens.com/hcschedulersvc/svc/v1/immunizationLocations/availability";
            var body     = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
            var response = client.PostAsync(uri, body).Result;
            var result   = response.Content.ReadAsStringAsync().Result;
            var results  = JsonConvert.DeserializeObject <WalgreensResponse>(result);

            return(results);
        }