Class: ServerExtractor

ServerExtractor()

new ServerExtractor()

An instance of this class contains methods to extract the images and gets the results.

Methods

cancelExtraction(successCallback, errorCallback)

It will cancel the extraction process. If cancellation was not possible, the extractData successCallback is called with results and/or Exception. If cancellation was successful, the extractData successCallback listener is called with null results.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
successCallback - KMC_SUCCESS success call back errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
var constructorOptions = {serverType:"SERVER_KTA",serverUrl:"Enter server url"};
  var parameters = {
      imageIDs:[],
      params:{
          processIdentityName:"",
          sessionId:"",
          storeFolderAndDocuments:false
      }
  };
  var extractor = null;
  kfxCordova.kfxLibLogistics.createServerExtractor(function(serverExtractor){
      extractor = serverExtractor;

      extractor.extractData(function(result){
          alert(JSON.stringify(result));
      },function(error){
          alert(JSON.stringify(error));
      }, parameters);

      extractor.cancelExtraction(function(success){
          alert(JSON.stringify(success));
      },function(error){
          alert(JSON.stringify(error));
      });

  },function(error){
      alert(JSON.stringify(error));
  },constructorOptions);

clean(successCallback, errorCallback)

The method would clear server extractor memory
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error Call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - This library returns KMC_SUCCESS if server extractor memory cleared errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
var constructorOptions = {serverType:"SERVER_KTA",serverUrl:"Enter server url"};
  var extractor = null;
  kfxCordova.kfxLibLogistics.createServerExtractor(function(serverExtractor){
      extractor = serverExtractor;

      extractor.clean(function(result){
          alert(JSON.stringify(result));
      },function(error){
          alert(JSON.stringify(error));
      });

  },function(error){
      alert(JSON.stringify(error));
  },constructorOptions);

extractData(successCallback, errorCallback, parameters)

This method invokes extraction process.Before extraction, login() method needs to be called for KTA servers. ExtractData method would be expect valid documents (images) like MobileID , Checks and Bills. Documents can be sent in parameters as imageID array. Extract API internally uses Image Process for some operations like reading from file or writing an image to file buffer. During this time, the expectation is that ImageProcessor instance be not busy. If it is busy it throws back an error.
Parameters:
Name Type Description
successCallback function Callback consists of extraction results or cancel error with empty results.The extraction results needs to be parse in application.
errorCallback function Default Error call back function name
parameters Object parameters which are used to extract the fields. Parameters object contain appropriate x-parameters of the SMC projects i.e. MobileID, BillPay and CheckDeposit. Documentation will explicitly indicate developers to refer to the SMC documentation. Below are the mandatory parameters for serverExtractor.
Properties
Name Type Attributes Description
imageIDs Array <optional>
The extraction can be done with given imageIDs.
params Object <optional>
This parameters are depends on the server/requirement.For example below are the Parameters for KTA:
Properties
Name Type Attributes Default Description
processIdentityName String <optional>
KTA Process name(eg:Check,Bill,etc).
sessionId String <optional>
Get session Id from login successCallback and use it for extraction request.
storeFolderAndDocuments Boolean <optional>
false Store folder and documents after extraction complete. The default value is false.
See:
Returns:
successCallback : The return value is captured in the 'successCallback' function. This Callback consists of extraction results or cancel error with empty results. The extracted results are returned as a JSON string, so it needs to be parsed in Application. errorCallback : Several Server error codes are returned for this method when the extraction request could be started.
Example
var constructorOptions = {serverType:"SERVER_KTA",serverUrl:"Enter server url"};
  var parameters = {
      imageIDs:[],
      params:{
          processIdentityName:"",
          sessionId:"",
          storeFolderAndDocuments:false
      }
  };
  var extractor = null;
  kfxCordova.kfxLibLogistics.createServerExtractor(function(serverExtractor){
      extractor = serverExtractor;

      extractor.extractData(function(result){
          var data =  JSON.parse(result);
          alert(JSON.stringify(data));
      },function(error){
          alert(JSON.stringify(error));
      }, parameters);

  },function(error){
      alert(JSON.stringify(error));
  },constructorOptions);

getOptions(successCallback, errorCallback)

Method to get the options of the server extractor.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions. successCallback - The library returns the serverOptions. errorCallback - Error message would contain the appropriate error description. Possible error is KmcException,JSONException.
Example
var constructorOptions = {serverType:"SERVER_KTA",serverUrl:"Enter server url"};
  var extractor = null;
  kfxCordova.kfxLibLogistics.createServerExtractor(function(serverExtractor){
      extractor = serverExtractor;

      extractor.getOptions(function(result){
          alert(JSON.stringify(result));
      },function(error){
          alert(JSON.stringify(error));
      });

  },function(error){
      alert(JSON.stringify(error));
  },constructorOptions);

login(successCallback, errorCallback, parameters)

This method login to KTA server using given credentials and returns session id in success callback.Login is mandatory for KTA servers. This session ID is included in extraction parameters for further extraction process.Login is not supported for RTTI server.
Parameters:
Name Type Description
successCallback function CallBack consists of the session id for the given credentials.
errorCallback function Default Error call back function name.
parameters Object parameters which are used to login.
Properties
Name Type Attributes Description
username String <optional>
User name.
password String <optional>
User Password.
Returns:
successCallback - It will returns the session id. errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
var parameters = {username:"Enter user name",password:"Enter password"};
  var constructorOptions = {serverType:"SERVER_KTA",serverUrl:"Enter server url"};
  var extractor = null;
  kfxCordova.kfxLibLogistics.createServerExtractor(function(serverExtractor){
      extractor = serverExtractor;

      extractor.login(function(result){
          alert(JSON.stringify(result));
      },function(error){
          alert(JSON.stringify(error));
      }, parameters);

  },function(error){
      alert(JSON.stringify(error));
  },constructorOptions);

setOptions(successCallback, errorCallback, options)

Method to set the options of the server Extractor.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
options Object A JSON object contains the options of the server extractor.
Properties
Name Type Attributes Default Description
serverTimeout Number <optional>
20 timeout for the server extractor
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions. successCallback - The library returns KMC_SUCCESS. errorCallback - Error message would contain the appropriate error description. Possible error is KmcException,JSONException.
Example
var options={
    serverTimeout:20
  };
  var constructorOptions = {serverType:"SERVER_KTA",serverUrl:"Enter server url"};
  var extractor = null;
  kfxCordova.kfxLibLogistics.createServerExtractor(function(serverExtractor){
      extractor = serverExtractor;

      extractor.setOptions(function(result){
          alert(JSON.stringify(result));
      },function(error){
          alert(JSON.stringify(error));
      }, options);

  },function(error){
      alert(JSON.stringify(error));
  },constructorOptions);