Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="client"></param>
        /// <param name="query"></param>
        /// <param name="region">https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains</param>
        /// <param name="returnFields"></param>
        /// <returns></returns>
        public async Task <Response <Place> > FindBusiness(HttpClient client, string query, double?lat = null, double?lng = null, int?radiusInMeters = 50000, string region = null, string language = null, string pageToken = null, PlaceType?type = null, string[] returnFields = null)
        {
            var location = lat.HasValue && lng.HasValue ? $"{lat},{lng}" : string.Empty;

            var uri = "";

            if (string.IsNullOrWhiteSpace(pageToken))
            {
                uri = GetPlacesQueryString(
                    "textsearch",
                    ("query", query),
                    ("type", type?.ToString()),
                    ("location", location),
                    ("radius", radiusInMeters?.ToString()),
                    ("region", region),
                    ("language", language),
                    ("fields", string.Join(",", returnFields ?? GoogleApiBase.SearchFieldsBasic.Concat(GoogleApiBase.SearchFieldsContact).Concat(GoogleApiBase.SearchFieldsAtmosphere)))
                    );
            }
            else
            {
                uri = $"{GeoPlacesUrl}textsearch/json?pagetoken={pageToken}&key={GoogleApiKey}";
            }

            return(await MakeRequest(client, uri));
        }
Ejemplo n.º 2
0
        public async Task <Response <Place> > FindPlaces(HttpClient client, string input, string[] returnFields = null)
        {
            var uri = GetPlacesQueryString(
                "findplacefromtext",
                ("input", input),
                ("inputtype", "textquery"),
                ("fields", string.Join(",", returnFields ?? GoogleApiBase.SearchFieldsBasic.Concat(GoogleApiBase.SearchFieldsContact).Concat(GoogleApiBase.SearchFieldsAtmosphere)))
                );

            var response = await client.GetAsync(uri);

            return(await Place.ParseResponse(response));
        }
Ejemplo n.º 3
0
        public async Task <Response <Place> > GetPlaceDetailsById(HttpClient client, string placeId, string[] returnFields = null, string sessionToken = null)
        {
            var uri = GetPlacesQueryString(
                "details",
                ("place_id", placeId),
                ("sessiontoken", sessionToken),
                ("fields", string.Join(",", returnFields ?? GoogleApiBase.DetailsFieldsBasic.Concat(GoogleApiBase.DetailsFieldsContact).Concat(GoogleApiBase.DetailsFieldsAtmosphere)))
                );

            var response = await client.GetAsync(uri);

            return(await Place.ParseResponse(response));
        }