Пример #1
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            KrogerClient     krogerClient     = Startup.KrogerClient;
            SearchAllRequest searchAllRequest = JsonConvert.DeserializeObject <SearchAllRequest>(req.Content.ReadAsStringAsync().Result);

            SearchAllResponse searchAllResponse = krogerClient.SearchAll(searchAllRequest);

            ProductsDetailsResponse productsDetailsResponse = await krogerClient.ProductsDetailsAsync(new ProductsDetailsRequest()
            {
                UPCs = searchAllResponse.Upcs
            });

            return(req.CreateResponse(HttpStatusCode.OK,
                                      new { productsDetailsResponse.Products }
                                      ));
        }
Пример #2
0
        /// <summary>
        /// Peform a keyword search across site content
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <SearchAllResponse> SearchAllAsync(SearchAllRequest request)
        {
            SearchAllResponse response = null;
            string            urlQuery = string.Format(SITE_SEARCH_ALL, request.Start, request.Count, request.Query, 0); //0 products tab



            IRestRequest restRequest = new RestRequest(urlQuery, Method.POST);

            restRequest.AddCookie("_", "_"); //a cookie is required by the request contract,
                                             //restsharp requires that this not be an empty string in order for the header be set

            IRestResponse <SearchAllResponse> restResponse = await _client.ExecutePostTaskAsync <SearchAllResponse>(restRequest);

            response = restResponse.Data;


            return(response);
        }