Class: Contract

Contract(apiKeyopt)

Contract API client. Manages contract templates and generates filled documents (PDF/DOCX/HTML) from templates and transaction data.

Constructor

new Contract(apiKeyopt)

Create a new Contract API client.
Parameters:
Name Type Attributes Default Description
apiKey string | null <optional>
null Your API key. If omitted, the `IDANALYZER_KEY` environment variable is used.
Source:

Extends

Methods

(async) createTemplate(nameopt, contentopt, orientationopt, timezoneopt, fontopt) → {Promise.<ApiResponse>}

Create new contract template
Parameters:
Name Type Attributes Default Description
name string <optional>
"" Template name.
content string <optional>
"" Template HTML content.
orientation string <optional>
"0" Page orientation: 0=Portrait(Default), 1=Landscape.
timezone string <optional>
"UTC" Template timezone.
font string <optional>
"Open Sans" Template font.
Source:
Throws:
If `name` or `content` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

(async) deleteTemplate(templateIdopt) → {Promise.<ApiResponse>}

Delete contract template
Parameters:
Name Type Attributes Default Description
templateId string <optional>
"" Template ID.
Source:
Throws:
If `templateId` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

(async) generate(templateIdopt, _formatopt, transactionIdopt, fillDataopt) → {Promise.<ApiResponse>}

Generate document using template and transaction data
Parameters:
Name Type Attributes Default Description
templateId string <optional>
'' Template ID.
_format string <optional>
'PDF' Output format: PDF, DOCX or HTML.
transactionId string <optional>
'' Fill the template with data from the specified transaction.
fillData Object.<string, *> | null <optional>
null Key-value pairs to autofill dynamic fields. Data from the user ID is used first in case of a conflict. For example, passing `{"myparameter":"abc"}` would fill `%{myparameter}` in the contract template with "abc".
Source:
Throws:
If `templateId` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

getApiKey(customKeyopt) → {string|null}

Resolve the API key, preferring the provided value and falling back to the `IDANALYZER_KEY` environment variable.
Parameters:
Name Type Attributes Default Description
customKey string | null <optional>
null Explicitly supplied API key.
Overrides:
Source:
Returns:
The resolved API key, or `null` if none is available.
Type
string | null

(async) getTemplate(templateIdopt) → {Promise.<ApiResponse>}

Get contract template
Parameters:
Name Type Attributes Default Description
templateId string <optional>
"" Template ID.
Source:
Throws:
If `templateId` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

(async) listTemplate(orderopt, limitopt, offsetopt, filterTemplateIdopt) → {Promise.<ApiResponse>}

Retrieve a list of contract templates
Parameters:
Name Type Attributes Default Description
order number <optional>
-1 Sort results by newest(-1) or oldest(1).
limit number <optional>
10 Number of items to be returned per call.
offset number <optional>
0 Start the list from a particular entry index.
filterTemplateId string <optional>
"" Filter result by template ID.
Source:
Throws:
If `order` is not 1 or -1, or `limit` is out of range.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>

setParam(key, value) → {void}

Set an API parameter and its value, this function allows you to set any API parameter without using the built-in functions
Parameters:
Name Type Description
key string Parameter key
value * Parameter value
Overrides:
Source:
Returns:
Type
void

throwApiException(swopt) → {void}

Whether an exception should be thrown if API response contains an error message
Parameters:
Name Type Attributes Default Description
sw boolean <optional>
false Set to `true` to throw an APIError when the API response contains an error, or `false` to return the raw error response instead.
Overrides:
Source:
Returns:
Type
void

(async) updateTemplate(templateIdopt, nameopt, contentopt, orientationopt, timezoneopt, fontopt) → {Promise.<ApiResponse>}

Update contract template
Parameters:
Name Type Attributes Default Description
templateId string <optional>
"" Template ID.
name string <optional>
"" Template name.
content string <optional>
"" Template HTML content.
orientation string <optional>
"0" Page orientation: 0=Portrait(Default), 1=Landscape.
timezone string <optional>
"UTC" Template timezone.
font string <optional>
"Open Sans" Template font.
Source:
Throws:
If `templateId`, `name`, or `content` is empty.
Type
InvalidArgumentException
Returns:
The parsed API response.
Type
Promise.<ApiResponse>