-
Notifications
You must be signed in to change notification settings - Fork 1
Template
github-actions edited this page Nov 30, 2023
·
6 revisions
Contains information about Templates and methods to make previews.
Name | Type | Description |
---|---|---|
id |
string |
The ID of the template. |
name |
string |
The name of the template. |
format |
string |
The format of the template. Can be POSTCARD_A5 , POSTCARD_A6 , POSTCARD_SQ14 or GREETINGCARD_SQ15
|
labels |
string[] |
The labels of the template. |
mergeVariables |
string[] |
The merge variables of the template. |
thumbnail |
string |
The thumbnail of the template in base64. |
apiVersion |
string |
The API version of the template. |
version |
number |
The version of the template. |
updatedAt |
Date |
The date and time the template was last updated. |
pages |
string[] | undefined
|
The pages of the template. Is undefined if the template is not loaded. |
Load the pages of the template.
Returns: Promise<void>
Example
await template.load();
console.log(template.pages);
Make a preview of the template.
Parameters
Name | Type | Description |
---|---|---|
mergeVariables |
object |
The merge variables to use in the preview. Is an object with the merge variable name as key. |
Returns: Promise<Preview>
Example
const previews = await template.preview({
name: "John Doe",
address: "Main Street 1",
});
Delete the template.
Returns: Promise<void>
Example
await template.delete();
Create a new template.
Parameters
Name | Type | Description |
---|---|---|
data.name |
string |
The name of the template. |
data.format |
string |
The format of the template. Can be POSTCARD_A5 , POSTCARD_A6 , POSTCARD_SQ14 or GREETINGCARD_SQ15
|
data.labels |
string[] | undefined
|
The labels of the template. |
data.pages |
string[] |
The pages of the template. |
Returns: Promise<Template>
Example
const template = await client.createTemplate({
name: "Example Template",
format: Format.POSTCARD_A5,
labels: ["example"],
pages: ["front", "back"],
});
Get all templates.
Parameters
Name | Type | Default | Description |
---|---|---|---|
options.limit |
number |
10 |
The maximum number of templates to return. |
options.page |
number |
1 |
The page of templates to return. |
options.sortBy |
sort |
updatedAt:DESC |
The field(s) to sort the templates by. Can be updatedAt
|
options.filter.name |
string | string[]
|
undefined |
The name(s) of the template(s) to filter by. |
options.filter.labels |
contains |
undefined |
The label(s) of the template(s) to filter by. |
options.filter.format |
string | string[]
|
undefined |
The format(s) of the template(s) to filter by. Can be POSTCARD_A5 , POSTCARD_A6 , POSTCARD_SQ14 or GREETINGCARD_SQ15
|
Returns: Promise<Template[]>
Example
const templates = await client.getTemplates({
limit: 20,
page: 1,
sortBy: "updatedAt:ASC",
filter: {
name: "Example Template",
labels: "example",
format: Format.POSTCARD_A5,
},
});
Get a template by its ID.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID of the template to get. |
Returns: Promise<Template>
Example
const template = await client.getTemplate("example-template-id");
Get the template of the order.
Returns: Promise<Template>
Example
const template = await order.getTemplate();