Beispiel #1
0
        /// <summary>
        /// Search for a location by geographic coordinate.
        /// <para>
        /// <c>Requires Authentication: False</c>
        /// </para>
        /// </summary>
        /// <param name="latitude">Latitude of the center search coordinate. If used, lng is required.</param>
        /// <param name="longitude">Longitude of the center search coordinate. If used, lat is required.</param>
        /// <param name="distance">Default is 1000m (distance=1000), max distance is 5000.</param>
        /// <param name="foursquareId">Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use lat and lng.</param>
        /// <param name="foursquareVersion">The version of the FourSquare ID  you are using.  Either version 1 or 2.</param>
        public Task<LocationsResponse> Search(double? latitude = null, double? longitude = null, double distance = 1000, string foursquareId = null, FoursquareVersion? foursquareVersion = null) {
            var request = base.Request("search");

            if (foursquareId != null && foursquareVersion == null)
            {
                throw new ArgumentNullException("foursquareVersion", "You should specify FoursquareVersion when using FoursquareId");
            }

            if (foursquareVersion != null) {
                switch (foursquareVersion) {
                    case FoursquareVersion.One:
                        request.AddParameter("foursquare_id", foursquareId);
                        break;
                    case FoursquareVersion.Two:
                        request.AddParameter("foursquare_v2_id", foursquareId);
                        break;
                    default:
                        break;
                }
            } else {
                request.AddParameter("lat", latitude);
                request.AddParameter("lng", longitude);
            }

            request.AddParameter("distance", distance);

            return base.Client.ExecuteAsync<LocationsResponse>(request);
        }
Beispiel #2
0
        /// <summary>
        /// Search for a location by geographic coordinate.
        /// <para>Requires Authentication: False</para>
        /// </summary>
        /// <param name="foursquareId">Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use lat and lng.</param>
        /// <param name="foursquareVersion">The version of the FourSquare ID  you are using.  Either version 1 or 2.</param>
        /// <returns>location response</returns>
        /// <exception cref="System.ArgumentException">foursquareId empty;foursquareId</exception>
        public Task <LocationsResponse> Search(string foursquareId, FoursquareVersion foursquareVersion)
        {
            if (string.IsNullOrWhiteSpace(foursquareId))
            {
                throw new ArgumentException("foursquareId empty", "foursquareId");
            }

            var request = Request("search");

            switch (foursquareVersion)
            {
            case FoursquareVersion.One:
                request.AddParameter("foursquare_id", foursquareId);
                break;

            case FoursquareVersion.Two:
                request.AddParameter("foursquare_v2_id", foursquareId);
                break;
            }

            return(Client.ExecuteAsync <LocationsResponse>(request));
        }
        private string SearchJson(double latitude, double longitude, string foursquare_id, FoursquareVersion foursquare_version, int distance) {
            string uri = string.Format(base.Uri + "search?client_id={0}", InstagramConfig.ClientId);

            if (foursquare_version != FoursquareVersion.None) {
                switch (foursquare_version) {
                    case FoursquareVersion.One:
                        uri += "&foursquare_id=" + foursquare_id;
                        break;
                    case FoursquareVersion.Two:
                        uri += "&foursquare_id=" + foursquare_id;
                        break;
                    default:
                        break;
                }
            }
            else {
                uri = string.Format(uri + "&lat={0}&lng={1}", latitude, longitude);
            }

            if (distance != 0) uri += "&distance=" + distance;

            return HttpClient.GET(uri);
        }
Beispiel #4
0
        private string SearchJson(double latitude, double longitude, string foursquare_id, FoursquareVersion foursquare_version, int distance)
        {
            string uri = string.Format(base.Uri + "search?client_id={0}", InstagramConfig.ClientId);

            if (foursquare_version != FoursquareVersion.None)
            {
                switch (foursquare_version)
                {
                case FoursquareVersion.One:
                    uri += "&foursquare_id=" + foursquare_id;
                    break;

                case FoursquareVersion.Two:
                    uri += "&foursquare_id=" + foursquare_id;
                    break;

                default:
                    break;
                }
            }
            else
            {
                uri = string.Format(uri + "&lat={0}&lng={1}", latitude, longitude);
            }

            if (distance != 0)
            {
                uri += "&distance=" + distance;
            }

            return(HttpClient.GET(uri));
        }
Beispiel #5
0
 public LocationsResponse Search(string foursquare_id, FoursquareVersion foursquare_version, int distance)
 {
     return((LocationsResponse)Mapper.Map <LocationsResponse>(SearchJson(0, 0, foursquare_id, foursquare_version, distance)));
 }
Beispiel #6
0
 public LocationsResponse Search(string foursquare_id, FoursquareVersion foursquare_version)
 {
     return(Search(foursquare_id, foursquare_version, 0));
 }
Beispiel #7
0
        /// <summary>
        /// Search for a location by geographic coordinate.
        /// <para>Requires Authentication: False</para>
        /// </summary>
        /// <param name="foursquareId">Returns a location mapped off of a foursquare v2 api location id. If used, you are not required to use lat and lng.</param>
        /// <param name="foursquareVersion">The version of the FourSquare ID  you are using.  Either version 1 or 2.</param>
        public Task<LocationsResponse> Search(string foursquareId, FoursquareVersion foursquareVersion)
        {
            if (string.IsNullOrWhiteSpace(foursquareId))
            {
                throw new ArgumentException("foursquareId empty", "foursquareId");
            }

            var request = Request("search");

            switch (foursquareVersion)
            {
                case FoursquareVersion.One:
                    request.AddParameter("foursquare_id", foursquareId);
                    break;
                case FoursquareVersion.Two:
                    request.AddParameter("foursquare_v2_id", foursquareId);
                    break;
            }

            return Client.ExecuteAsync<LocationsResponse>(request);
        }
 public LocationsResponse Search(string foursquare_id, FoursquareVersion foursquare_version, int distance) {
     return (LocationsResponse)Mapper.Map<LocationsResponse>(SearchJson(0, 0, foursquare_id, foursquare_version, distance));
 }
 public LocationsResponse Search(string foursquare_id, FoursquareVersion foursquare_version) {
     return Search(foursquare_id, foursquare_version, 0);
 }