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
@@ -0,0 +1,67 @@
import { snakeCaseToTitleCase } from "../../common/utils.mjs";
import flexisign from "../../flexisign.app.mjs";

export default {
key: "flexisign-send-document-using-template",
name: "Send Document Using Template",
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)",
version: "0.0.1",
type: "action",
props: {
flexisign,
templateId: {
propDefinition: [
flexisign,
"templateId",
],
reloadProps: true,
},
},
Comment on lines +10 to +19
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add required recipients property to props.

According to the PR objectives, the component should allow specifying recipients for the signature request. However, the recipients property is missing from the props definition.

Add the recipients property to props:

  props: {
    flexisign,
    templateId: {
      propDefinition: [
        flexisign,
        "templateId",
      ],
      reloadProps: true,
    },
+   recipients: {
+     type: "string[]",
+     label: "Recipients",
+     description: "Email addresses of the recipients who need to sign the document",
+     required: true,
+   },
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
props: {
flexisign,
templateId: {
propDefinition: [
flexisign,
"templateId",
],
reloadProps: true,
},
},
props: {
flexisign,
templateId: {
propDefinition: [
flexisign,
"templateId",
],
reloadProps: true,
},
recipients: {
type: "string[]",
label: "Recipients",
description: "Email addresses of the recipients who need to sign the document",
required: true,
},
},

Copy link
Collaborator

@GTFalcao GTFalcao Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense given the component description mentions 'specified recipients'. Is the recipient prop being mounted in additionalProps? If not, the description should be updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GTFalcao, thank you for pointing this out. The recipients prop is being added in the additionalProps method based on the selected templateId. The additionalProps function dynamically generates props from the template's bodyStructure, which includes recipients. Given this, we should update the component's description to clarify that the recipients are specified dynamically based on the template's structure.

async additionalProps() {
const props = {};
if (this.templateId) {
const { data: { bodyStructure } } = await this.flexisign.getTemplateDetails({
params: {
templateId: this.templateId,
},
});

for (const [
key,
value,
] of Object.entries(bodyStructure)) {
if ([
"templateId",
"recipientsCount",
].includes(key)) continue;

const title = snakeCaseToTitleCase(key);
props[key] = {
type: typeof value === "number"
? "integer"
: "string",
label: title,
description: title,
default: typeof value === "number"
? value
: undefined,
};
}
}
return props;
},
async run({ $ }) {
const {
flexisign,
...data
} = this;

const response = await flexisign.sendSignatureRequest({
$,
data,
});

$.export("$summary", `Signature request sent for template ID: ${this.templateId}`);
return response;
},
};
4 changes: 4 additions & 0 deletions components/flexisign/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const snakeCaseToTitleCase = (s) =>
s.replace(/^_*(.)|_+(.)/g, (s, c, d) => c
? c.toUpperCase()
: " " + d.toUpperCase());
57 changes: 53 additions & 4 deletions components/flexisign/flexisign.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,60 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "flexisign",
propDefinitions: {},
propDefinitions: {
templateId: {
type: "string",
label: "Template ID",
description: "The ID of the template to generate the document from",
async options() {
const { data: { list } } = await this.listTemplates();
return list.map(({
_id: value, name: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.flexisign.io/v1";
},
_headers() {
return {
"api-key": `${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
listTemplates(opts = {}) {
return this._makeRequest({
path: "/templates/all",
...opts,
});
},
getTemplateDetails(opts = {}) {
return this._makeRequest({
path: "/template",
...opts,
});
},
sendSignatureRequest(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/template/create-document",
...opts,
});
},
},
};
7 changes: 5 additions & 2 deletions components/flexisign/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/flexisign",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream FlexiSign Components",
"main": "flexisign.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading