Ajax api managing the chat on the yalst server
Created on 22.09.2014 for the yalst-trunk project.
Created on 22.09.2014 for the yalst-trunk project.
Members
(static) enterStartForm :function|*
Reports the visitor entering the welcoming form page
Type:
- function | *
(static) isConfiguredPromise :Promise
A promise which if resolved indicates that the api is ready to use by third-party custom JavaScript
Type:
(static) leaveStartForm :function|*
Reports the visitor leaving the welcoming form page
Type:
- function | *
(static) leaveStartFormBlocking :function|*
Reports the visitor leaving the welcoming form page.
This call is a blocking (SJAX) network request!
This call is a blocking (SJAX) network request!
Type:
- function | *
Methods
(static) apiAjaxPromise(getParametersnon-null, postParametersopt, queryFragmentopt) → {Promise}
basic method to perform the ajax request to the Chat Api
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
getParameters |
Object | ||
postParameters |
Object |
<optional> |
|
queryFragment |
string |
<optional> |
key value pairs in HTML-form encoded format |
Returns:
- Type
- Promise
(static) configure(options)
Set up the live support server. This method is called before any other methods by the web application
and will resolve the
module:api.isConfiguredPromise
.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
(static) enter(pageId) → {Promise}
Reports the visitor entering a particular page or view
Parameters:
Name | Type | Description |
---|---|---|
pageId |
string |
Returns:
- Type
- Promise
(static) hello() → {Promise}
Query the availability of the live support service
Returns:
- Type
- Promise
Example
// loading the module
require(['api'], function(serverApi)
{
serverApi.isConfiguredPromise.then(function()
{
serverApi.hello().then(function(data)
{
switch (data.chat)
{
case "online":
console.log("Chat available");
break;
case "busy":
console.log("Agents are busy");
break;
case "offline":
console.log("Try again later");
break;
}
},
function(error)
{
console.error(error.message);
});
});
});
(static) leave(pageId) → {Promise}
Reports the visitor leaving a particular page or view
Parameters:
Name | Type | Description |
---|---|---|
pageId |
string |
Returns:
- Type
- Promise
(static) leaveBlocking(pageId) → {undefined}
Reports the visitor leaving a particular page or view.
This is done by a SJAX (blocking) network request. Therefore it is safe to call this method e.g. on pagehide
This is done by a SJAX (blocking) network request. Therefore it is safe to call this method e.g. on pagehide
Parameters:
Name | Type | Description |
---|---|---|
pageId |
string |
Returns:
- Type
- undefined
(static) start(options) → {Promise}
Request a chat with optionally with a department at the
configured live support service
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
- Type
- Promise
(static) startForm(departmentopt) → {Promise}
Retrieve the welcoming form for a particular department or the
live support service in general
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
department |
string |
<optional> |
Returns:
- Type
- Promise
Type Definitions
Api
Ajax api managing the chat on the yalst server
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
configure |
api.configure | Set up the live support server. |
apiAjaxPromise |
api.apiAjaxPromise | basic method to perform the ajax request to the Chat Api |
hello |
api.hello | Query the availability of the live support service |