Skip to content

Commit e02dfcc

Browse files
Merging pull request #18164
* Create the "List Templates" action. * Update "List Templates" action with the correct URL. * Update for the "templateId" prop. * Add success message with $.export("$summary") * Add the "Delete Template" action. * Create the "List Documents" action. * Add the "Get Document" action. * Update the "Get Document" action. * Add the "Update Document" action. * Add the "Delete Document" action. * Add "Generate Document" action. * Add "Generate Document" action. * Add optional fields. * Update output format options. * Update summary message. * Set version: "1.0.0" for all actions. * Update package.json * Update README file. * Fix step numbering in README. * Running eslint --fix * Moving actions to individual folders * Adding docs links to descriptions * Fixing package version --------- Co-authored-by: Guilherme Falcão <[email protected]> Co-authored-by: GTFalcao <[email protected]>
1 parent 5ea38d5 commit e02dfcc

File tree

12 files changed

+371
-45
lines changed

12 files changed

+371
-45
lines changed

components/docugenerate/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,25 @@ The DocuGenerate API lets you automate document creation and management tasks wi
99
- **Automated Report Creation and Distribution**: Schedule a workflow to run weekly, gathering data from tools such as Google Sheets or a database. Use this data to create a tailored report via DocuGenerate and subsequently email the report to a list of stakeholders using an email service like SendGrid.
1010

1111
- **Dynamic Invoice Creation from E-Commerce Platforms**: When a new order is placed on an e-commerce platform (like Shopify), trigger a Pipedream workflow that creates an invoice through the DocuGenerate API. Then, archive the invoice in cloud storage like Google Drive and update the order status within the e-commerce platform.
12+
13+
# Getting Started
14+
15+
## Obtaining Your API Key
16+
17+
1. Sign up for a [DocuGenerate](https://www.docugenerate.com/) account
18+
2. Get your unique API Key from the Developers tab in the [Settings](https://app.docugenerate.com/settings/developers) page
19+
3. Copy the API Key for use in Pipedream
20+
21+
## Connecting to Pipedream
22+
23+
1. In your Pipedream workflow, add a DocuGenerate action
24+
2. When prompted for authentication, paste your API Key
25+
3. Test the connection by using the "List Templates" action
26+
27+
## Generating Your First Document
28+
29+
Use the "Generate Document" action with:
30+
- **Template**: Select from your available templates
31+
- **Data**: Provide JSON data matching your template merge tags (e.g., `{ "name": "John Doe" }`)
32+
- **Name**: Set a custom document name (optional)
33+
- **Format**: Choose your desired output format (optional)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-delete-document",
5+
name: "Delete Document",
6+
description: "Deletes a specific document. [See the documentation](https://api.docugenerate.com/#/Document/deleteDocument)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
documentId: {
12+
type: "string",
13+
label: "Document",
14+
description: "The ID of the document",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.deleteDocument($, this.documentId);
19+
20+
$.export("$summary", `Successfully deleted the document ${this.documentId}`);
21+
return response;
22+
},
23+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-delete-template",
5+
name: "Delete Template",
6+
description: "Deletes a specific template. [See the documentation](https://api.docugenerate.com/#/Template/deleteTemplate)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
templateId: {
12+
propDefinition: [
13+
app,
14+
"templateId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.deleteTemplate($, this.templateId);
20+
21+
$.export("$summary", `Successfully deleted the template ${this.templateId}`);
22+
return response;
23+
},
24+
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-generate-document",
5+
name: "Generate Document",
6+
description: "Generates a document from a template. [See the documentation](https://api.docugenerate.com/#/Document/generateDocument)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
templateId: {
12+
propDefinition: [
13+
app,
14+
"templateId",
15+
],
16+
},
17+
name: {
18+
type: "string",
19+
label: "Name",
20+
description: "Name of the generated document. Defaults to the template’s name.",
21+
optional: true,
22+
},
23+
format: {
24+
type: "string",
25+
label: "Format",
26+
description: "Output format of the generated document. Defaults to .docx.",
27+
optional: true,
28+
options: [
29+
{
30+
label: "PDF (.pdf)",
31+
value: ".pdf",
32+
},
33+
{
34+
label: "Microsoft Word (.docx)",
35+
value: ".docx",
36+
},
37+
{
38+
label: "Microsoft Word 2007 (.doc)",
39+
value: ".doc",
40+
},
41+
{
42+
label: "OpenDocument Format (.odt)",
43+
value: ".odt",
44+
},
45+
{
46+
label: "Plain Text (.txt)",
47+
value: ".txt",
48+
},
49+
{
50+
label: "PNG (.png)",
51+
value: ".png",
52+
},
53+
],
54+
},
55+
data: {
56+
type: "object",
57+
label: "Data",
58+
description: "Data that is used to generate the document.",
59+
},
60+
},
61+
async run({ $ }) {
62+
const body = {
63+
template_id: this.templateId,
64+
name: this.name,
65+
output_format: this.format,
66+
data: this.data,
67+
};
68+
69+
const response = await this.app.generateDocument($, body);
70+
71+
$.export("$summary", `Successfully generated the document ${response.id}`);
72+
return response;
73+
},
74+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-get-document",
5+
name: "Get Document",
6+
description: "Retrieves a specific document. [See the documentation](https://api.docugenerate.com/#/Document/getDocument)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
documentId: {
12+
type: "string",
13+
label: "Document",
14+
description: "The ID of the document",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.getDocument($, this.documentId);
19+
20+
$.export("$summary", `Successfully retrieved the document ${this.documentId}`);
21+
return response;
22+
},
23+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-get-template",
5+
name: "Get Template",
6+
description: "Retrieves a specific template. [See the documentation](https://api.docugenerate.com/#/Template/getTemplate)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
templateId: {
12+
propDefinition: [
13+
app,
14+
"templateId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.getTemplate($, this.templateId);
20+
21+
$.export("$summary", `Successfully retrieved the template ${this.templateId}`);
22+
return response;
23+
},
24+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-list-documents",
5+
name: "List Documents",
6+
description: "Retrieves a list of documents generated from a template. [See the documentation](https://api.docugenerate.com/#/Document/queryDocuments)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
templateId: {
12+
propDefinition: [
13+
app,
14+
"templateId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.listDocuments($, this.templateId);
20+
21+
$.export("$summary", `Successfully retrieved ${response?.length || 0} documents`);
22+
return response;
23+
},
24+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-list-templates",
5+
name: "List Templates",
6+
description: "Retrieves a list of all templates. [See the documentation](https://api.docugenerate.com/#/Template/queryTemplates)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
async run({ $ }) {
13+
const response = await this.app.listTemplates($);
14+
15+
$.export("$summary", `Successfully retrieved ${response?.length || 0} templates`);
16+
return response;
17+
},
18+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import app from "../../docugenerate.app.mjs";
2+
3+
export default {
4+
key: "docugenerate-update-document",
5+
name: "Update Document",
6+
description: "Updates a specific document. [See the documentation](https://api.docugenerate.com/#/Document/updateDocument)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
documentId: {
12+
type: "string",
13+
label: "Document",
14+
description: "The ID of the document",
15+
},
16+
name: {
17+
type: "string",
18+
label: "Name",
19+
description: "The new name for the document",
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.app.updateDocument($, this.documentId, {
24+
name: this.name,
25+
});
26+
27+
$.export("$summary", `Successfully updated the document ${this.documentId}`);
28+
return response;
29+
},
30+
};
Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,99 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "docugenerate",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
templateId: {
8+
type: "string",
9+
label: "Template",
10+
description: "The selected template",
11+
async options() {
12+
const response = await this.listTemplates();
13+
return response.map((template) => ({
14+
label: template.name,
15+
value: template.id,
16+
}));
17+
},
18+
},
19+
},
520
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
21+
getBaseUrl() {
22+
return "https://api.docugenerate.com/v1";
23+
},
24+
getHeaders() {
25+
return {
26+
"Authorization": `${this.$auth.api_key}`,
27+
"Content-Type": "application/json",
28+
};
29+
},
30+
async makeRequest({
31+
$ = this,
32+
method = "GET",
33+
path,
34+
...args
35+
}) {
36+
const config = {
37+
method,
38+
url: `${this.getBaseUrl()}${path}`,
39+
headers: this.getHeaders(),
40+
...args,
41+
};
42+
return axios($, config);
43+
},
44+
async listTemplates($ = this) {
45+
return this.makeRequest({
46+
$,
47+
path: "/template",
48+
});
49+
},
50+
async getTemplate($ = this, templateId) {
51+
return this.makeRequest({
52+
$,
53+
path: `/template/${templateId}`,
54+
});
55+
},
56+
async deleteTemplate($ = this, templateId) {
57+
return this.makeRequest({
58+
$,
59+
method: "DELETE",
60+
path: `/template/${templateId}`,
61+
});
62+
},
63+
async listDocuments($ = this, templateId) {
64+
return this.makeRequest({
65+
$,
66+
path: `/document?template_id=${templateId}`,
67+
});
68+
},
69+
async getDocument($ = this, documentId) {
70+
return this.makeRequest({
71+
$,
72+
path: `/document/${documentId}`,
73+
});
74+
},
75+
async updateDocument($ = this, documentId, body) {
76+
return this.makeRequest({
77+
$,
78+
method: "PUT",
79+
path: `/document/${documentId}`,
80+
data: body,
81+
});
82+
},
83+
async deleteDocument($ = this, documentId) {
84+
return this.makeRequest({
85+
$,
86+
method: "DELETE",
87+
path: `/document/${documentId}`,
88+
});
89+
},
90+
async generateDocument($ = this, body) {
91+
return this.makeRequest({
92+
$,
93+
method: "POST",
94+
path: "/document",
95+
data: body,
96+
});
997
},
1098
},
11-
};
99+
};

0 commit comments

Comments
 (0)