new ApplicationApi()
Application API contains methods and event to track application lifecycle and user activity, get/set application data and do UI actions (like show/hide error messages).
Methods
getConfig() → {Promise}
Retrieves application configuration. Application configuration must be requested in 'WORKING' state only.
applicationApi.subscribe({
loginStateChanged: (params) => {
if (params.state === 'WORKING') {
applicationApi.getConfig().then(config => {
console.debug('Application API got config: ' + JSON.stringify(config));
});
}
}
});
Returns:
- Type:
-
Promise
Promise object represents AppConfig[] In case of error Promise is rejected and ApplicationApiErrorStatus is returned.
hideErrorMessage(params) → {Promise}
Hide error message in adapter
applicationApi.hideErrorMessage({ msgText: 'Operation cannot be completed.' });
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise is resolved if operation succeeded. In case of error Promise is rejected and ApplicationApiErrorStatus is returned.
isFloatingOn() → {Promise}
Determines if the adapter has floating mode on
Returns:
- Type:
-
Promise
Promise object represents boolean value
showErrorMessage(params) → {Promise}
Show error message in adapter
applicationApi.showErrorMessage({ msgText: 'Operation cannot be completed.' });
You must pass the same message text to hide error message.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
object
|
|
Returns:
- Type:
-
Promise
Promise is resolved if operation succeeded. In case of error Promise is rejected and ApplicationApiErrorStatus is returned.
subscribe(apiEvents) → {void}
Subscribes to Application Api events.
const applicationApi = window.Five9.CrmSdk.applicationApi();
applicationApi.subscribe({
sessionInitialized: () => {},
loginStateChanged: (params) => {}
});
Parameters:
Name | Type | Description |
---|---|---|
apiEvents |
ApplicationApiEvents
|
Callbacks corresponding to the events will be called on object passed as parameter |
Returns:
- Type:
-
void