public override LoadRequest GetLoadRequest(ExploreVenuesLoadContext context, Type objectType) { var components = new List <string>(); string section = context.Section; if (section != null) { components.Add("section"); components.Add(section); } components.Add("radius"); components.Add(context.RadiusMeters.ToString(CultureInfo.InvariantCulture)); string query = context.Query; if (query != null) { components.Add("query"); components.Add(query); } return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "venues/explore", GeoMethodType.Required, components.ToArray()))); }
public override LoadRequest GetLoadRequest(PhotoAddLoadContext loadContext, Type objectType) { if (LocalCredentials.Current != null && string.IsNullOrEmpty(LocalCredentials.Current.UserId)) { throw new UserIgnoreException(); } var @params = loadContext.GetMultipartFormParameters(); var la = LocationAssistant.Instance.LastKnownLocation; // TODO: Centralize the dictionary filling of this between this method. if (la != null && !double.IsNaN(la.Latitude) && !double.IsNaN((la.Longitude))) { @params["ll"] = la.Latitude.ToString(CultureInfo.InvariantCulture) + "," + la.Longitude.ToString(CultureInfo.InvariantCulture); if (!double.IsNaN(la.HorizontalAccuracy)) { @params["llAcc"] = la.HorizontalAccuracy.ToString(CultureInfo.InvariantCulture); } if (!double.IsNaN(la.VerticalAccuracy) && la.VerticalAccuracy != 0.0 && !double.IsNaN(la.Altitude)) { @params["altAcc"] = la.VerticalAccuracy.ToString(CultureInfo.InvariantCulture); @params["alt"] = la.Altitude.ToString(CultureInfo.InvariantCulture); } } return(BuildPostRequest( loadContext, FourSquareWebClient.BuildFourSquareUri( "photos/add", GeoMethodType.None), @params, // GeoMethodType.Optional, loadContext.GetPhotoBytes())); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { string id = (string)context.Identity; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "venues/" + id + "/events", GeoMethodType.Optional))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { string id = (string)context.Identity; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/" + id + "/mayorships", GeoMethodType.None))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "tips/" + context.Identity + "/listed", GeoMethodType.Optional, null))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { var id = (string)context.Identity; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/" + id + "/tips", GeoMethodType.None, "sort", "recent"))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { //var id = (string)context.Identity; string method = "venues/categories"; // +id; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( method, GeoMethodType.None))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { var id = (string)context.Identity; string method = "checkins/" + id; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( method, GeoMethodType.None))); }
public override LoadRequest GetLoadRequest(SpecialLoadContext context, Type objectType) { return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "specials/" + context.SpecialId, GeoMethodType.None, "venueId", context.VenueId))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { if (LocalCredentials.Current != null && string.IsNullOrEmpty(LocalCredentials.Current.UserId)) { throw new UserIgnoreException(); } return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "settings/all", GeoMethodType.None))); }
public override LoadRequest GetLoadRequest(LimitingLoadContext context, Type objectType) { Debug.Assert(context.Limit <= 100); return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "specials/search", GeoMethodType.Required, "limit", context.Limit.ToString(CultureInfo.InvariantCulture) ))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { if (LocalCredentials.Current != null && string.IsNullOrEmpty(LocalCredentials.Current.UserId)) { throw new UserIgnoreException(); //throw new UserIntendedException("You must be signed into the service.", "Checkins.GetLoadRequest"); } return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "checkins/recent", GeoMethodType.Optional))); }
public static void AddComment(string checkinId, string text, Action success, Action <Exception> failure) { var client = (new FourSquareWebClient()).GetWrappedClientTemporary(); var uuri = FourSquareWebClient.BuildFourSquareUri( "checkins/" + checkinId + "/addcomment", GeoMethodType.None, "text", text); // real app will... %20%26%20 for space & space ( & ) var uri = uuri.Uri; var newUri = FourSquareWebClient.CreateServiceRequest(uri, true); client.UploadStringCompleted += (x, xe) => //client.DownloadStringCompleted += (x, xe) => { Exception e = null; if (xe.Error != null) { e = xe.Error; } else { string rs = xe.Result; try { var json = FourSquareDataLoaderBase <LoadContext> .ProcessMetaAndNotificationsReturnJson(rs); } catch (Exception ee) { e = new UserIntendedException("There was a problem adding your comment, please try again later.", ee); } } client = null; // Result now if there is not a photo. if (e != null) { failure(e); } else { success(); } }; // POST request. client.UploadStringAsync(newUri, string.Empty); //client.DownloadStringAsyncWithPost(newUri, string.Empty); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { var id = (string)context.Identity; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/" + id + "/lists", GeoMethodType.Optional //"sort", //sortType ))); }
public override LoadRequest GetLoadRequest(UserAndCategoryLoadContext context, Type objectType) { string id = (string)context.Identity; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/" + id + "/venuehistory", GeoMethodType.Optional, "categoryId", context.CategoryId ?? string.Empty ))); }
public override LoadRequest GetLoadRequest(UserSearchLoadContext context, Type objectType) { string typeString = context.SearchType == UserSearchLoadContext.UserSearchType.TwitterSource ? "twitterSource" : context.SearchType.ToString().ToLowerInvariant(); return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/search", GeoMethodType.Optional, typeString, context.Query))); }
public override LoadRequest GetLoadRequest(UpdatesLoadContext context, Type objectType) { var parameters = new List <string>(); parameters.Add("offset"); parameters.Add(context.Offset.ToString(CultureInfo.InvariantCulture)); parameters.Add("limit"); parameters.Add(context.Limit.ToString(CultureInfo.InvariantCulture)); return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "updates/notifications", GeoMethodType.Optional, parameters.ToArray()))); }
public override LoadRequest GetLoadRequest(LeaderboardLoadContext context, Type objectType) { var parameters = new List <string>(); if (context.Neighbors != null) { parameters.Add("neighbors"); parameters.Add(context.Neighbors); } return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/leaderboard", GeoMethodType.Optional, parameters.ToArray()))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { // TODO: CONSIDER: Expose sorting properly through a load context instead. string sortType = LocationAssistant.Instance.LastKnownLocation != null ? "nearby" : "recent"; var id = (string)context.Identity; return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "users/" + id + "/todos", GeoMethodType.Optional, "sort", sortType ))); }
public override LoadRequest GetLoadRequest(ListLoadContext context, Type objectType) { var parameters = new List <string>(); //if (context.Limit != null) //{ parameters.Add("limit"); parameters.Add(context.Limit.ToString(CultureInfo.InvariantCulture)); //} return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "lists/" + context.Identity, GeoMethodType.Optional, parameters.ToArray()))); }
public override LoadRequest GetLoadRequest(LoadContext context, Type objectType) { // The "MORE" button should temporarily increase this... int limit = 30; Debug.Assert(limit >= 0 && limit < 50, "0-50 is the valid range for the limit."); return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "venues/search", GeoMethodType.Required, "intent", "checkin", "limit", limit.ToString(CultureInfo.InvariantCulture)))); }
public override LoadRequest GetLoadRequest(TrendingVenuesLoadContext context, Type objectType) { Debug.Assert(context.Limit <= 100); Debug.Assert(context.RadiusMeters > 0); //Debug.Assert(context.RadiusMeters <= 5000); return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "venues/trending", GeoMethodType.Required, "limit", context.Limit.ToString(), "radius", context.RadiusMeters.ToString() ))); }
public override LoadRequest GetLoadRequest(VenueSearchLoadContext context, Type objectType) { Debug.Assert(context.Limit <= 100); return(BuildRequest( context, FourSquareWebClient.BuildFourSquareUri( "venues/search", GeoMethodType.Required, "query", context.Query, // will be null if in the no-query mode. // consider exposing other intents on the context "intent", "checkin", "limit", context.Limit.ToString(CultureInfo.InvariantCulture) ))); }
// DESIGN: Not a very good place for a web service call like this. public static void AddNewTip(string venueId, string tipText, Stream photo, Action <Tip, Exception> result) { // NOTE: Official API supports an extra "url" parameter to associate var client = (new FourSquareWebClient()).GetWrappedClientTemporary(); var uuri = FourSquareWebClient.BuildFourSquareUri( "tips/add", GeoMethodType.None, "venueId", venueId, "text", tipText); Uri uri = uuri.Uri; var newUri = FourSquareWebClient.CreateServiceRequest(uri, true); client.UploadStringCompleted += (x, xe) => { Exception e = null; Tip t = null; if (xe.Error != null) { e = xe.Error; } else { string rs = xe.Result; try { var json = FourSquareDataLoaderBase <LoadContext> .ProcessMetaAndNotificationsReturnJson(rs); Tip tip = Tip.ParseJson(json["tip"], typeof(Venue), venueId); if (photo != null) { // Result comes after the photo upload. var req = Model.PhotoAddLoadContext.AddPhotoToTip(tip.TipId, false, false); req.SetPhotoBytes(photo); FourSquare.Instance.AddPhoto(req, (pic) => { // that's it.. //RefreshVenue(null); result(tip, null); }, (fail) => { result(null, fail); }); } } catch (Exception ee) { e = new UserIntendedException("There was a problem adding the tip, please try again later.", ee); } } client = null; // Result now if there is not a photo. if (photo == null) { result(t, e); } }; // POST request. client.UploadStringAsync(newUri, string.Empty); //client.DownloadStringAsyncWithPost(r, string.Empty); }