McDewey

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

Page 470

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

success: function(response){ // here response is an xml containing all the relevant information regarding the User 1001001 which can be used // for example response can be <User><id>1001001</id><state>NOT_READY</state></User> // Need to parse the response and make it usable }, error: function(err){ // Something went wrong while fetching user data, show an error dialog to the user may be. }, }); • Make a PUT call to the server to change the state of this agent. Example—PUT $.ajax({ url: 'finesse/api/User/1001001' // where 1001001 is the username/id through which the agent logged in. type: 'PUT', data: '<User><state>READY</state></User>' success: function(response){ // Do something once the user state has been changed successfully. }, error: function(err){ // Something went wrong while fetching user data, show an error dialog to the user may be. }, }); REST operations such as POST and DELETE can also be performed on the User API to get the desired result. With Finesse JavaScript library In the presence of the Finesse JavaScript library, the following code would be needed to pull the User details, where the User object is under the namespace finesse.restservices.User. • Make a GET all on the User API. The GET call in the above example is made using the jQuery OpenAjax API, where the onLoad is equivalent to the success option of the jQuery OpenAjax call. Example—onLoad, onChange, and on Error 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() } onError: function(err){ // Something went wrong while fetching user data, show an error dialog to the user may be. } }); The onChange is equivalent to the success option in PUT jQuery OpenAjax call made to modify the state of the User in the second example. Similarly, there are other handlers such as onAdd used for POST request and onDelete used for DELETE requests which are supported by User object as well as other Finesse JavaScript objects. Cisco Finesse Web Services Developer and JavaScript Guide, Release 12.5(1) 454 Cisco Finesse JavaScript APIs JavaScript Library