-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - papersign #14423
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 - papersign #14423
Changes from all commits
Commits
Show all changes
5 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
65 changes: 65 additions & 0 deletions
65
components/papersign/actions/copy-document/copy-document.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,65 @@ | ||
| import papersign from "../../papersign.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "papersign-copy-document", | ||
| name: "Copy Document", | ||
| description: "Duplicates a given document. [See the documentation](https://paperform.readme.io/reference/papersigncopydocument)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| papersign, | ||
| documentId: { | ||
| propDefinition: [ | ||
| papersign, | ||
| "documentId", | ||
| ], | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The new name of the copied document", | ||
| optional: true, | ||
| }, | ||
| spaceId: { | ||
| propDefinition: [ | ||
| papersign, | ||
| "spaceId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| path: { | ||
| type: "string", | ||
| label: "Path", | ||
| description: "The path to copy the document to. Maximum depth is 4 levels. Any missing folders will be created.", | ||
| optional: true, | ||
| }, | ||
| folderId: { | ||
| propDefinition: [ | ||
| papersign, | ||
| "folderId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const data = {}; | ||
| if (this.folderId) { | ||
| data.folder_id = this.folderId; | ||
| } else { | ||
| data.space_id = this.spaceId; | ||
| data.path = this.path; | ||
| } | ||
|
|
||
| const response = await this.papersign.duplicateDocument({ | ||
| $, | ||
| documentId: this.documentId, | ||
| data: { | ||
| ...data, | ||
| name: this.name, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully copied document: ${response.results.document.name}`); | ||
| return response; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
27 changes: 27 additions & 0 deletions
27
components/papersign/actions/get-document/get-document.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,27 @@ | ||
| import papersign from "../../papersign.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "papersign-get-document", | ||
| name: "Get Document", | ||
| description: "Retrieve a document using a specified ID. [See the documentation](https://paperform.readme.io/reference/getpapersigndocument)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| papersign, | ||
| documentId: { | ||
| propDefinition: [ | ||
| papersign, | ||
| "documentId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.papersign.getDocument({ | ||
| $, | ||
| documentId: this.documentId, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully retrieved document with ID: ${this.documentId}`); | ||
| return response; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
115 changes: 115 additions & 0 deletions
115
components/papersign/actions/send-document/send-document.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,115 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import papersign from "../../papersign.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "papersign-send-document", | ||
| name: "Send Document", | ||
| description: "Dispatches a document to a specified recipient. [See the documentation](https://paperform.readme.io/reference/papersignsenddocument)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| papersign, | ||
| documentId: { | ||
| propDefinition: [ | ||
| papersign, | ||
| "documentId", | ||
| ], | ||
| }, | ||
| expiration: { | ||
| type: "string", | ||
| label: "Expiration", | ||
| description: "The expiration date of the document. Must be at least 30 minutes in the future. **Format: YYYY-MM-DDTHH:MM:SS.SSSZ**", | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| inviteMessage: { | ||
| type: "string", | ||
| label: "Invite Message", | ||
| description: "The message to include in the invitation email, up to 1000 characters.", | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fromUserEmail: { | ||
| type: "string", | ||
| label: "From User Email", | ||
| description: "The email address of a User on your team's account to send the document from.", | ||
| optional: true, | ||
| }, | ||
| documentRecipientEmails: { | ||
| type: "string[]", | ||
| label: "Document Recipient Emails", | ||
| description: "An array of recipient emails for the document.", | ||
| optional: true, | ||
| }, | ||
| firstAfterDays: { | ||
| type: "integer", | ||
| label: "Automatic Reminder - First After Days", | ||
| description: "The number of days after the document is sent to send the reminder.", | ||
| optional: true, | ||
| }, | ||
| followUpEveryDays: { | ||
| type: "integer", | ||
| label: "Automatic Reminder - Follow Up Every Days", | ||
| description: "The number of days to wait between reminders.", | ||
| optional: true, | ||
| }, | ||
| signers: { | ||
| type: "string[]", | ||
| label: "Signers", | ||
| description: "An array of objects of signers. **Object format: {\"key\": \"123\",\"name\": \"Jack Smith\",\"email\": \"[email protected]\",\"phone\": \"123 456 7899\",\"job_title\": \"Account Manager\",\"company\": \"Explosive Startup\",\"custom_attributes\": [{\"key\": \"Relationship\",\"label\": \"Relationship to the company\",\"value\": \"CEO\"}]}**", | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| variables: { | ||
| type: "object", | ||
| label: "Variables", | ||
| description: "The key: value of the document variables.", | ||
| optional: true, | ||
| }, | ||
| copy: { | ||
| type: "boolean", | ||
| label: "Copy", | ||
| description: "Whether to copy before sending.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if ( | ||
| (this.firstAfterDays && !this.followUpEveryDays) || | ||
| (!this.firstAfterDays && this.followUpEveryDays) | ||
| ) { | ||
| throw new ConfigurationError("You must fill in the fields 'First After Days' and 'Follow Up Every Days' or none of them"); | ||
| } | ||
|
|
||
| const automaticReminders = {}; | ||
| if (this.firstAfterDays) { | ||
| automaticReminders.first_after_days = this.firstAfterDays; | ||
| automaticReminders.follow_up_every_days = this.followUpEveryDays; | ||
| } | ||
|
|
||
| const variables = []; | ||
| if (this.variables) { | ||
| for (const key of Object.keys(parseObject(this.variables))) { | ||
| variables.push({ | ||
| key, | ||
| value: this.variables[key], | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const response = await this.papersign.sendDocument({ | ||
| $, | ||
| documentId: this.documentId, | ||
| data: { | ||
| expiration: this.expiration, | ||
| inviteMessage: this.inviteMessage, | ||
| fromUserEmail: this.fromUserEmail, | ||
| documentRecipientEmails: parseObject(this.documentRecipientEmails), | ||
| automaticReminders, | ||
| signers: parseObject(this.signers), | ||
| variables, | ||
| copy: this.copy, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Document sent successfully with ID ${this.documentId}`); | ||
| return response; | ||
| }, | ||
luancazarine 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,12 @@ | ||
| export const LIMIT = 100; | ||
|
|
||
| export const SCOPE_OPTIONS = [ | ||
| { | ||
| label: "Direct Children", | ||
| value: "folder.direct_children", | ||
| }, | ||
| { | ||
| label: "All Descendants", | ||
| value: "folder.all_descendants", | ||
| }, | ||
| ]; |
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,32 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return parseObject(item); | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| if (typeof obj === "object") { | ||
| for (const [ | ||
| key, | ||
| value, | ||
| ] of Object.entries(obj)) { | ||
| obj[key] = parseObject(value); | ||
| } | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return obj; | ||
| }; | ||
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/papersign", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Papersign Components", | ||
| "main": "papersign.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
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.