Class: Coco

Coco

Class which provides primary functions of COCO client sdk

Methods

(static) api(req) → {Promise}

Configures and makes the required Http call by attaching the COCO access token.
Parameters:
Name Type Description
req Object Request object provided as input by the client
Properties
Name Type Description
url String request url
method String request method
headers Object request headers
responseType String response type
Returns:
- Promise containing XMLHttpRequest with either data or error
Type
Promise

(static) getAccessToken() → {Promise}

Get COCO access token of the user logged in
Returns:
Type
Promise

(static) init(config, expiringCallback, expiredCallback) → {Promise}

Create config using input from client and predefined static values configured from our end
Parameters:
Name Type Description
config Object Configuration object provided as input by the client
Properties
Name Type Description
client_id String Client Id of the application
redirect_uri String redirect url of the application
access_token_expiring_notification_time Number The number of seconds before an access token is to expire to send the expiring notification
expiringCallback function callback function called before 5 mins of token expiry
expiredCallback function callback function called when access token is expired
Returns:
Type
Promise

(static) isLoggedIn() → {Promise}

Check presence of valid access token to assess logged in status.
Returns:
Boolean result true for logged in and false otherwise.
Type
Promise

(static) login() → {Promise}

Start login by sending authorization request to our authorization server.
Returns:
Type
Promise

(static) logout() → {Promise}

Logout the user by removing the access token
Returns:
Type
Promise