Exemplo n.º 1
0
        public Task <FoursquareResponse <Empty> > DeletePhoto(string id)
        {
            var req = new FoursquareRequest(ApiBase + $"photos/{id}/delete", FoursquareRequest.HttpMethod.POST);

            AddCommonParams(ref req);
            return(req.MakeRequest <Empty>());
        }
Exemplo n.º 2
0
        public Task <FoursquareResponse <AddVenue> > AddVenue(Venue v, string category, FoursquareLocation loc, bool isPrivate = false, string dupeDetectedOverrideKey = null)
        {
            var req = new FoursquareRequest(ApiBase + "venues/add", FoursquareRequest.HttpMethod.POST);

            req.AddParam("name", v.name);
            req.AddParam("primaryCategoryId", category);
            req.AddParam("ignoreDuplicatesKey", dupeDetectedOverrideKey);
            req.AddParam("ignoreDuplicates", !string.IsNullOrEmpty(dupeDetectedOverrideKey) ? "true" : "false");
            req.AddParam("private", isPrivate.ToString().ToLower());

            if (v.location != null)
            {
                req.AddParam("address", v.location.address);
                req.AddParam("crossStreet", v.location.crossStreet);
                req.AddParam("city", v.location.city);
                req.AddParam("state", v.location.state);
                req.AddParam("zip", v.location.postalCode);
            }

            if (v.contact != null)
            {
                req.AddParam("phone", v.contact.phone);
                req.AddParam("twitter", v.contact.twitter);
            }
            req.AddParam("url", v.url);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <AddVenue>());
        }
Exemplo n.º 3
0
        public Task <FoursquareResponse <UserResponse> > UserDetails(string userId)
        {
            var req = new FoursquareRequest(ApiBase + $"users/{userId}");

            AddCommonParams(ref req);
            return(req.MakeRequest <UserResponse>());
        }
Exemplo n.º 4
0
        public Task <FoursquareResponse <Share> > AddListItem(string type, string id, string listId)
        {
            var endPoint = "lists/{0}/additem";
            var idKey    = "";

            switch (type)
            {
            case Constants.TYPE_TIP:
                idKey = "tipId";
                break;

            case Constants.TYPE_VENUE:
                idKey = "venueId";
                break;

            case Constants.TYPE_SHARE:
                idKey = "itemId";
                break;
            }

            var req = new FoursquareRequest(string.Format(ApiBase + string.Format(endPoint, listId)), FoursquareRequest.HttpMethod.POST);

            req.AddParam(idKey, id);

            AddCommonParams(ref req);

            return(req.MakeRequest <Share>());
        }
Exemplo n.º 5
0
 private static void AddLocationParams(this FoursquareRequest refRequest, FoursquareLocation location)
 {
     if (location != null)
     {
         refRequest.AddParam("ll", location.Lat.ToString(CultureInfo.InvariantCulture) + "," + location.Lng.ToString(CultureInfo.InvariantCulture));
         refRequest.AddParam("llAcc", location.Accuracy.ToString());
     }
 }
Exemplo n.º 6
0
        public Task <FoursquareResponse <EventsResponse> > VenueEvents(string id, string intent = null)
        {
            var req = new FoursquareRequest(ApiBase + $"venues/{id}/events");

            req.AddParam("intent", intent);
            AddCommonParams(ref req);
            return(req.MakeRequest <EventsResponse>());
        }
Exemplo n.º 7
0
        public Task <FoursquareResponse <Categories> > Categories(FoursquareLocation loc = null, string countryCode = null)
        {
            var req = new FoursquareRequest(ApiBase + "venues/categories");

            req.AddParam("cc", countryCode);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <Categories>());
        }
Exemplo n.º 8
0
        public Task <FoursquareResponse <TipListResponse> > CreateList(string listName)
        {
            var req = new FoursquareRequest(ApiBase + "lists/add", FoursquareRequest.HttpMethod.POST);

            req.AddParam("name", listName);
            AddCommonParams(ref req);

            return(req.MakeRequest <TipListResponse>());
        }
Exemplo n.º 9
0
        public Task <FoursquareResponse <PhotosResponse> > UserPhotos(string id = "self", int limit = Constants.DEFAULT_PAGE_SIZE, int offset = 0)
        {
            var req = new FoursquareRequest(ApiBase + $"users/{id}/photos");

            req.AddParam("limit", limit.ToString());
            req.AddParam("offset", offset.ToString());
            AddCommonParams(ref req);
            return(req.MakeRequest <PhotosResponse>());
        }
Exemplo n.º 10
0
        public Task <FoursquareResponse <TipResponse> > TipDetail(string id, string intent = null, FoursquareLocation loc = null)
        {
            var req = new FoursquareRequest(ApiBase + "tips/" + id);

            req.AddParam("intent", intent);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <TipResponse>());
        }
Exemplo n.º 11
0
        public Task <FoursquareResponse <AccessToken> > ExchangeCodeForToken(string code, string redirectUri = null)
        {
            var req = new FoursquareRequest(OAuthBase + "access_token");

            AddCommonParams(ref req);
            req.AddParam("grant_type", "authorization_code");
            req.AddParam("code", code);
            req.AddParam("redirect_uri", redirectUri);
            return(req.MakeRequest <AccessToken>());
        }
Exemplo n.º 12
0
        public Task <FoursquareResponse <PhotosResponse> > VenuePhotos(string id,
                                                                       int limit = Constants.DEFAULT_PAGE_SIZE, int offset = 0, FoursquareLocation loc = null)
        {
            var req = new FoursquareRequest(ApiBase + $"venues/{id}/photos");

            req.AddParam("limit", limit.ToString());
            req.AddParam("offset", offset.ToString());
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <PhotosResponse>());
        }
Exemplo n.º 13
0
        public Task <FoursquareResponse <FoursquareGeocode> > GeocodeAutocomplete(string query, FoursquareLocation loc, int limit = 5)
        {
            var req = new FoursquareRequest(ApiBase + "geo/geocode");

            req.AddParam("maxInterpretations", limit.ToString(CultureInfo.InvariantCulture));
            req.AddParam("autocomplete", "true");
            req.AddParam("query", query);
            AddCommonParams(ref req);
            AddLocationParams(ref req, loc);
            return(req.MakeRequest <FoursquareGeocode>());
        }
Exemplo n.º 14
0
        public Task <FoursquareResponse <TipListResponse> > ListDetail(string id, int limit = Constants.DEFAULT_PAGE_SIZE, int offset = 0, FoursquareLocation loc = null, string includeVenues = null, string sort = null)
        {
            var req = new FoursquareRequest(ApiBase + $"lists/{id}");

            req.AddParam("limit", limit.ToString());
            req.AddParam("offset", offset.ToString());
            req.AddParam("sort", sort);
            req.AddParam("includeVenues", includeVenues);
            AddCommonParams(ref req);
            AddLocationParams(ref req, loc);
            return(req.MakeRequest <TipListResponse>());
        }
Exemplo n.º 15
0
        public Task <FoursquareResponse <TipsResponse> > UserTips(string id, string sort = null, int limit = Constants.DEFAULT_PAGE_SIZE, int offset = 0, string subjectId = null, FoursquareLocation loc = null)
        {
            var req = new FoursquareRequest(ApiBase + $"users/{id}/tips");

            req.AddParam("sort", sort);
            req.AddParam("limit", limit.ToString());
            req.AddParam("offset", offset.ToString());
            req.AddParam("subjectId", subjectId);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <TipsResponse>());
        }
Exemplo n.º 16
0
        public Task <FoursquareResponse <TipListsResponse> > GetLists(string userId, string group, FoursquareLocation location = null, int limit = Constants.DEFAULT_PAGE_SIZE, int offset = 0, bool sortNearby = false)
        {
            var req = new FoursquareRequest(ApiBase + $"users/{(string.IsNullOrEmpty(userId) ? "self" : userId)}/lists");

            req.AddParam("limit", limit.ToString());
            req.AddParam("group", group);
            req.AddParam("offset", offset.ToString());
            req.AddParam("sort", sortNearby ? "nearby" : "");

            AddCommonParams(ref req);
            AddLocationParams(ref req, location);
            return(req.MakeRequest <TipListsResponse>());
        }
Exemplo n.º 17
0
        public Task <FoursquareResponse <VenueResponse> > VenueDetails(string id,
                                                                       string promotedTipId = null, string intent      = null, FoursquareLocation loc = null,
                                                                       string tasteIds      = null, string searchTipId = null)
        {
            var req = new FoursquareRequest(ApiBase + $"venues/{id}");

            req.AddParam("intent", intent);
            req.AddParam("tasteIds", tasteIds);
            req.AddParam("searchTipId", searchTipId);
            req.AddParam("promotedTipId", promotedTipId);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <VenueResponse>());
        }
Exemplo n.º 18
0
        public Task <FoursquareResponse <HistorySearch> > SearchHistory(string id, int offset = 0, int limit            = Constants.DEFAULT_PAGE_SIZE, string geoId = null,
                                                                        string venueId        = null, string categoryId = null, string friendId = null, string stickerId = null, string near = null, string llBounds = null, FoursquareLocation loc = null)
        {
            var req = new FoursquareRequest(ApiBase + $"users/{id}/historysearch");

            req.AddParam("offset", offset.ToString());
            req.AddParam("limit", limit.ToString());
            req.AddParam("venueIds", venueId);
            req.AddParam("geoId", geoId);
            req.AddParam("stickerId", stickerId);
            req.AddParam("near", near);
            req.AddParam("categoryId", categoryId);
            req.AddParam("friendId", friendId);
            req.AddParam("llBounds", llBounds);
            AddCommonParams(ref req);
            AddLocationParams(ref req, loc);
            return(req.MakeRequest <HistorySearch>());
        }
Exemplo n.º 19
0
        private void AddCommonParams(ref FoursquareRequest refRequest)
        {
            if (IsLoggedIn())
            {
                refRequest.AddParam("oauth_token", Token);
            }
            else
            {
                refRequest.AddParam("client_id", _clientId);
                refRequest.AddParam("client_secret", _clientSecret);
            }

            if (!refRequest.HasParam("v"))
            {
                refRequest.AddParam("v", _version);
            }
            refRequest.AddParam("m", "foursquare");
        }
Exemplo n.º 20
0
        public Task <FoursquareResponse <TipsResponse> > VenueTips(string id,
                                                                   string sort          = null, string query = null, string tasteId = null,
                                                                   string promotedTipId = null, string searchTipId                = null,
                                                                   int limit            = Constants.DEFAULT_PAGE_SIZE, int offset = 0, string group = null, FoursquareLocation loc = null)
        {
            var req = new FoursquareRequest(ApiBase + $"venues/{id}/tips");

            req.AddParam("sort", sort);
            req.AddParam("limit", limit.ToString());
            req.AddParam("offset", offset.ToString());
            req.AddParam("query", query);
            req.AddParam("tasteId", tasteId);
            req.AddParam("group", group);
            req.AddParam("promotedTipId", promotedTipId);
            req.AddParam("searchTipId", searchTipId);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <TipsResponse>());
        }
Exemplo n.º 21
0
        public Task <FoursquareResponse <VenueSearch> > SearchVenues(FoursquareLocation loc,
                                                                     string query      = null,
                                                                     int limit         = Constants.DEFAULT_PAGE_SIZE,
                                                                     string appSource  = null,
                                                                     bool spellCorrect = false,
                                                                     string intent     = "checkin",
                                                                     string wifi       = null)
        {
            var req = new FoursquareRequest(ApiBase + "venues/search");

            req.AddParam("query", query);
            req.AddParam("limit", limit.ToString());
            req.AddParam("appSource", appSource);
            req.AddParam("noCorrect", spellCorrect.ToString().ToLower());
            req.AddParam("intent", intent);
            req.AddParam("wifiScan", wifi);
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <VenueSearch>());
        }
Exemplo n.º 22
0
        public Task <FoursquareResponse <AutoComplete> > AutoComplete(string query, string groups = null,
                                                                      int limit     = Constants.DEFAULT_PAGE_SIZE, FoursquareLocation loc = null, CancellationTokenSource cancel = null,
                                                                      bool searched = false, string nearbyVenueIds = null)
        {
            var req = new FoursquareRequest(ApiBase + "search/autocomplete");

            req.AddParam("limit", limit.ToString());
            req.AddParam("group", groups);
            req.AddParam("query", query);
            req.AddParam("nearbyVenueIds", nearbyVenueIds);
            if (searched)
            {
                req.AddParam("searched", "true");
            }
            if (loc == null)
            {
                req.AddParam("intent", "global");
            }
            AddCommonParams(ref req);
            AddLocationParams(ref req, loc);
            return(req.MakeRequest <AutoComplete>(cancel?.Token ?? new CancellationTokenSource().Token));
        }
Exemplo n.º 23
0
        public Task <FoursquareResponse <PhotoResponse> > AddPhoto(Stream file, string checkinId = null, string venueId = null, string tipId = null, bool twitter = false, bool facebook = false, bool makePublic = false, FoursquareLocation loc = null)
        {
            var req = new FoursquareRequest(ApiBase + "photos/add", FoursquareRequest.HttpMethod.PHOTO_POST)
            {
                File = file
            };
            var broadcast = string.Empty;

            if (twitter)
            {
                broadcast += "twitter";
            }
            if (facebook)
            {
                if (!string.IsNullOrEmpty(broadcast))
                {
                    broadcast += ",";
                }
                broadcast += "facebook";
            }
            if (!string.IsNullOrEmpty(checkinId))
            {
                req.AddParam("checkinId", checkinId);
                req.AddParam("broadcast", broadcast);
                req.AddParam("public", makePublic.ToString().ToLower());
            }
            else if (!string.IsNullOrEmpty(venueId))
            {
                req.AddParam("venueId", venueId);
            }
            else if (!string.IsNullOrEmpty(tipId))
            {
                req.AddParam("tipId", tipId);
            }
            AddLocationParams(ref req, loc);
            AddCommonParams(ref req);
            return(req.MakeRequest <PhotoResponse>());
        }
Exemplo n.º 24
0
        public static void AddBrowseExploreParams(this FoursquareRequest req, SearchRecommendationFilters filters = null,
                                                  FoursquareLocation currentLocation = null, FoursquareLocation location = null, FoursquareLocation ne = null, FoursquareLocation sw = null,
                                                  string near = null, string nearGeoId = null)
        {
            if (filters != null)
            {
                if (!string.IsNullOrEmpty(filters.query))
                {
                    req.AddParam("query", filters.query);
                }
                if (filters.intent != null)
                {
                    req.AddParam("intent", filters.intent.id);
                }
                if (filters.subintent != null)
                {
                    req.AddParam("subintent", filters.subintent.id);
                }
                if (filters.openAt != null)
                {
                    if (filters.openAt.openNow)
                    {
                        req.AddParam("openNow", "1");
                    }
                    else if (filters.openAt.localDay >= 0 && !string.IsNullOrEmpty(filters.openAt.localTime))
                    {
                        req.AddParam("localDay", filters.openAt.localDay == 0 ? "7" : filters.openAt.localDay.ToString());
                        req.AddParam("localTime", filters.openAt.localTime);
                    }
                }
                if (filters.refinements != null && filters.refinements.Count > 0)
                {
                    var refinements = new Dictionary <string, string>();
                    for (int i = 0; i < filters.refinements.Count; i++)
                    {
                        SearchRecommendationRefinement item = filters.refinements[i];
                        if (!string.IsNullOrEmpty(item.groupType))
                        {
                            if (refinements.ContainsKey(item.groupType))
                            {
                                string val = refinements[item.groupType];
                                refinements[item.groupType] = val + "," + RefinementString(item, i);
                            }
                            else
                            {
                                refinements.Add(item.groupType, RefinementString(item, i));
                            }
                        }
                    }

                    foreach (var item in refinements.Keys)
                    {
                        req.AddParam(item, refinements[item]);
                    }
                }
            }

            if (ne == null && sw == null)
            {
                req.AddLocationParams(location);
                if (!string.IsNullOrEmpty(near))
                {
                    req.AddParam("near", near);
                    if (!string.IsNullOrEmpty(nearGeoId))
                    {
                        req.AddParam("nearGeoId", nearGeoId);
                    }
                }
            }
            else
            {
                req.AddParam("ne", LatLngFromLocation(ne));
                req.AddParam("sw", LatLngFromLocation(sw));
            }

            if (currentLocation != null)
            {
                req.AddParam("userll", LatLngFromLocation(currentLocation));
            }
        }
 public FoursquareRequest AddSubRequest(FoursquareRequest request)
 {
     SubRequests = SubRequests ?? new List <FoursquareRequest>();
     SubRequests.Add(request);
     return(this);
 }
Exemplo n.º 26
0
        public Task <FoursquareResponse <SearchRecommendation> > SearchRecommendations(SearchRecommendationFilters filters, RecommendationSort sort = RecommendationSort.BestMatch,
                                                                                       string near = null, string nearGeoId = null, int snippetCharLimit = Constants.BROWSE_EXPLORE_SNIPPET_LENGTH,
                                                                                       FoursquareLocation location   = null, FoursquareLocation currentLocation = null, FoursquareLocation ne = null, FoursquareLocation sw = null,
                                                                                       bool ignoreSpellingCorrection = false, int?searchRadius           = null, string mode = null, int limit = Constants.DEFAULT_PAGE_SIZE, int offset = 0,
                                                                                       List <string> excludeVenues   = null, List <string> includeVenues = null, string referralId = null, SearchRecommendationLocations.SearchRecommendationGeoBounds bounds = null,
                                                                                       int initialOffset             = 0)
        {
            var req = new FoursquareRequest(ApiBase + "search/recommendations");

            if (searchRadius.HasValue)
            {
                req.AddParam("radius", searchRadius.GetValueOrDefault(0).ToString());
            }
            req.AddParam("snippetCharacterLimit", snippetCharLimit.ToString());
            switch (sort)
            {
            case RecommendationSort.Distance:
                req.AddParam("sortByDistance", "1");
                break;

            case RecommendationSort.Rating:
                req.AddParam("sortByVenueRating", "1");
                break;
            }

            if (!string.IsNullOrEmpty(mode))
            {
                req.AddParam("mode", mode);
            }
            if (excludeVenues != null && excludeVenues.Count > 0)
            {
                req.AddParam("excludeVenues", string.Join(",", excludeVenues));
            }
            if (includeVenues != null && includeVenues.Count > 0)
            {
                req.AddParam("includeVenues", string.Join(",", includeVenues));
            }
            if (ignoreSpellingCorrection)
            {
                req.AddParam("noCorrect", "1");
            }
            if (initialOffset > 0)
            {
                req.AddParam("initialOffset", initialOffset.ToString(CultureInfo.InvariantCulture));
            }

            req.AddParam("limit", limit.ToString());
            req.AddParam("offset", offset.ToString());
            req.AddParam("referralId", referralId);

            req.AddBrowseExploreParams(filters, currentLocation, location, ne, sw, near, nearGeoId);

            if (bounds != null)
            {
                if (bounds.box != null)
                {
                    req.AddParam("fromGeoBounds", "true");
                    req.AddParam("ne", ApiUtils.LatLngFromLocation(new FoursquareLocation {
                        Lat = bounds.box.ne.lat, Lng = bounds.box.ne.lng
                    }));
                    req.AddParam("sw", ApiUtils.LatLngFromLocation(new FoursquareLocation {
                        Lat = bounds.box.sw.lat, Lng = bounds.box.sw.lng
                    }));
                }
                else if (bounds.circle != null)
                {
                    req.AddParam("fromGeoBounds", "true");
                    req.AddParam("radius", bounds.circle.radius.ToString(CultureInfo.InvariantCulture));
                }
                else if (!string.IsNullOrEmpty(bounds.geoId))
                {
                    req.AddParam("fromGeoBounds", "true");
                }
            }

            AddCommonParams(ref req);
            return(req.MakeRequest <SearchRecommendation>());
        }