コード例 #1
0
        public DisneyPostRequest(String url, AuthToken token, String partySize, String mealPeriod, String searchDate)
        {
            String parameters = "grant_type=assertion&assertion_type=public&client_id=WDPRO-MOBILE.CLIENT-PROD&partySize=" + partySize + "&mealPeriod=" + mealPeriod + "&searchDate=" + searchDate;

            IDisneyReservationRequest disneyRequest = this;
            HttpWebRequest request = disneyRequest.setHeadersWithAuthorization(url, token);
            HttpWebResponse response = disneyRequest.makeReservationRequest(request, parameters);
            try
            {
                _response = response;
                String responseMessage = disneyRequest.returnResponse(response);
                ResponseMessage = responseMessage;
                WebHeaderCollection responseHeaders = response.Headers;
                _reservationUrl = responseHeaders.Get("Location");

            }
            catch (NullReferenceException err)
            {
                Console.WriteLine(err.Message);

            }

            DisneyGetRequest reservationRequest = new DisneyGetRequest(_reservationUrl, token);
            ResponseMessage = reservationRequest.ResponseMessage;
        }
コード例 #2
0
        public void populateDisneyRestaurants(AuthToken token)
        {
            this.DisneyRestaurants = new List<DisneyRestaurant>();

            foreach (String url in this._restaurantUrls)
            {

                DisneyRestaurant restaurant = new DisneyRestaurant();

                restaurant.RestaurantUrl = url;

                DisneyGetRequest restaurantRequest = new DisneyGetRequest(url, token);

                try
                {
                    //Location
                    JObject response = JObject.Parse(restaurantRequest.ResponseMessage);

                    JObject links = (JObject)response.SelectToken("links");
                    JObject ancestorPark = (JObject)links.SelectToken("ancestorThemePark") ?? (JObject)links.SelectToken("ancestorEntertainmentVenue") ?? (JObject)links.SelectToken("ancestorResort");
                    restaurant.Location = (String)ancestorPark.SelectToken("title");
                    Console.WriteLine(restaurant.Location);

                    //ID
                    String id = (String)response.SelectToken("id");
                    String[] words = id.Split(';');
                    restaurant.Id = Convert.ToInt32(words[0]);
                    Console.WriteLine(restaurant.Id);

                    //Name
                    restaurant.RestaurantName = (String)response.SelectToken("name");
                    Console.WriteLine(restaurant.RestaurantName);

                    //Price Range
                    JObject facets = (JObject)response.SelectToken("facets");
                    JArray priceRange = (JArray)facets.SelectToken("priceRange");
                    restaurant.PriceRange = (String)priceRange[0].SelectToken("urlFriendlyId");
                    Console.WriteLine(restaurant.PriceRange);

                    // Type of restaurant -- Table or Quick
                    JArray service = (JArray)facets.SelectToken("tableService");
                    String diningType = null;
                    if (service != null)
                    {
                        JArray tableDiningMealTimesArray = (JArray)facets.SelectToken("dining");

                        diningType = "Table Service";
                    }
                    else
                    {
                        service = (JArray)facets.SelectToken("quickService");
                        if (service != null)
                        {
                            diningType = "Quick Service";
                        }
                    }
                    restaurant.RestaurantType = diningType;
                    Console.WriteLine(restaurant.RestaurantType);
                }
                catch(NullReferenceException err)
                {
                    Console.WriteLine(err.Message);
                }
                if (restaurant.Id != 0)
                {
                    this.DisneyRestaurants.Add(restaurant);
                    Console.WriteLine("Added restaurant!");
                }

            }
        }
コード例 #3
0
        private void populateRestaurantUrls(AuthToken token)
        {
            List<String> urls = new List<String>();
            DisneyGetRequest request = new DisneyGetRequest(_fullRestaurantListUrl, token);
            JObject response = JObject.Parse(request.ResponseMessage);

            String total = (String)response.SelectToken("total");
            _totalNumberOfRestaurants = Convert.ToInt32(total);

            JArray entries = (JArray)response.SelectToken("entries");
            foreach(var entry in entries)
            {
                JObject links = (JObject)entry.SelectToken("links");
                JObject self = (JObject)links.SelectToken("self");
                string url = (String)self.SelectToken("href");
                urls.Add(url);
            }

            _restaurantUrls = urls;
        }