public GooglePlaceTextSearchModel GooglePlacesTextSearch(RestaurantSearchByTextModel restaurantSearchByTextModel) { if (restaurantSearchByTextModel != null) { GooglePlaceTextSearchModel googlePlacesTextSearchModel = new GooglePlaceTextSearchModel(); googlePlacesTextSearchModel.Price = new PriceLimit() { MaxPrice = restaurantSearchByTextModel.MaxPrice.ToString(), //TODO: include min price in the parameter model MinPrice = "0" }; googlePlacesTextSearchModel.geometry = new Geometry() { location = new Location() { Lat = (restaurantSearchByTextModel?.CurrentLocation?.Lat) ?? "30.5043", Lng = (restaurantSearchByTextModel?.CurrentLocation?.Lng) ?? "-90.4769" } }; googlePlacesTextSearchModel.Radius = restaurantSearchByTextModel.Radius ?? "50000"; googlePlacesTextSearchModel.OpenNow = restaurantSearchByTextModel.OpenNow; googlePlacesTextSearchModel.Query = restaurantSearchByTextModel.Query ?? "beer"; ; return(googlePlacesTextSearchModel); } return(null); }
static void Main(string[] args) { RestaurantSearchByTextModel restaurantSearchRequest = new RestaurantSearchByTextModel() { OpenNow = "true", Query = "chicken " }; //testGoogleEndPoint(); var query = "Chicken fajita"; RestClient Client = new RestClient("http://localhost:61774/api/restaurant"); string url = "search?q={query}&app_id=896840d0&app_key={key}"; RestRequest request = new RestRequest(url, Method.GET); request.AddHeader("Accept", "application/json"); request.AddHeader("Content-Type", "application/json; charset=utf-8"); request.RequestFormat = DataFormat.Json; request.AddParameter("key", "c9bf18dcd7c303612a47ad7a6307e772", ParameterType.UrlSegment); request.AddParameter("query", query, ParameterType.UrlSegment); var response = Client.Execute(request);//[JSON].hits.[0].recipe.label var jo = JObject.Parse(response.Content); File.WriteAllText("C:\\Users\\Bibek\\Desktop\\test", response.Content); var xxxxx = JsonConvert.DeserializeObject <EdamanResponseMapper>(response.Content); var extractedRecipte = xxxxx.Hits.Where(x => x.Recipe.Label.ToLower().Contains(query.ToLower())); var breakpointTest = "here"; }