Skip to content

Commit e4d26ca

Browse files
committed
agrello init
1 parent 0acdb8b commit e4d26ca

File tree

8 files changed

+542
-6
lines changed

8 files changed

+542
-6
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import agrello from "../../agrello.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "agrello-create-document-from-template",
6+
name: "Create Document from Template",
7+
description: "Creates a new document in Agrello, invites participants, and fills file variables. [See the documentation](https://api.agrello.io/public/webjars/swagger-ui/index.html)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
agrello,
12+
folderId: {
13+
propDefinition: [
14+
agrello,
15+
"folderId",
16+
],
17+
},
18+
name: {
19+
type: "string",
20+
label: "Document Name",
21+
description: "The name of the document",
22+
},
23+
outputType: {
24+
type: "string",
25+
label: "Output Type",
26+
description: "The output type of the document",
27+
options: [
28+
"pdf",
29+
"asice",
30+
"zip",
31+
],
32+
},
33+
variables: {
34+
type: "object",
35+
label: "Variables",
36+
description: "The variables for the document",
37+
},
38+
signers: {
39+
type: "string[]",
40+
label: "Signers",
41+
description: "The signers of the document",
42+
},
43+
viewers: {
44+
type: "string[]",
45+
label: "Viewers",
46+
description: "The viewers of the document",
47+
},
48+
immediatePublish: {
49+
type: "boolean",
50+
label: "Immediate Publish",
51+
description: "Whether to publish the document immediately",
52+
},
53+
metadata: {
54+
type: "object",
55+
label: "Metadata",
56+
description: "The metadata for the document",
57+
},
58+
templateId: {
59+
propDefinition: [
60+
agrello,
61+
"templateId",
62+
],
63+
optional: true,
64+
},
65+
},
66+
async run({ $ }) {
67+
const data = {
68+
folderId: this.folderId,
69+
name: this.name,
70+
outputType: this.outputType,
71+
variables: this.variables,
72+
signers: this.signers,
73+
viewers: this.viewers,
74+
immediatePublish: this.immediatePublish,
75+
metadata: this.metadata,
76+
templateId: this.templateId,
77+
};
78+
79+
const response = await this.agrello.createDocument(data);
80+
$.export("$summary", `Successfully created document with ID ${response.id}`);
81+
return response;
82+
},
83+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import agrello from "../../agrello.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "agrello-get-document",
6+
name: "Get Document",
7+
description: "Get a document in Agrello. [See the documentation](https://api.agrello.io/public/webjars/swagger-ui/index.html)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
agrello,
12+
documentId: {
13+
propDefinition: [
14+
agrello,
15+
"documentId",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const response = await this.agrello.getDocument({
21+
documentId: this.documentId,
22+
});
23+
$.export("$summary", `Successfully retrieved document with ID ${this.documentId}`);
24+
return response;
25+
},
26+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import agrello from "../../agrello.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "agrello-upload-document",
6+
name: "Upload Document",
7+
description: "Uploads a document to Agrello. [See the documentation](https://api.agrello.io/public/webjars/swagger-ui/index.html)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
agrello,
12+
folderId: {
13+
propDefinition: [
14+
agrello,
15+
"folderId",
16+
],
17+
},
18+
file: {
19+
propDefinition: [
20+
agrello,
21+
"file",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.agrello.uploadDocument({
27+
folderId: this.folderId,
28+
file: this.file,
29+
});
30+
31+
$.export("$summary", `Successfully uploaded document to folder ID ${this.folderId}`);
32+
return response;
33+
},
34+
};

components/agrello/agrello.app.mjs

Lines changed: 178 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,184 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "agrello",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
folderId: {
8+
type: "string",
9+
label: "Folder ID",
10+
description: "The ID of the folder",
11+
async options() {
12+
const folders = await this.listFolders();
13+
return folders.map((folder) => ({
14+
label: folder.name,
15+
value: folder.id,
16+
}));
17+
},
18+
},
19+
documentId: {
20+
type: "string",
21+
label: "Document ID",
22+
description: "The ID of the document",
23+
async options() {
24+
const documents = await this.listDocuments();
25+
return documents.map((document) => ({
26+
label: document.name,
27+
value: document.id,
28+
}));
29+
},
30+
},
31+
templateId: {
32+
type: "string",
33+
label: "Template ID",
34+
description: "The ID of the template",
35+
optional: true,
36+
async options() {
37+
const templates = await this.listTemplates();
38+
return templates.map((template) => ({
39+
label: template.name,
40+
value: template.id,
41+
}));
42+
},
43+
},
44+
file: {
45+
type: "string",
46+
label: "File",
47+
description: "The file to upload",
48+
},
49+
name: {
50+
type: "string",
51+
label: "Document Name",
52+
description: "The name of the document",
53+
},
54+
outputType: {
55+
type: "string",
56+
label: "Output Type",
57+
description: "The output type of the document",
58+
options: [
59+
"pdf",
60+
"asice",
61+
"zip",
62+
],
63+
},
64+
variables: {
65+
type: "object",
66+
label: "Variables",
67+
description: "The variables for the document",
68+
},
69+
signers: {
70+
type: "string[]",
71+
label: "Signers",
72+
description: "The signers of the document",
73+
},
74+
viewers: {
75+
type: "string[]",
76+
label: "Viewers",
77+
description: "The viewers of the document",
78+
},
79+
immediatePublish: {
80+
type: "boolean",
81+
label: "Immediate Publish",
82+
description: "Whether to publish the document immediately",
83+
},
84+
metadata: {
85+
type: "object",
86+
label: "Metadata",
87+
description: "The metadata for the document",
88+
},
89+
},
590
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
91+
_baseUrl() {
92+
return "https://api.agrello.io";
93+
},
94+
async _makeRequest(opts = {}) {
95+
const {
96+
$ = this,
97+
method = "GET",
98+
path = "/",
99+
headers,
100+
...otherOpts
101+
} = opts;
102+
return axios($, {
103+
...otherOpts,
104+
method,
105+
url: this._baseUrl() + path,
106+
headers: {
107+
...headers,
108+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
109+
},
110+
});
111+
},
112+
async listFolders() {
113+
return this._makeRequest({
114+
path: "/v3/folders",
115+
});
116+
},
117+
async listDocuments() {
118+
return this._makeRequest({
119+
path: "/v3/documents",
120+
});
121+
},
122+
async listTemplates() {
123+
return this._makeRequest({
124+
path: "/v3/templates",
125+
});
126+
},
127+
async uploadDocument({
128+
folderId, file,
129+
}) {
130+
const formData = new FormData();
131+
formData.append("file", file);
132+
return this._makeRequest({
133+
method: "POST",
134+
path: `/folders/${folderId}/documents`,
135+
data: formData,
136+
headers: {
137+
"Content-Type": "multipart/form-data",
138+
},
139+
});
140+
},
141+
async getDocument({ documentId }) {
142+
return this._makeRequest({
143+
path: `/documents/${documentId}`,
144+
});
145+
},
146+
async createDocument({
147+
folderId,
148+
name,
149+
outputType,
150+
variables,
151+
signers,
152+
viewers,
153+
immediatePublish,
154+
metadata,
155+
templateId,
156+
}) {
157+
const data = {
158+
folderId,
159+
name,
160+
outputType,
161+
variables,
162+
signers,
163+
viewers,
164+
immediatePublish,
165+
metadata,
166+
templateId,
167+
};
168+
return this._makeRequest({
169+
method: "POST",
170+
path: "/documents",
171+
data,
172+
});
173+
},
174+
async emitDocumentSignatureAdded() {
175+
// Implementation to emit event when a signature is added to a document
176+
},
177+
async emitDocumentSigned() {
178+
// Implementation to emit event when a document is signed by all parties
179+
},
180+
async emitUserAddedDocumentToFolder({ folderId }) {
181+
// Implementation to emit event when a user adds a document to a specific folder
9182
},
10183
},
11-
};
184+
};

components/agrello/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)