Appearance
Template
Workflow and activity templates.
Endpoints
| Endpoint | Arguments | Returns |
|---|---|---|
v3.template.create | template: { description: string, global: boolean, processId?: string, configuration: any } | HailerResult |
v3.template.delete | templateId: string | boolean |
v3.template.get | templateId: string | unknown |
v3.template.list | processId?: string | any[] |
v3.template.preview | data: { activityId: string, templateId: string } | unknown |
v3.template.update | update: { templateId: string, description?: string, global?: boolean, processId?: string, configuration?: any } | boolean |
v3.template.create
Description
Create document template. Returns created template
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
description | string | no | Description what this template is doing |
global | boolean | yes | If global, allow all processes to use the template |
fileType | any | yes | Allowed filetypes: pdf, csv |
content | string | yes | Script to generate pdf, csv from |
ownerCids | ObjectId[] | no | NetworkIds for those who are allowed to edit template |
configuration | object | no | configuration. Configuration for template. This will be copied to process.documentTemplates |
processId | ObjectId | no | Process Id to which this template belongs |
cid | ObjectId | no | Network to which this template belongs |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.create', [
{
global: false, // If global, allow all processes to use the template
fileType: '...', // Allowed filetypes: pdf, csv
content: 'string', // Script to generate pdf, csv from
},
]);
console.log(result);Returns
HailerResult
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
v3.template.delete
Description
Delete document template. Returns true if OK
Parameters
Argument 1 (ObjectId, required): templateId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.delete', [
'507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
v3.template.get
Description
Get document template by id
Parameters
Argument 1 (ObjectId, required): templateId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.get', [
'507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);Returns
Undocumented
The return value is not described in the source yet.
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
v3.template.list
Description
List templates
Parameters
Argument 1 (ObjectId, optional): processId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.list', [
'507f1f77bcf86cd799439011', // ObjectId
]);
console.log(result);Returns
Array of any.
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
v3.template.preview
Description
Get preview data for document template by activityId
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
activityId | activityId | yes | Id of activity |
templateId | ObjectId | yes | Id of template |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.preview', [
{
activityId: '507f1f77bcf86cd799439011', // Id of activity
templateId: '507f1f77bcf86cd799439011', // Id of template
},
]);
console.log(result);Returns
Undocumented
The return value is not described in the source yet.
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
v3.template.update
Description
Update document template. Returns updated document template
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
templateId | ObjectId | yes | Id of template |
description | string | no | Description what this template is doing |
global | boolean | no | If global, allow all processes to use the template |
fileType | any | no | Allowed filetypes: pdf, csv |
content | string | no | Script to generate pdf, csv from |
ownerCids | ObjectId[] | no | NetworkIds for those who are allowed to edit template |
configuration | object | no | configuration. Configuration for template. This will be copied to process.documentTemplates |
processId | ObjectId | no | Process Id to which this template belongs |
cid | ObjectId | no | Network to which this template belongs |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('v3.template.update', [
{
templateId: '507f1f77bcf86cd799439011', // Id of template
},
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.