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); }
public void BuildGoogleApiTextSearchRequest(GooglePlaceTextSearchModel googlePlaceTextSearchModel) { Client = new RestClient(ApiUrl.GooglePlacesApiTextSearchUrl); CreateRequest("json?" // + "keyword={searchFor}" // only for radarsearch + "&query={searchFor}" //include only for textsearch + "&location={location}" + "&radius={radius}" //must include if location is to be included + "&type={type}" //include for radar // +"&rankby={rankby}" //only include for radarSearch + "&key={key}" // +"&opennow" , Method.GET , ApiKeys.GooglePlacesApiKey); // googlePlacesSearch.AddParameters(GooglePlacesRequestModel_Test); //todo: move to a client request execute service provider request.AddParameter("searchFor", googlePlaceTextSearchModel.Query, ParameterType.UrlSegment); request.AddParameter("rankby", googlePlaceTextSearchModel.rankby, ParameterType.UrlSegment); request.AddParameter("location", string.Format("{0},{1}", googlePlaceTextSearchModel.geometry.location.Lat, googlePlaceTextSearchModel.geometry.location.Lng), ParameterType.UrlSegment); request.AddParameter("type", googlePlaceTextSearchModel.placeType, ParameterType.UrlSegment); request.AddParameter("radius", googlePlaceTextSearchModel.Radius, ParameterType.UrlSegment); request.AddParameter("opennow", googlePlaceTextSearchModel.OpenNow, ParameterType.UrlSegment); request.AddParameter("maxprice", googlePlaceTextSearchModel.Price.MaxPrice, ParameterType.UrlSegment); request.AddParameter("minprice", googlePlaceTextSearchModel.Price.MaxPrice, ParameterType.UrlSegment); var result = Client.Execute(request); var xxx = "test"; }
private IRestResponse BuildAndExecuteGoogleApiTextSearchService(GooglePlaceTextSearchModel googlePlaceTextSearchModel) { // var test = services.RequestBuilder.BuildGoogleApiTextSearchRequest(googlePlaceTextSearchModel); _services.GoogleApiTextSearchService.CreateRequest("json?" // only for radarsearch // + "keyword={searchFor}" //include only for textsearch + "&query={searchFor}" + "&location={location}" //must include if location is to be included + "&radius={radius}" //include for radar + "&type={type}" //only include for radarSearch // +"&rankby={rankby}" + "&key={key}" //if(openNow==false) +"&opennow" , Method.GET , ApiKeys.GooglePlacesApiKey); _services.GoogleApiTextSearchService.AddParametersTextSearch(googlePlaceTextSearchModel); var response = _services.GoogleApiTextSearchService.GetSearchResults(); return(response); }
// public void CreateRequest(string url, Method method) // { // CreateRequest(url, method,ApiKeys.GooglePlacesApiKey); // } public void AddParametersTextSearch(GooglePlaceTextSearchModel searchParameters) { Request.AddParameter("searchFor", searchParameters.Query, ParameterType.UrlSegment); Request.AddParameter("rankby", searchParameters.rankby, ParameterType.UrlSegment); Request.AddParameter("location", $"{searchParameters.geometry.location.Lat},{searchParameters.geometry.location.Lng}" , ParameterType.UrlSegment); Request.AddParameter("type", searchParameters.placeType, ParameterType.UrlSegment); Request.AddParameter("radius", searchParameters.Radius, ParameterType.UrlSegment); Request.AddParameter("opennow", searchParameters.OpenNow, ParameterType.UrlSegment); Request.AddParameter("maxprice", searchParameters.Price.MaxPrice, ParameterType.UrlSegment); Request.AddParameter("minprice", searchParameters.Price.MaxPrice, ParameterType.UrlSegment); //request.AddParameter("radius", 500000, ParameterType.UrlSegment); //"30.504373,-90.47694" restauran }
public GooglePlaceTextSearchModel GooglePlacesTextSearch(string query, string cuisineType, string categoryType, string latitude, string longitude, string radius, string maxPrice, string maxCalories, string openNow) { GooglePlaceTextSearchModel googlePlacesTextSearchModel = new GooglePlaceTextSearchModel(); googlePlacesTextSearchModel.Price = new PriceLimit() { MaxPrice = maxPrice ?? "4", //TODO: include min price in the parameter model MinPrice = "0" }; googlePlacesTextSearchModel.geometry = new Geometry() { location = new Location() { Lat = latitude ?? "30.5043", Lng = longitude ?? "-90.4769" } }; googlePlacesTextSearchModel.Radius = radius ?? "50000"; googlePlacesTextSearchModel.OpenNow = openNow ?? "false"; googlePlacesTextSearchModel.Query = query; return(googlePlacesTextSearchModel); }