Skip to content

Commit 2789621

Browse files
committed
flexisign init
1 parent 129369a commit 2789621

File tree

3 files changed

+105
-5
lines changed

3 files changed

+105
-5
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import flexisign from "../../flexisign.app.mjs";
2+
3+
export default {
4+
key: "flexisign-send-document-using-template",
5+
name: "Send Document Using Template",
6+
description: "Sends a signature request to the specified recipients for a document generated from a template. [See the documentation](https://flexisign.io/app/integrations/flexisignapi)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
flexisign,
11+
templateId: {
12+
propDefinition: [
13+
flexisign,
14+
"templateId",
15+
],
16+
},
17+
recipients: {
18+
propDefinition: [
19+
flexisign,
20+
"recipients",
21+
],
22+
},
23+
message: {
24+
propDefinition: [
25+
flexisign,
26+
"message",
27+
],
28+
optional: true,
29+
},
30+
},
31+
async run({ $ }) {
32+
const response = await this.flexisign.sendSignatureRequest({
33+
templateId: this.templateId,
34+
recipients: this.recipients,
35+
message: this.message,
36+
});
37+
38+
$.export("$summary", `Signature request sent for template ID: ${this.templateId}`);
39+
return response;
40+
},
41+
};
Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,70 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "flexisign",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
templateId: {
8+
type: "string",
9+
label: "Template ID",
10+
description: "The ID of the template to generate the document from",
11+
async options() {
12+
const templates = await this.listTemplates();
13+
return templates.map((template) => ({
14+
label: template.name,
15+
value: template.id,
16+
}));
17+
},
18+
},
19+
recipients: {
20+
type: "string[]",
21+
label: "Recipients",
22+
description: "An array of recipient objects, with each recipient specified as a JSON string (e.g., '[{\"email\": \"[email protected]\"}]')",
23+
},
24+
message: {
25+
type: "string",
26+
label: "Message",
27+
description: "A personalized message for the recipients",
28+
optional: true,
29+
},
30+
},
531
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
32+
_baseUrl() {
33+
return "https://api.flexisign.io/v1";
34+
},
35+
async _makeRequest(opts = {}) {
36+
const {
37+
$ = this, method = "GET", path = "/", headers, ...otherOpts
38+
} = opts;
39+
return axios($, {
40+
...otherOpts,
41+
method,
42+
url: this._baseUrl() + path,
43+
headers: {
44+
...headers,
45+
Authorization: `Bearer ${this.$auth.api_key}`,
46+
},
47+
});
48+
},
49+
async listTemplates(opts = {}) {
50+
return this._makeRequest({
51+
path: "/templates",
52+
...opts,
53+
});
54+
},
55+
async sendSignatureRequest(opts = {}) {
56+
const {
57+
templateId, recipients, message,
58+
} = opts;
59+
return this._makeRequest({
60+
method: "POST",
61+
path: "/signature/send",
62+
data: {
63+
template_id: templateId,
64+
recipients: recipients.map(JSON.parse),
65+
message,
66+
},
67+
});
968
},
1069
},
1170
};

components/flexisign/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)