c2mAPIBatch Object

The c2mAPIBatch object encapsulates the basic functionality needed to execute batch mail jobs via the API. It maintains as object properties most of the key elements needed to access and manage a job.

Object Properties

Property

Type

Description

batchID

string

ID of the batch created with this instance

jobId

string

Unused

addressListId

string

ID of the address list associated with this batch

documentID

string

Unused

mode

string ("0" or "1")

"0" : run in staging / testing environment
"1" : run in production environment

username

string

Account user name

password

string

Account password

jobs

list of lists

List of lists of key : value pairs with information for each job. Each list is of the form:

{
"startPage":startPage,
"endPage":endPage,
"printOptions":printOptions,
"returnAddress":returnAddress,
"recipients":recipients
}

Object Methods

addJob() Method

This method adds a job to the batch by appending the job information to .jobs.

It does not return any value.

Parameter

Type

Description

startPage

string

Starting page

endPage

string

Ending page

printOptions

c2mAPI.printOptions

Object containing the list of print options for the job

returnAddress

c2mAPI.returnAddress

Object containing the return address for the job

recipients

list of lists

A list of lists containing the addresses for the job to be sent to. Each address list is of the form:

{'name':'name',
'organization':'organization',
'address1':'1235 test street',
'address2':'ste 1234',
'address3':'',
'city':'Oak Brook',
'state':'IL',
'postalCode':'60523',
'country':'US'}	

createBatch() Method

This method creates the batch to be processed and sets .batchID to the value of the batch ID created.

Returns the requests.Response() object resulting from the POST call to the /batches endpoint.


createBatchXML() Method

This method builds out the required XML needed to run the batch job.

Returns the constructed XML as a string.


getBatchStatus() Method

This method queries the system for the current status of .batchID.

Returns the requests.Response() object resulting from the GET call to the /batches endpoint.


getBatchUrl() Method

Returns the full URL for the Batch API based on the environment defined by .mode'. If .mode' = 0, it returns the staging URL, otherwise it returns the production URL.


runAll() Method

This method executes all the necessary methods to create a new batch, upload the PDF file, build and submit the configuration XML, and submit the batch.

On success, returns the requests.Response() object resulting from the GET call to the /batches endpoint (based on an internal call to getBatchStatus().

On a failure of any step, returns the requests.Response() object associated with the failed step.


sendPDF() Method

This method uploads the PDF file to be referenced in the batch job.

Returns the requests.Response() object resulting from the PUT call to the /batches endpoint.

Parameter

Type

Description

file

string

The pdf file to send


sendXML() Method

This method uploads the batch configuration XML for the .batchID batch.

Returns the requests.Response() object resulting from the PUT call to the /batches endpoint.

Parameter

Type

Description

xmlStr

string

The XML string to send


setFileName() Method

This method sets the properties .fileName and .filePath.

There is no return value

Parameter

Type

Description

fileName

string

The name of the file

filePath

string

The path to the file on the local filesystem


submitBatch() Method

This method submits batch .batchID for execution.

Returns the requests.Response() object resulting from the POST call to the /batches endpoint.