Namespace: ClearBlade

ClearBlade

This is the base module for the ClearBlade Platform API
Source:

Example

Initialize ClearBladeAPI

initOptions = {systemKey: 'asdfknafikjasd3853n34kj2vc', systemSecret: 'SHHG245F6GH7SDFG823HGSDFG9'};
var cb = new ClearBlade();
cb.init(initOptions);

Classes

Analytics
Code
Collection
Item
Messaging
MessagingStats
Query
User

Methods

(static) getEdges(callback)

Gets an array of Edges on the system.
Parameters:
Name Type Description
callback function A function like `function (err, data) {}` to handle the response
Source:

(static) init(options)

This method initializes the ClearBlade module with the values needed to connect to the platform
Parameters:
Name Type Description
options Object This value contains the config object for initializing the ClearBlade module. A number of reasonable defaults are set for the option if none are set.

The connect options and their defaults are:

{String} [systemKey] This is the app key that will identify your app in order to connect to the Platform

{String} [systemSecret] This is the app secret that will be used in combination with the systemKey to authenticate your app

{String} [URI] This is the URI used to identify where the Platform is located. Default is https://platform.clearblade.com

{String} [messagingURI] This is the URI used to identify where the Messaging server is located. Default is platform.clearblade.com

n *

{Number} [messagingPort] This is the default port used when connecting to the messaging server. Default is 8904

{Boolean} [logging] This is the property that tells the API whether or not the API will log to the console. This should be left `false` in production. Default is false

{Number} [callTimeout] This is the amount of time that the API will use to determine a timeout. Default is 30 seconds

{Boolean} [mqttAuth] Setting this to true and providing an email and password will use mqtt websockets to authenticate, rather than http.

{String} [messagingAuthPort] is the port that the messaging auth websocket server is listening on.

Source:

(static) isCurrentUserAuthenticated(callback)

Method to check if the current user has an active server session
Parameters:
Name Type Description
callback function
Source:
Example
cb.isCurrentUserAuthenticated(function(err, body) {
   if(err) {
     //handle error
   } else {
     //check authentication boolean
   }
})

(static) loginAnon(callback)

Method to create an anonymous session with the ClearBlade Platform
Parameters:
Name Type Description
callback function
Source:
Example
cb.loginAnon(function(err, body) {
   if(err) {
       //handle error
   } else {
       //do post login stuff
   }
})

(static) loginUserMqtt(email, password, callback)

Method to log user or developer in via MQTT over websockets
Parameters:
Name Type Description
email String
password String
callback function
Source:
Example
cb.loginUserMqtt("foo@bar.baz","secret_password", function(err, body) {
   if(err) {
       //handle error
   } else {
       //do post login stuff
   }
})

(static) logoutUser(callback)

Method to end the server session for the current user
Parameters:
Name Type Description
callback function
Source:
Example
cb.logoutUser(function(err, body) {
   if(err) {
       //handle error
   } else {
       //do post logout stuff
   }
})

(static) registerUser(email, password, callback)

Method to register a user with the ClearBlade Platform
Parameters:
Name Type Description
email String the users email
password String the password for the user
callback function returns a Boolean error value and a response as parameters
Source:
Example

Register User

cb.registerUser("newUser@domain.com", "qwerty", function(err, body) {
   if(err) {
     //handle error
   } else {
     console.log(body);
   }
});

(static) sendPush(users, payload, appId, callback)

Sends a push notification
Parameters:
Name Type Description
users Array The list of users to which the message will be sent
payload Object An object with the keys 'alert', 'badge', 'sound'
appId string A string with appId that identifies the app to send to
callback function A function like `function (err, data) {}` to handle the response
Source:

(static) setUser(email, authToken)

Used when assuming the role of a user to make subsequent requests
Parameters:
Name Type Description
email String the email of the user
authToken String the authToken for the user
Source: