Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Document From Template",
description: "Create a Document from a PandaDoc Template. [See the documentation here](https://developers.pandadoc.com/reference/create-document-from-pandadoc-template)",
type: "action",
version: "0.0.7",
version: "0.0.8",
props: {
app,
name: {
Expand Down Expand Up @@ -52,7 +52,12 @@ export default {
},
async additionalProps() {
const props = {};
const { fields } = await this.app.getTemplate({
if (!this.templateId) {
return props;
}
const {
fields, images,
} = await this.app.getTemplate({
templateId: this.templateId,
});
for (const field of fields) {
Expand All @@ -65,6 +70,15 @@ export default {
optional: true,
};
}
if (images?.length) {
for (const image of images) {
props[image.block_uuid] = {
type: "string",
label: `${image.name} URL`,
optional: true,
};
}
}
return props;
},
methods: {
Expand All @@ -91,7 +105,9 @@ export default {
} = this;

const fields = {};
const { fields: items } = await this.app.getTemplate({
const {
fields: items, images: templateImages,
} = await this.app.getTemplate({
templateId: this.templateId,
});
for (const field of items) {
Expand All @@ -103,6 +119,20 @@ export default {
};
}

const images = [];
if (templateImages?.length) {
for (const image of templateImages) {
if (this[image.block_uuid]) {
images.push({
name: image.name,
urls: [
this[image.block_uuid],
],
});
}
}
}

const response = await this.app.createDocument({
$,
data: {
Expand All @@ -113,6 +143,7 @@ export default {
recipients: this.parseToAnyArray(recipients),
tokens: this.parseToAnyArray(tokens),
fields,
images,
},
});

Expand Down
2 changes: 1 addition & 1 deletion components/pandadoc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/pandadoc",
"version": "1.0.1",
"version": "1.0.2",
"description": "Pipedream PandaDoc Components",
"main": "pandadoc.app.mjs",
"keywords": [
Expand Down
Loading