Zimlet JavaScript API Reference - ZmBatchCommand

Class ZmBatchCommand


This class represent a batch command, which is a collection of separate requests. Each command is a callback with a method, arguments, and (usually) an object on which to call the method. Normally, when the command is run, it creates a SOAP document or JSON object which it hands to the app controller's sendRequest() method. It may also pass a response callback and/or an error callback.

Instead of calling sendRequest(), the command should hand the batch command its SOAP document or JSON object, response callback, and error callback. The last argument that the command receives is a reference to the batch command; that's how it knows it's in batch mode.

After all commands have been added to the batch command, call its run() method. That will create a BatchRequest out of the individual commands' requests and send it to the server. Each subrequest gets an ID. When the BatchResponse comes back, it is broken into individual responses. If a response indicates success (it is a *Response), the corresponding response callback is called with the result. If the response is a fault, the corresponding error callback is called with the exception.

A command does not have to be the method that generates a SOAP document or JSON object. It can be higher-level. Just make sure that the reference to the batch command gets passed down to it.



Defined in: ZmBatchCommand.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ZmBatchCommand(continueOnError, accountName, useJson)
Creates an empty batch command.
Method Summary
Method Attributes Method Name and Description
 
add(cmd)
Adds a command to the list of commands to run as part of this batch request.
 
addNewRequestParams(request, respCallback, errorCallback)
Adds the given command parameters to the batch command, as part of a command's invocation.
 
addRequestParams(request, respCallback, errorCallback)
Adds the given command parameters to the batch command, as part of a command's invocation.
 
Checks if the command is sensitive.
 
run(callback, errorCallback, offlineCallback)
Runs the batch request.
 
setNoAuthToken(noAuthToken)
Sets the noAuthToken flag.
 
setSensitive(sensitive)
Sets the sensitive flag.
 
size()
Gets the number of commands that are part of this batch request.
 
Returns a string representation of the object.
Class Detail
ZmBatchCommand(continueOnError, accountName, useJson)
Creates an empty batch command. Use the #add method to add commands to it, and #run to invoke it.
Author: Conrad Damon.
Parameters:
{Boolean} continueOnError
if true, the batch request continues processing when a subrequest fails (defaults to true)
{String} accountName
the account name to run this batch command as.
{Boolean} useJson
if true, send JSON rather than XML
Method Detail
add(cmd)
Adds a command to the list of commands to run as part of this batch request.
Parameters:
{AjxCallback} cmd
the command

addNewRequestParams(request, respCallback, errorCallback)
Adds the given command parameters to the batch command, as part of a command's invocation. Should be called without a previous #add command, when the request object can immediately generate its request object.
Parameters:
{AjxSoapDoc|object} request
a SOAP document or JSON object with the command's request
{AjxCallback} respCallback
the next callback in chain for async request
{AjxCallback} errorCallback
the callback to run if there is an exception
See:
#add

addRequestParams(request, respCallback, errorCallback)
Adds the given command parameters to the batch command, as part of a command's invocation. Should be called by a function that was added via #add earlier; that function should pass the request object.
Parameters:
{AjxSoapDoc|Object} request
a SOAP document or JSON object with the command's request
{AjxCallback} respCallback
the next callback in chain for async request
{AjxCallback} errorCallback
the callback to run if there is an exception
See:
#add

{Boolean} isSensitive()
Checks if the command is sensitive.
Returns:
{Boolean} true if the command is sensitive

run(callback, errorCallback, offlineCallback)
Runs the batch request. For each individual request, either a response or an error callback will be called.
Parameters:
{AjxCallback} callback
the callback to run after entire batch request has completed
{AjxCallback} errorCallback
the error callback called if anything fails. The error callbacks arguments are all of the exceptions that occurred. Note: only the first exception is passed if this batch command's onError is set to stop.
offlineCallback

setNoAuthToken(noAuthToken)
Sets the noAuthToken flag.
Parameters:
{Boolean} noAuthToken
true to send command with noAuthToken

setSensitive(sensitive)
Sets the sensitive flag. This indicates that this batch command contains a request with sensitive data. Note: There is no way to unset this value for the batch command.
Parameters:
{Boolean} sensitive
true to set command as sensitive

{int} size()
Gets the number of commands that are part of this batch request.
Returns:
{int} the size

{String} toString()
Returns a string representation of the object.
Returns:
{String} a string representation of the object

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:30 GMT-0400 (EDT)