McDewey

Multi-vendor documentation library · semantic search · MCP endpoint at /mcp

Page 471

↗ View in doc context
page
471
source
finesse/v12.5/developer-guide/developer-guide.md
chunk_id
finesse::v12.5::developer-guide::developer-guide::455

• Update the state of the User using the setState() provided by finesse.restservices.User. Example—Update State of a User _user.setState('READY'); The above example triggers a state change for the User, which is equivalent to make a PUT request, which in turn triggers the onChange handler attached to the User object. All the handlers (GET, PUT, POST, DELETE, ERROR) can be attached to the object during initialization. Initialization of a JavaScript object triggers a GET request, the response of which is used to populate the JavaScript object. There are APIs available within the JavaScript object to create, update, and delete certain compositions (in the JavaScript object itself) that internally trigger PUT, POST, and DELETE REST API request respectively. To put this into perspective, the Finesse JavaScript REST API objects try to encapsulate the low-level request or response handling at the client-side and provide with APIs which are easy to use, maintain and improve the readability of the code. Subscription Support Finesse JavaScript objects support subscription to the XMPP events. These events are the notifications generated by the Openfire server and pushed to the desktop as XMPP events. Any JavaScript object that supports subscription is automatically hooked up for listening to XMPP events when it is initialized. This subscription is not a Notification subscription but a desktop level subscription to receive the events generated by the OpenAjax hub. Note For example, the User API supports the subscription model and the User functions as stated in the below example. Example for User Functions var _user = new finesse.restservices.User({ id: '1001001', onLoad: function(user){ // Do something on the successful fetch(GET) of user object }, onChange: function(user){ // Do something on the successful update(PUT) of object // can do user.getState() or user.getTeamName() }, onAdd: function(user){}, onDelete: function(user){}, onError: function(err){ // Something went wrong while fetching user data, show an error dialog to the user may be. } }); These handlers can handle the REST response and the XMPP events. For example, when the state change for a signed-in User is triggered by another agent (that is, Supervisor), the client or desktop receives a User update XMPP event on the node “/finesse/api/User/1001001”. Payload with Updated User State Details Cisco Finesse Web Services Developer and JavaScript Guide, Release 12.5(1) 455 Cisco Finesse JavaScript APIs Subscription Support