Methods
(async) ready(VivochaLoginOptionsopt) → {Promise|Promise}
This function, resolving the returned Promise, signals that the Vivocha Library is fully loaded, initialized and ready to be used. Until the returned promise is resolved, not other Vivocha function is safe to be used. Overrides VivochaCore.ready and extends it to allow the automatic login of an Agent. See VivochaAgent.login for more details on the login procedure.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VivochaLoginOptions |
VivochaLoginOptions |
<optional> |
Agent credentials or JSON Web Token. Properties
|
Returns:
-
The login request succeeds if the promise is resolved.
- Type
- Promise
-
- Type
- Promise
(async) login(VivochaLoginOptionsopt) → {Promise}
Creates a login session for an Agent. The function the be used in two different ways:
- Passing the Userid and the password of the agent to login;
- Using the credentials of an administrator acting on behalf of an Agent
Examples
vivocha.ready().then(function() {
// The API is ready
vivocha.login({jwt: 'TOKEN_HERE'}).then(function() {
// Agent session created, all systems go.
});
});
vivocha.ready().then(function() {
// The API is ready
vivocha.login({uid: 'agent', pwd: 'password'}).then(function() {
// Agent session created, all systems go.
});
});
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VivochaLoginOptions |
VivochaLoginOptions |
<optional> |
Agent credentials or JSON Web Token. Properties
|
Returns:
The login request succeeds if the promise is resolved.
- Type
- Promise
(async) logout() → {Promise}
Logs out the currently logged in Agent
Returns:
Resolved when the operation is successfully completed.
- Type
- Promise