-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - flexisign #14552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - flexisign #14552
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
components/flexisign/actions/send-document-using-template/send-document-using-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }, | ||
| }, | ||
| 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; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sendSignatureRequest(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/template/create-document", | ||
| ...opts, | ||
| }); | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
recipientsprop is being added in theadditionalPropsmethod based on the selectedtemplateId. TheadditionalPropsfunction dynamically generates props from the template'sbodyStructure, which includesrecipients. Given this, we should update the component's description to clarify that the recipients are specified dynamically based on the template's structure.