Skip to content

Commit a68884c

Browse files
luancazarinelcaresia
authored andcommitted
New Components - flexisign (#14552)
* flexisign init * [Components] flexisign #14491 Actions - Send Document Using Template * pnpm update
1 parent 6856152 commit a68884c

File tree

5 files changed

+135
-9
lines changed

5 files changed

+135
-9
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { snakeCaseToTitleCase } from "../../common/utils.mjs";
2+
import flexisign from "../../flexisign.app.mjs";
3+
4+
export default {
5+
key: "flexisign-send-document-using-template",
6+
name: "Send Document Using Template",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
flexisign,
12+
templateId: {
13+
propDefinition: [
14+
flexisign,
15+
"templateId",
16+
],
17+
reloadProps: true,
18+
},
19+
},
20+
async additionalProps() {
21+
const props = {};
22+
if (this.templateId) {
23+
const { data: { bodyStructure } } = await this.flexisign.getTemplateDetails({
24+
params: {
25+
templateId: this.templateId,
26+
},
27+
});
28+
29+
for (const [
30+
key,
31+
value,
32+
] of Object.entries(bodyStructure)) {
33+
if ([
34+
"templateId",
35+
"recipientsCount",
36+
].includes(key)) continue;
37+
38+
const title = snakeCaseToTitleCase(key);
39+
props[key] = {
40+
type: typeof value === "number"
41+
? "integer"
42+
: "string",
43+
label: title,
44+
description: title,
45+
default: typeof value === "number"
46+
? value
47+
: undefined,
48+
};
49+
}
50+
}
51+
return props;
52+
},
53+
async run({ $ }) {
54+
const {
55+
flexisign,
56+
...data
57+
} = this;
58+
59+
const response = await flexisign.sendSignatureRequest({
60+
$,
61+
data,
62+
});
63+
64+
$.export("$summary", `Signature request sent for template ID: ${this.templateId}`);
65+
return response;
66+
},
67+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const snakeCaseToTitleCase = (s) =>
2+
s.replace(/^_*(.)|_+(.)/g, (s, c, d) => c
3+
? c.toUpperCase()
4+
: " " + d.toUpperCase());
Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,60 @@
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 { data: { list } } = await this.listTemplates();
13+
return list.map(({
14+
_id: value, name: label,
15+
}) => ({
16+
label,
17+
value,
18+
}));
19+
},
20+
},
21+
},
522
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
23+
_baseUrl() {
24+
return "https://api.flexisign.io/v1";
25+
},
26+
_headers() {
27+
return {
28+
"api-key": `${this.$auth.api_key}`,
29+
};
30+
},
31+
_makeRequest({
32+
$ = this, path, ...opts
33+
}) {
34+
return axios($, {
35+
url: this._baseUrl() + path,
36+
headers: this._headers(),
37+
...opts,
38+
});
39+
},
40+
listTemplates(opts = {}) {
41+
return this._makeRequest({
42+
path: "/templates/all",
43+
...opts,
44+
});
45+
},
46+
getTemplateDetails(opts = {}) {
47+
return this._makeRequest({
48+
path: "/template",
49+
...opts,
50+
});
51+
},
52+
sendSignatureRequest(opts = {}) {
53+
return this._makeRequest({
54+
method: "POST",
55+
path: "/template/create-document",
56+
...opts,
57+
});
958
},
1059
},
1160
};

components/flexisign/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/flexisign",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream FlexiSign Components",
55
"main": "flexisign.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)