com.stackmob.sdk.api
Class StackMob

java.lang.Object
  extended by com.stackmob.sdk.api.StackMob

public class StackMob
extends Object


Nested Class Summary
protected static class StackMob.RegistrationIDAndUser
           
 
Field Summary
protected  StackMobRedirectedCallback redirectedCallback
           
protected  StackMobRedirectedCallback userRedirectedCallback
           
 
Constructor Summary
StackMob(StackMob other)
           
StackMob(String apiKey, String apiSecret, String userObjectName, Integer apiVersionNumber)
          create a new StackMob object
StackMob(String apiKey, String apiSecret, String userObjectName, Integer apiVersionNumber, String urlFormat, StackMobRedirectedCallback redirectedCallback)
          create a new StackMob object.
StackMob(String apiKey, String apiSecret, String userObjectName, Integer apiVersionNumber, String apiUrlFormat, String pushUrlFormat, StackMobRedirectedCallback redirectedCallback)
           
StackMob(String apiKey, String apiSecret, String userObjectName, String appName, Integer apiVersionNumber)
          create a new StackMob object.
StackMob(String apiKey, String apiSecret, String userObjectName, String appName, Integer apiVersionNumber, String apiUrlFormat, String pushUrlFormat, StackMobRedirectedCallback redirectedCallback)
           
 
Method Summary
 StackMobRequestSendResult broadcastPushNotification(Map<String,String> payload, StackMobRawCallback callback)
          broadcast a push notification to all users of this app.
 StackMobRequestSendResult count(StackMobQuery query, StackMobRawCallback callback)
          retrieve the number of objects for a query on the StackMob platform
 StackMobRequestSendResult count(String path, StackMobRawCallback callback)
          retrieve the number of objects for a schema on the StackMob platform
 StackMobRequestSendResult delete(String path, String id, StackMobRawCallback callback)
          do a delete request to the stackmob platform
<T> StackMobRequestSendResult
deleteIdFrom(String path, String primaryId, String field, T idToDelete, boolean cascadeDelete, StackMobRawCallback callback)
          atomically remove elements from an array or has many relationship
<T> StackMobRequestSendResult
deleteIdsFrom(String path, String primaryId, String field, List<T> idsToDelete, boolean cascadeDeletes, StackMobRawCallback callback)
          atomically remove elements from an array or has many relationship
 StackMobRequestSendResult facebookLogin(String token, StackMobRawCallback callback)
          login into facebook on the StackMob platform
 StackMobRequestSendResult facebookPostMessage(String msg, StackMobRawCallback callback)
          post a message to facebook.
 StackMobRequestSendResult forgotPassword(String username, StackMobRawCallback callback)
          send out a password reset email to a user who's forgotten their password
 StackMobRequestSendResult get(StackMobQuery query, StackMobRawCallback callback)
          do a get request on the StackMob platform
 StackMobRequestSendResult get(StackMobQueryWithField query, StackMobRawCallback callback)
          do a get request on the StackMob platform
 StackMobRequestSendResult get(String path, Map<String,String> arguments, List<Map.Entry<String,String>> headers, StackMobRawCallback callback)
          do a get request on the StackMob platform
 StackMobRequestSendResult get(String path, Map<String,String> arguments, Map<String,String> headerMap, StackMobRawCallback callback)
          do a get request on the StackMob platform
 StackMobRequestSendResult get(String path, Map<String,String> arguments, StackMobRawCallback callback)
          do a get request on the StackMob platform
 StackMobRequestSendResult get(String path, StackMobRawCallback callback)
          do a get request on the StackMob platform
 StackMobRequestSendResult getAndClearExpiredPushTokens(StackMobRawCallback callback)
          get all expired push tokens for this app, and clear them after they've been returned
 StackMobRequestSendResult getExpiredPushTokens(StackMobRawCallback callback)
          get expired push tokens, but do not clear them after they've been returned
 StackMobRequestSendResult getFacebookUserInfo(StackMobRawCallback callback)
          get facebook user info for the current user.
 String getLoggedInUser()
           
static StackMobLogger getLogger()
           
 StackMobSession getSession()
          get the session that this StackMob object contains
static StackMob getStackMob()
           
 StackMobRequestSendResult getTokensForUsers(List<String> usernames, StackMobRawCallback callback)
          get all the tokens for the each of the given users
 StackMobRequestSendResult getTwitterUserInfo(StackMobRawCallback callback)
          get twitter user info for the current user.
protected static String getUserAgent(String appName)
           
static String getVersion()
           
 boolean isLoggedIn()
           
 boolean isLoggedOut()
           
 boolean isUserLoggedIn(String username)
           
 StackMobRequestSendResult linkUserWithFacebookToken(String token, StackMobRawCallback callback)
          link an existing StackMob user with a Facebook user
 StackMobRequestSendResult linkUserWithTwitterToken(String token, String secret, StackMobRawCallback callback)
          link an existing stackmob user with an existing twitter user
 StackMobRequestSendResult login(Map<String,String> params, StackMobRawCallback callback)
          call the login method on StackMob
 StackMobRequestSendResult logout(StackMobRawCallback callback)
          call the logout method on StackMob
 StackMobRequestSendResult post(String path, Object requestObject, StackMobRawCallback callback)
          do a post request on the StackMob platform for a single object
 StackMobRequestSendResult post(String path, String body, List<Map.Entry<String,String>> headers, StackMobRawCallback callback)
          do a post request on the StackMob platform for a single object
 StackMobRequestSendResult post(String path, String body, StackMobRawCallback callback)
          do a post request on the StackMob platform for a single object
<T> StackMobRequestSendResult
postBulk(String path, List<T> requestObjects, StackMobRawCallback callback)
          do a post request on the StackMob platform with a list of objects
 StackMobRequestSendResult postRelated(String path, String primaryId, String relatedField, Object relatedObject, StackMobRawCallback callback)
          post a new related object to an existing object.
<T> StackMobRequestSendResult
postRelatedBulk(String path, String primaryId, String relatedField, List<T> relatedObjects, StackMobRawCallback callback)
          post a list of new related objects to an existing object.
 StackMobRequestSendResult pushToTokens(Map<String,String> payload, List<StackMobPushToken> tokens, StackMobRawCallback callback)
          send a push notification to a group of tokens
 StackMobRequestSendResult pushToUsers(Map<String,String> payload, List<String> userIds, StackMobRawCallback callback)
          send a push notification to a group of users.
 StackMobRequestSendResult put(String path, String id, Object requestObject, StackMobRawCallback callback)
          do a put request on the StackMob platform
 StackMobRequestSendResult put(String path, String id, String body, StackMobRawCallback callback)
          do a put request on the StackMob platform
 StackMobRequestSendResult putAndUpdateAtomicCounters(String path, String id, Object requestObject, List<String> counterFields, StackMobRawCallback callback)
          do a put request on the StackMob platform, treating some of the fields as counters to be incremented rather than as values to set
<T> StackMobRequestSendResult
putRelated(String path, String primaryId, String relatedField, List<T> relatedIds, StackMobRawCallback callback)
          do a an atomic put request on the StackMob platform with the contents of the has-many relation
 StackMobRequestSendResult registerForPushWithUser(String username, String registrationID, boolean overwrite, StackMobRawCallback callback)
          register a user for C2DM push notifications
 StackMobRequestSendResult registerForPushWithUser(String username, String registrationID, StackMobRawCallback callback)
          register a user for C2DM push notifications
 StackMobRequestSendResult registerWithFacebookToken(String token, String username, StackMobRawCallback callback)
          create a new StackMob user and link that user with a facebook account
 StackMobRequestSendResult registerWithTwitterToken(String token, String secret, String username, StackMobRawCallback callback)
          create a new user on stackmob and associate it with an existing twitter user
 StackMobRequestSendResult removePushToken(String tokenString, StackMobPushToken.TokenType tokenType, StackMobRawCallback callback)
          remove a push token for this app
 StackMobRequestSendResult resetPassword(String oldPassword, String newPassword, StackMobRawCallback callback)
          reset the logged in user's password
static void setLogger(StackMobLogger logger)
           
 void setSession(StackMobSession session)
           
static void setStackMob(StackMob stackmob)
           
static void setUserAgentName(String name)
           
 StackMobRequestSendResult startSession(StackMobRawCallback callback)
          call the startsession method on StackMob
 StackMobRequestSendResult twitterLogin(String token, String secret, StackMobRawCallback callback)
          call the twitterlogin method on stackmob
 StackMobRequestSendResult twitterStatusUpdate(String message, StackMobRawCallback callback)
          call the twitterStatusUpdate method on StackMob
 StackMobRequestSendResult updateAtomicCounter(String path, String id, String field, int value, StackMobRawCallback callback)
          Do an atomic update on a an integer field in a particular object and schema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userRedirectedCallback

protected StackMobRedirectedCallback userRedirectedCallback

redirectedCallback

protected StackMobRedirectedCallback redirectedCallback
Constructor Detail

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                String appName,
                Integer apiVersionNumber)
create a new StackMob object. this is the preferred constructor

Parameters:
apiKey - the api key for your app
apiSecret - the api secret for your app
userObjectName - the name of your app's user object. if you do not have a user object, pass the empty strinrg here and do not use the login, logout, facebook or twitter methods, as they will fail
appName - the name of your application
apiVersionNumber - the version of your app's API that you want to use with this StackMob session. pass 0 for sandbox

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                Integer apiVersionNumber)
create a new StackMob object

Parameters:
apiKey - the api key for your app
apiSecret - the api secret for your app
userObjectName - the name of your app's user object. if you do not have a user object, pass the empty string here and do not use the login, logout, facebook or twitter methods, as they will fail
apiVersionNumber - the version of your app's API that you want to use with this StackMob session. pass 0 for sandbox

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                Integer apiVersionNumber,
                String urlFormat,
                StackMobRedirectedCallback redirectedCallback)
create a new StackMob object. use this constructor if you do your own caching of URLs for redirection

Parameters:
apiKey - the api key for your app
apiSecret - the api secret for your app
userObjectName - the name of your app's user object
apiVersionNumber - the version number of your app's API that you want to use with this object. pass 0 for sandbox
urlFormat - the format of URLs to use. for instance: api.mob1.stackmob.com
redirectedCallback - callback to be called if the StackMob platform issues a redirect. you should use this callback to cache the new URLs. here is a sample callback: new StackMobRedirectedCallback() { public void redirected(HttpRequest origRequest, HttpResponse response, HttpRequest newRequest) { try { URI uri = new URI(newRequest.getRequestLine().getUri()); cache(uri.getHost); } catch (URISyntaxException e) { handleException(e); } } } } note that this callback may be called in a background thread

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                Integer apiVersionNumber,
                String apiUrlFormat,
                String pushUrlFormat,
                StackMobRedirectedCallback redirectedCallback)

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                String appName,
                Integer apiVersionNumber,
                String apiUrlFormat,
                String pushUrlFormat,
                StackMobRedirectedCallback redirectedCallback)

StackMob

public StackMob(StackMob other)
Method Detail

getVersion

public static String getVersion()

getUserAgent

protected static String getUserAgent(String appName)

setUserAgentName

public static void setUserAgentName(String name)

setLogger

public static void setLogger(StackMobLogger logger)

getLogger

public static StackMobLogger getLogger()

getStackMob

public static StackMob getStackMob()

setStackMob

public static void setStackMob(StackMob stackmob)

login

public StackMobRequestSendResult login(Map<String,String> params,
                                       StackMobRawCallback callback)
call the login method on StackMob

Parameters:
params - parameters to pass to the login method
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

logout

public StackMobRequestSendResult logout(StackMobRawCallback callback)
call the logout method on StackMob

Parameters:
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

startSession

public StackMobRequestSendResult startSession(StackMobRawCallback callback)
call the startsession method on StackMob

Parameters:
callback - callback to call when the method completes
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

twitterLogin

public StackMobRequestSendResult twitterLogin(String token,
                                              String secret,
                                              StackMobRawCallback callback)
call the twitterlogin method on stackmob

Parameters:
token - the twitter session key (this is a per user key - different from the consumer key)
secret - the twitter session secret (this is a per user secret - different from the consumer secret)
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

twitterStatusUpdate

public StackMobRequestSendResult twitterStatusUpdate(String message,
                                                     StackMobRawCallback callback)
call the twitterStatusUpdate method on StackMob

Parameters:
message - the message to send. must be <= 140 characters
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

registerWithTwitterToken

public StackMobRequestSendResult registerWithTwitterToken(String token,
                                                          String secret,
                                                          String username,
                                                          StackMobRawCallback callback)
create a new user on stackmob and associate it with an existing twitter user

Parameters:
token - the twitter session key (this is a per user key - different from the consumer key)
secret - the twitter session secret (this is a per user secret - different from the consumer secret)
username - the username that the user should have
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

linkUserWithTwitterToken

public StackMobRequestSendResult linkUserWithTwitterToken(String token,
                                                          String secret,
                                                          StackMobRawCallback callback)
link an existing stackmob user with an existing twitter user

Parameters:
token - the twitter session key (this is a per user key - different from the consumer key)
secret - the twitter session secret (this is a per user secret - different from the consumer secret)
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

facebookLogin

public StackMobRequestSendResult facebookLogin(String token,
                                               StackMobRawCallback callback)
login into facebook on the StackMob platform

Parameters:
token - the facebook user token
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

registerWithFacebookToken

public StackMobRequestSendResult registerWithFacebookToken(String token,
                                                           String username,
                                                           StackMobRawCallback callback)
create a new StackMob user and link that user with a facebook account

Parameters:
token - the facebook user token
username - the StackMob username that the new user should have
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

linkUserWithFacebookToken

public StackMobRequestSendResult linkUserWithFacebookToken(String token,
                                                           StackMobRawCallback callback)
link an existing StackMob user with a Facebook user

Parameters:
token - the Facebook user token
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

facebookPostMessage

public StackMobRequestSendResult facebookPostMessage(String msg,
                                                     StackMobRawCallback callback)
post a message to facebook. this method will not post to FB and will return nothing if there is no user logged into FB

Parameters:
msg - the message to post
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

getFacebookUserInfo

public StackMobRequestSendResult getFacebookUserInfo(StackMobRawCallback callback)
get facebook user info for the current user. this method will return nothing if there is no currently logged in FB user

Parameters:
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

getTwitterUserInfo

public StackMobRequestSendResult getTwitterUserInfo(StackMobRawCallback callback)
get twitter user info for the current user. this method will return nothing if there is no currently logged in twitter user

Parameters:
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

pushToTokens

public StackMobRequestSendResult pushToTokens(Map<String,String> payload,
                                              List<StackMobPushToken> tokens,
                                              StackMobRawCallback callback)
send a push notification to a group of tokens

Parameters:
payload - the payload of the push notification to send
tokens - the tokens to which to send
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

pushToUsers

public StackMobRequestSendResult pushToUsers(Map<String,String> payload,
                                             List<String> userIds,
                                             StackMobRawCallback callback)
send a push notification to a group of users.

Parameters:
payload - the payload to send
userIds - the IDs of the users to which to send
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

registerForPushWithUser

public StackMobRequestSendResult registerForPushWithUser(String username,
                                                         String registrationID,
                                                         StackMobRawCallback callback)
register a user for C2DM push notifications

Parameters:
username - the StackMob username to register
registrationID - the C2DM registration ID. see http://code.google.com/android/c2dm/#registering for detail on how to get this ID
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

registerForPushWithUser

public StackMobRequestSendResult registerForPushWithUser(String username,
                                                         String registrationID,
                                                         boolean overwrite,
                                                         StackMobRawCallback callback)
register a user for C2DM push notifications

Parameters:
username - the StackMob username to register
registrationID - the C2DM registration ID. see http://code.google.com/android/c2dm/#registering for detail on how to get this ID
overwrite - whether to overwrite existing entries
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

getTokensForUsers

public StackMobRequestSendResult getTokensForUsers(List<String> usernames,
                                                   StackMobRawCallback callback)
get all the tokens for the each of the given users

Parameters:
usernames - the users whose tokens to get
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

broadcastPushNotification

public StackMobRequestSendResult broadcastPushNotification(Map<String,String> payload,
                                                           StackMobRawCallback callback)
broadcast a push notification to all users of this app. use this method sparingly, especially if you have a large app

Parameters:
payload - the payload to broadcast
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

getAndClearExpiredPushTokens

public StackMobRequestSendResult getAndClearExpiredPushTokens(StackMobRawCallback callback)
get all expired push tokens for this app, and clear them after they've been returned

Parameters:
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

getExpiredPushTokens

public StackMobRequestSendResult getExpiredPushTokens(StackMobRawCallback callback)
get expired push tokens, but do not clear them after they've been returned

Parameters:
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

removePushToken

public StackMobRequestSendResult removePushToken(String tokenString,
                                                 StackMobPushToken.TokenType tokenType,
                                                 StackMobRawCallback callback)
remove a push token for this app

Parameters:
tokenString - the token value
tokenType - the type of the token
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

get

public StackMobRequestSendResult get(String path,
                                     StackMobRawCallback callback)
do a get request on the StackMob platform

Parameters:
path - the path to get
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

get

public StackMobRequestSendResult get(String path,
                                     Map<String,String> arguments,
                                     Map<String,String> headerMap,
                                     StackMobRawCallback callback)
do a get request on the StackMob platform

Parameters:
path - the path to get
arguments - arguments to be encoded into the query string of the get request
headerMap - any additional headers to send
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

get

public StackMobRequestSendResult get(String path,
                                     Map<String,String> arguments,
                                     List<Map.Entry<String,String>> headers,
                                     StackMobRawCallback callback)
do a get request on the StackMob platform

Parameters:
path - the path to get
arguments - arguments to be encoded into the query string of the get request
headers - any additional headers to send
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

get

public StackMobRequestSendResult get(String path,
                                     Map<String,String> arguments,
                                     StackMobRawCallback callback)
do a get request on the StackMob platform

Parameters:
path - the path to get
arguments - the arguments to be encoded into the query string of the get request
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

get

public StackMobRequestSendResult get(StackMobQuery query,
                                     StackMobRawCallback callback)
do a get request on the StackMob platform

Parameters:
query - the query to run
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

get

public StackMobRequestSendResult get(StackMobQueryWithField query,
                                     StackMobRawCallback callback)
do a get request on the StackMob platform

Parameters:
query - the query to run
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

post

public StackMobRequestSendResult post(String path,
                                      Object requestObject,
                                      StackMobRawCallback callback)
do a post request on the StackMob platform for a single object

Parameters:
path - the path to get
requestObject - the object to serialize and send in the POST body. this object will be serialized with Gson
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

post

public StackMobRequestSendResult post(String path,
                                      String body,
                                      StackMobRawCallback callback)
do a post request on the StackMob platform for a single object

Parameters:
path - the path to get
body - the json body
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

post

public StackMobRequestSendResult post(String path,
                                      String body,
                                      List<Map.Entry<String,String>> headers,
                                      StackMobRawCallback callback)
do a post request on the StackMob platform for a single object

Parameters:
path - the path to get
body - the json body
headers - any additional headers to send
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

postBulk

public <T> StackMobRequestSendResult postBulk(String path,
                                              List<T> requestObjects,
                                              StackMobRawCallback callback)
do a post request on the StackMob platform with a list of objects

Parameters:
path - the path to get
requestObjects - List of objects to serialize and send in the POST body. the list will be serialized with Gson
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

postRelated

public StackMobRequestSendResult postRelated(String path,
                                             String primaryId,
                                             String relatedField,
                                             Object relatedObject,
                                             StackMobRawCallback callback)
post a new related object to an existing object. the relation of the root object is updated

Parameters:
path - the path to get
primaryId - id of the object with the relation
relatedField - name of the relation
relatedObject - related object to post
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

postRelatedBulk

public <T> StackMobRequestSendResult postRelatedBulk(String path,
                                                     String primaryId,
                                                     String relatedField,
                                                     List<T> relatedObjects,
                                                     StackMobRawCallback callback)
post a list of new related objects to an existing object. the relation of the root object is updated

Parameters:
path - the path to get
primaryId - id of the object with the relation
relatedField - name of the relation
relatedObjects - list of related objects to post. the list will be serialized with Gson
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

put

public StackMobRequestSendResult put(String path,
                                     String id,
                                     Object requestObject,
                                     StackMobRawCallback callback)
do a put request on the StackMob platform

Parameters:
path - the path to put
id - the id of the object to put
requestObject - the object to serialize and send in the PUT body. this object will be serialized with Gson
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

put

public StackMobRequestSendResult put(String path,
                                     String id,
                                     String body,
                                     StackMobRawCallback callback)
do a put request on the StackMob platform

Parameters:
path - the path to put
id - the id of the object to put
body - the json body
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

putAndUpdateAtomicCounters

public StackMobRequestSendResult putAndUpdateAtomicCounters(String path,
                                                            String id,
                                                            Object requestObject,
                                                            List<String> counterFields,
                                                            StackMobRawCallback callback)
do a put request on the StackMob platform, treating some of the fields as counters to be incremented rather than as values to set

Parameters:
path - the path to put
id - the id of the object to put
requestObject - the object to serialize and send in the PUT body. this object will be serialized with Gson
counterFields - a list of the fields in the object to be treated as counters being incremented
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

updateAtomicCounter

public StackMobRequestSendResult updateAtomicCounter(String path,
                                                     String id,
                                                     String field,
                                                     int value,
                                                     StackMobRawCallback callback)
Do an atomic update on a an integer field in a particular object and schema

Parameters:
path - the path to put
id - the id of the object to put
field - the field to increment
value - the value to increment by
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

putRelated

public <T> StackMobRequestSendResult putRelated(String path,
                                                String primaryId,
                                                String relatedField,
                                                List<T> relatedIds,
                                                StackMobRawCallback callback)
do a an atomic put request on the StackMob platform with the contents of the has-many relation

Parameters:
path - the path to get
primaryId - id of the object with the relation
relatedField - name of the relation
relatedIds - list of ids to atomically add to the relation. The type should be the same type as the primary key field of the related object
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

delete

public StackMobRequestSendResult delete(String path,
                                        String id,
                                        StackMobRawCallback callback)
do a delete request to the stackmob platform

Parameters:
path - the path to delete
id - the id of the object to put
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

deleteIdsFrom

public <T> StackMobRequestSendResult deleteIdsFrom(String path,
                                                   String primaryId,
                                                   String field,
                                                   List<T> idsToDelete,
                                                   boolean cascadeDeletes,
                                                   StackMobRawCallback callback)
atomically remove elements from an array or has many relationship

Parameters:
path - the path to get
primaryId - id of the object with the relation
field - name of the relation or array field to delete from
idsToDelete - list of ids to atomically remove from field. ids should be same type as the primary id of the related type (most likely String or Integer)
cascadeDeletes - true if related objects specified in idsToDelete should also be deleted
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

deleteIdFrom

public <T> StackMobRequestSendResult deleteIdFrom(String path,
                                                  String primaryId,
                                                  String field,
                                                  T idToDelete,
                                                  boolean cascadeDelete,
                                                  StackMobRawCallback callback)
atomically remove elements from an array or has many relationship

Parameters:
path - the path to get
primaryId - id of the object with the relation
field - name of the relation or array field to delete from
idToDelete - id to atomically remove from field. should be same type as the primary id of the related type (most likely String or Integer)
cascadeDelete - true if related object specified in idToDelete should also be deleted
callback - callback to be called when the server returns. may execute in a separate thread

count

public StackMobRequestSendResult count(String path,
                                       StackMobRawCallback callback)
retrieve the number of objects for a schema on the StackMob platform

Parameters:
path - the path to get
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

count

public StackMobRequestSendResult count(StackMobQuery query,
                                       StackMobRawCallback callback)
retrieve the number of objects for a query on the StackMob platform

Parameters:
query - the query to send
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

forgotPassword

public StackMobRequestSendResult forgotPassword(String username,
                                                StackMobRawCallback callback)
send out a password reset email to a user who's forgotten their password

Parameters:
username - the user who's forgotten their password
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

resetPassword

public StackMobRequestSendResult resetPassword(String oldPassword,
                                               String newPassword,
                                               StackMobRawCallback callback)
reset the logged in user's password

Parameters:
oldPassword - the old temporary password
newPassword - the new password that the user just created
callback - callback to be called when the server returns. may execute in a separate thread
Returns:
a StackMobRequestSendResult representing what happened when the SDK tried to do the request. contains no information about the response - that will be passed to the callback when the response comes back

getLoggedInUser

public String getLoggedInUser()

isLoggedIn

public boolean isLoggedIn()

isUserLoggedIn

public boolean isUserLoggedIn(String username)

isLoggedOut

public boolean isLoggedOut()

getSession

public StackMobSession getSession()
get the session that this StackMob object contains

Returns:
the session

setSession

public void setSession(StackMobSession session)


Copyright © 2012 StackMob. All Rights Reserved.