Name
sn_cai.ApiCallbackHandler
Description
Abstract class for Api Callback handler to enforce signature
Script
/**
* <h3>Scope: This is ServiceNow Instance side class</h3>
* ApiCallbackHandler gets called when cloud access layer receives the response for the call it made.
* For each page received, the new instance of this object is created and callback will be provided,
* context information supplied while registering the callback shall be used to determine the context and perform relevant operation at the caller end.
*
* Interested parties shall extend this class and override the onResponseCallBack to receive the response
*
* @example
* //Extending this abstract class to create asynchrous respose receiver
* var DemoApiCallbackHandler = Class.create();
* DemoApiCallbackHandler.prototype = Object.extendsObject(ApiCallbackHandler, {
* initialize: function() {
* },
*
* onResponseCallback : function (requestId, page, contextStr) {
* gs.info("@@DemoApiCallbackHandler ::requestID=" + requestId + "::context=" + contextStr);
* /// caller will call its response mapping mechanism.
* gs.info("@@DemoApiCallbackHandler ::pageNumber=" + page.getPageNumber() + "::page=" + page.getResponse());
* },
*
* type: 'DemoApiCallbackHandler'
* });
*
*
* @class
* @alias ApiCallbackHandler
* @memberof sn_cloud_access_la
* @abstract
*/
var ApiCallbackHandler = Class.create();
ApiCallbackHandler.prototype = {
initialize: function() {
},
/**
* Method that gets called when each page is received on cloud access later
* @param {string} requestId requestId passed while invoking the api
* @param {number} pageNumber current page number
* @param {boolean} isFinal is final page
* @param {ResultPage} page page response, typically empty for final page
* @param {string} contextStr context string supplied when registering the callback
*/
onResponseCallback : function (requestId, page, contextStr) {
gs.info("ApiCallbackHandler ::requestID=" + requestId + "::context=" + contextStr);
throw "Callback handler shall override this method and provide their implementation";
},
type: 'ApiCallbackHandler'
};
Sys ID
ffefbd3953931010d53bddeeff7b1238