-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - signaturit #14855
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 - signaturit #14855
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
29088ab
signaturit init
luancazarine 87cac62
[Components] signaturit #13223
luancazarine c7dbef9
pnpm update
luancazarine b90d7d4
Update components/signaturit/actions/create-signature-request-from-te…
luancazarine a7c26a0
some adjusts
luancazarine df12f4d
Merge branch 'master' into issue-13223
luancazarine 5a79456
pnpm update
luancazarine 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
This file was deleted.
Oops, something went wrong.
116 changes: 116 additions & 0 deletions
116
components/signaturit/actions/create-certified-email/create-certified-email.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,116 @@ | ||
import FormData from "form-data"; | ||
import fs from "fs"; | ||
import { TYPE_OPTIONS } from "../../common/constants.mjs"; | ||
import { | ||
checkTmp, | ||
parseObject, | ||
} from "../../common/utils.mjs"; | ||
import signaturit from "../../signaturit.app.mjs"; | ||
|
||
export default { | ||
key: "signaturit-create-certified-email", | ||
name: "Create Certified Email", | ||
description: "Initiates the creation of a certified email. [See the documentation](https://docs.signaturit.com/api/latest#emails_create_email)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
signaturit, | ||
body: { | ||
propDefinition: [ | ||
signaturit, | ||
"body", | ||
], | ||
optional: true, | ||
}, | ||
brandingId: { | ||
propDefinition: [ | ||
signaturit, | ||
"brandingId", | ||
], | ||
optional: true, | ||
}, | ||
eventsUrl: { | ||
propDefinition: [ | ||
signaturit, | ||
"eventsUrl", | ||
], | ||
optional: true, | ||
}, | ||
data: { | ||
propDefinition: [ | ||
signaturit, | ||
"data", | ||
], | ||
optional: true, | ||
}, | ||
attachments: { | ||
propDefinition: [ | ||
signaturit, | ||
"attachments", | ||
], | ||
optional: true, | ||
}, | ||
recipients: { | ||
propDefinition: [ | ||
signaturit, | ||
"recipients", | ||
], | ||
}, | ||
type: { | ||
type: "string", | ||
label: "Type", | ||
description: "Type of certified email.", | ||
options: TYPE_OPTIONS, | ||
optional: true, | ||
}, | ||
subject: { | ||
propDefinition: [ | ||
signaturit, | ||
"subject", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const formData = new FormData(); | ||
|
||
let i = 0; | ||
for (const recipient of parseObject(this.recipients)) { | ||
for (const [ | ||
key, | ||
value, | ||
] of Object.entries(recipient)) { | ||
formData.append(`recipients[${i}][${key}]`, value); | ||
} | ||
i++; | ||
} | ||
if (this.data) { | ||
for (const [ | ||
key, | ||
value, | ||
] of Object.entries(this.data)) { | ||
formData.append(`data[${key}]`, value); | ||
} | ||
i++; | ||
} | ||
if (this.body) formData.append("body", this.body); | ||
if (this.brandingId) formData.append("branding_id", this.brandingId); | ||
if (this.eventsUrl) formData.append("events_url", this.eventsUrl); | ||
if (this.type) formData.append("type", this.type); | ||
if (this.subject) formData.append("subject", this.subject); | ||
|
||
if (this.attachments) { | ||
let j = 0; | ||
for (const file of parseObject(this.attachments)) { | ||
formData.append(`attachments[${j++}]`, fs.createReadStream(checkTmp(file))); | ||
} | ||
} | ||
const response = await this.signaturit.createCertifiedEmail({ | ||
$, | ||
data: formData, | ||
headers: formData.getHeaders(), | ||
}); | ||
$.export("$summary", `Created certified email with ID: ${response.id}`); | ||
return response; | ||
}, | ||
}; |
227 changes: 227 additions & 0 deletions
227
...actions/create-signature-request-from-template/create-signature-request-from-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,227 @@ | ||
import FormData from "form-data"; | ||
import fs from "fs"; | ||
import { | ||
DELIVERY_TYPE_OPTIONS, | ||
SIGNATURE_TYPE_OPTIONS, | ||
SIGNING_MODE_OPTIONS, | ||
} from "../../common/constants.mjs"; | ||
import { | ||
checkTmp, | ||
parseObject, | ||
} from "../../common/utils.mjs"; | ||
import signaturit from "../../signaturit.app.mjs"; | ||
|
||
export default { | ||
key: "signaturit-create-signature-request-from-template", | ||
name: "Create Signature Request from Template", | ||
description: "Creates a signature request using a pre-existing template. [See the documentation](https://docs.signaturit.com/api/latest#signatures_create_signature)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
signaturit, | ||
body: { | ||
propDefinition: [ | ||
signaturit, | ||
"body", | ||
], | ||
description: "Email body (html code is allowed) for **email** and **sms** type requests. Note: For **sms** request types it will be truncated to 120 characters Note: For **sms** the body should contain the tag **{{url}}** where we will include the document url.", | ||
optional: true, | ||
}, | ||
brandingId: { | ||
propDefinition: [ | ||
signaturit, | ||
"brandingId", | ||
], | ||
optional: true, | ||
}, | ||
callbackUrl: { | ||
type: "string", | ||
label: "Callback URL", | ||
description: "Url to redirect the user when finish the signature process.", | ||
optional: true, | ||
}, | ||
data: { | ||
propDefinition: [ | ||
signaturit, | ||
"data", | ||
], | ||
optional: true, | ||
}, | ||
deliveryType: { | ||
type: "string", | ||
label: "Delivery Type", | ||
description: "Delivery type for signature request.", | ||
options: DELIVERY_TYPE_OPTIONS, | ||
optional: true, | ||
}, | ||
expireTime: { | ||
type: "integer", | ||
label: "Expiration Time (days)", | ||
description: "Expiration time of the document in days (max 365).", | ||
min: 1, | ||
max: 365, | ||
optional: true, | ||
}, | ||
eventsUrl: { | ||
propDefinition: [ | ||
signaturit, | ||
"eventsUrl", | ||
], | ||
optional: true, | ||
}, | ||
files: { | ||
propDefinition: [ | ||
signaturit, | ||
"attachments", | ||
], | ||
label: "Files", | ||
optional: true, | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Name assigned to the signature request.", | ||
}, | ||
recipients: { | ||
propDefinition: [ | ||
signaturit, | ||
"recipients", | ||
], | ||
description: "List of recipients in JSON format, e.g., '{\"name\": \"John Doe\", \"email\": \"[email protected]\", \"phone\": \"34555667788\"}'. [See the documentation](https://docs.signaturit.com/api/latest#signatures_create_signature) for further information.", | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cc: { | ||
type: "string[]", | ||
label: "CC", | ||
description: "List with email recipients containing name and email for people that will receive a copy of the signed document when the process is completed. e.g., '{\"name\": \"John Doe\", \"email\": \"[email protected]\"}'.", | ||
optional: true, | ||
}, | ||
replyTo: { | ||
type: "string", | ||
label: "Reply To", | ||
description: "Email Reply-To address.", | ||
optional: true, | ||
}, | ||
reminders: { | ||
type: "string[]", | ||
label: "Reminders (days)", | ||
description: "Reminders in days to send automatic reminders. You can set it 0 to disable reminders. E.g. [1,3,4]", | ||
optional: true, | ||
}, | ||
signingMode: { | ||
type: "string", | ||
label: "Signing Mode", | ||
description: "The signing mode lets you control the order in which your recipients receive and sign your documents.", | ||
options: SIGNING_MODE_OPTIONS, | ||
optional: true, | ||
}, | ||
subject: { | ||
propDefinition: [ | ||
signaturit, | ||
"subject", | ||
], | ||
optional: true, | ||
}, | ||
templates: { | ||
propDefinition: [ | ||
signaturit, | ||
"templates", | ||
], | ||
}, | ||
type: { | ||
type: "string", | ||
label: "Type", | ||
description: "The type of the signature.", | ||
options: SIGNATURE_TYPE_OPTIONS, | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
transformArray({ | ||
arr, prefixBase, formData, | ||
}) { | ||
let result = []; | ||
function processObject(obj, prefix = "") { | ||
for (let key in obj) { | ||
if (Array.isArray(obj[key])) { | ||
obj[key].forEach((item, index) => { | ||
processObject(item, `${prefix}[${key}][${index}]`); | ||
}); | ||
} else if (typeof obj[key] === "object") { | ||
processObject(obj[key], `${prefix}[${key}]`); | ||
} else { | ||
result.push({ | ||
key: `${prefixBase}${prefix}[${key}]`, | ||
value: `${obj[key]}`, | ||
}); | ||
} | ||
} | ||
} | ||
arr.map((item, index) => { | ||
processObject(item, `[${index}]`); | ||
}); | ||
for (const { | ||
key, value, | ||
} of result) { | ||
formData.append(key, value); | ||
} | ||
return result; | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const formData = new FormData(); | ||
this.transformArray({ | ||
arr: parseObject(this.recipients), | ||
prefixBase: "recipients", | ||
formData, | ||
}); | ||
if (this.cc) { | ||
let j = 0; | ||
for (const item of parseObject(this.cc)) { | ||
formData.append(`cc[${j++}]`, item); | ||
} | ||
} | ||
if (this.data) { | ||
for (const [ | ||
key, | ||
value, | ||
] of Object.entries(parseObject(this.data))) { | ||
formData.append(`data[${key}]`, value); | ||
} | ||
} | ||
if (this.templates) { | ||
let k = 0; | ||
for (const templateId of parseObject(this.templates)) { | ||
formData.append(`templates[${k++}]`, templateId); | ||
} | ||
} | ||
if (this.reminders) { | ||
let m = 0; | ||
for (const reminder of parseObject(this.reminders)) { | ||
formData.append(`reminders[${m++}]`, reminder); | ||
} | ||
} | ||
if (this.body) formData.append("body", this.body); | ||
if (this.brandingId) formData.append("branding_id", this.brandingId); | ||
if (this.callbackUrl) formData.append("callback_url", this.callbackUrl); | ||
if (this.deliveryType) formData.append("delivery_type", this.deliveryType); | ||
if (this.expireTime) formData.append("expire_time", this.expireTime); | ||
if (this.eventsUrl) formData.append("events_url", this.eventsUrl); | ||
if (this.name) formData.append("name", this.name); | ||
if (this.replyTo) formData.append("reply_to", this.replyTo); | ||
if (this.type) formData.append("type", this.type); | ||
|
||
if (this.files) { | ||
let k = 0; | ||
for (const file of parseObject(this.files)) { | ||
formData.append(`files[${k++}]`, fs.createReadStream(checkTmp(file))); | ||
} | ||
} | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const response = await this.signaturit.createSignatureRequest({ | ||
$, | ||
data: formData, | ||
headers: formData.getHeaders(), | ||
}); | ||
$.export("$summary", `Created signature request with ID: ${response.id}`); | ||
return response; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
26 changes: 26 additions & 0 deletions
26
...ts/signaturit/actions/send-signature-request-reminder/send-signature-request-reminder.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,26 @@ | ||
import signaturit from "../../signaturit.app.mjs"; | ||
|
||
export default { | ||
key: "signaturit-send-signature-request-reminder", | ||
name: "Send Signature Request Reminder", | ||
description: "Sends a reminder for a pending signature request. [See the documentation](https://docs.signaturit.com/api/latest#signatures_send_reminder)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
signaturit, | ||
signatureRequestId: { | ||
propDefinition: [ | ||
signaturit, | ||
"signatureRequestId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.signaturit.sendReminder({ | ||
$, | ||
signatureRequestId: this.signatureRequestId, | ||
}); | ||
$.export("$summary", `Sent reminder for signature request ${this.signatureRequestId}`); | ||
return response; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file was deleted.
Oops, something went wrong.
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.