Parse Arduino Yun SDK  1
Parse Arduino Yun SDK
Public Member Functions | Friends
ParseClient Class Reference

Class responsible for Parse connection. More...

#include <ParseClient.h>

Public Member Functions

 ParseClient ()
 Constructor of ParseClient object.
 
void begin (const char *applicationId, const char *clientKey)
 Initialize the Parse client and user session. More...
 
void setInstallationId (const char *installationId)
 Set the installation object id for this client. More...
 
const char * getInstallationId ()
 Return the client installation id. More...
 
void setSessionToken (const char *sessionToken)
 Set the session token for the Parse client. More...
 
void clearSessionToken ()
 Clear the session token. More...
 
const char * getSessionToken ()
 Return the client session token. More...
 
ParseResponse sendRequest (const char *httpVerb, const char *httpPath, const char *requestBody, const char *urlParams)
 Directly call REST API in Parse. More...
 
ParseResponse sendRequest (const String &httpVerb, const String &httpPath, const String &requestBody, const String &urlParams)
 Directly call REST API in Parse. More...
 
bool startPushService ()
 Start the push notifications service. More...
 
void stopPushService ()
 Stop the push notifications service. More...
 
bool pushAvailable ()
 Check if there is any new push message. More...
 
ParsePush nextPush ()
 Get next push message. More...
 
void end ()
 Release resource.
 

Friends

class ParseResponse
 
class ParsePush
 

Detailed Description

Class responsible for Parse connection.

Member Function Documentation

ParseClient::begin ( const char *  applicationId,
const char *  clientKey 
)

Initialize the Parse client and user session.

This method only initializes the Parse client, used for subsequent API requests. It does not start the push service, and does not create or load the installation object for the client.

Parameters
applicationIdThe application id for the Parse application. (required)
clientKeyThe client API key for the Parse application. (required)
void ParseClient::clearSessionToken ( )

Clear the session token.

Same as setSessionToken(NULL);

const char * ParseClient::getInstallationId ( )

Return the client installation id.

Return the installation id for the client. If called before the installation id for the client was set, this method will NOT create a new installation object. The typical usage scenario is:

  1. Call begin().
  2. Call getInstallationId(). 3.a. If the result is not NULL, the SDK has a previous installation id, there's nothing else to do. Otherwise: 3.b.1. If the device has already an installation id, call setInstallationId(). 3.b.2. If the device doesn't have an installation id, the SDK will generate one the first time it needs it.
Returns
The instalaltion id.
const char * ParseClient::getSessionToken ( )

Return the client session token.

Return the session token for the client, or NULL if there isn't one.

Returns
The session token.
ParsePush ParseClient::nextPush ( )

Get next push message.

NOTE: use only when pushAvailable() is TRUE

Returns
a ParsePush instance which contains one or multiple push messages
bool ParseClient::pushAvailable ( )

Check if there is any new push message.

use only after startPushService()

Returns
true if there is a push message, false otherwise.
ParseResponse ParseClient::sendRequest ( const char *  httpVerb,
const char *  httpPath,
const char *  requestBody,
const char *  urlParams 
)

Directly call REST API in Parse.

Parameters
httpVerb- GET/DELETE/PUT/POST
httpPath- the endpoint of REST API e.g. /1/installations
requestBody- http request body in json format, leave it as "" for DELTE/GET requests
urlParams- leave it as "" unless to perform a Parse query, use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2
Returns
response of request NOTE: ParseObjectCreate, ParseObjectUpdate, ParseObjectDelete, ParseGETObject, ParseQuery, ParseCloudFunction, ParseTrackEvent can also be used for REST API call
ParseResponse ParseClient::sendRequest ( const String &  httpVerb,
const String &  httpPath,
const String &  requestBody,
const String &  urlParams 
)

Directly call REST API in Parse.

Parameters
httpVerb- GET/DELETE/PUT/POST
httpPath- the endpoint of REST API e.g. /1/installations
requestBody- http request body in json format, leave it as "" for DELTE/GET requests
urlParams- leave it as "" unless to perform a Parse query, use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2
Returns
response of request NOTE: ParseObjectCreate, ParseObjectUpdate, ParseObjectDelete, ParseGETObject, ParseQuery, ParseCloudFunction, ParseTrackEvent can also be used for REST API call
void ParseClient::setInstallationId ( const char *  installationId)

Set the installation object id for this client.

Set the installation object id for this client. If this is not called before making an API request or starting push service, the SDK will create a new installation object for the client.

Parameters
installationIdThe installation id to be used by the client.
void ParseClient::setSessionToken ( const char *  sessionToken)

Set the session token for the Parse client.

Parameters
sessionTokenThe new session token. All subsequent API calls will use this token for authentication and authorization. If this is NULL, the client will be unauthenticated.
int ParseClient::startPushService ( )

Start the push notifications service.

This method will start the push notification service and will listen for incoming push notifications. If the push service is already started, this will do nothing. To actually process incoming push notifications, it is still necessary to repeatedly call

// Process pushes here
...
}
Returns
false if the push can't be started or true if started successfully.
void ParseClient::stopPushService ( )

Stop the push notifications service.

This method will stop the push notification service. If the push service is not started, this will do nothing.


The documentation for this class was generated from the following files: