Skip to content
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

[Components] OnlineCheckWriter: New action components #14119

Merged
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
134 changes: 134 additions & 0 deletions components/onlinecheckwriter/actions/create-check/create-check.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import app from "../../onlinecheckwriter.app.mjs";

export default {
key: "onlinecheckwriter-create-check",
name: "Create Check",
description: "Creates a new check. [See the documentation](https://apiv3.onlinecheckwriter.com/#211cb6e4-bda7-46de-9e84-a5e8b2709206)",
version: "0.0.1",
type: "action",
props: {
app,
bankAccountId: {
propDefinition: [
app,
"bankAccountId",
],
},
payeeId: {
propDefinition: [
app,
"payeeId",
],
},
categoryId: {
propDefinition: [
app,
"categoryId",
],
},
issueDate: {
propDefinition: [
app,
"issueDate",
],
},
amount: {
propDefinition: [
app,
"amount",
],
},
memo: {
propDefinition: [
app,
"memo",
],
},
note: {
propDefinition: [
app,
"note",
],
},
invoiceNumber: {
propDefinition: [
app,
"invoiceNumber",
],
},
noSign: {
propDefinition: [
app,
"noSign",
],
},
noAmount: {
propDefinition: [
app,
"noAmount",
],
},
noDate: {
propDefinition: [
app,
"noDate",
],
},
noPayee: {
propDefinition: [
app,
"noPayee",
],
},
},
methods: {
createChecks(args = {}) {
return this.app.post({
path: "/checks",
...args,
});
},
},
async run({ $ }) {
const {
createChecks,
bankAccountId,
payeeId,
categoryId,
issueDate,
amount,
memo,
note,
invoiceNumber,
noSign,
noAmount,
noDate,
noPayee,
} = this;

const response = await createChecks({
$,
data: {
checks: [
{
bankAccountId,
payeeId,
categoryId,
issueDate,
amount,
memo,
note,
invoiceNumber,
noSign,
noAmount,
noDate,
noPayee,
},
],
},
});

$.export("$summary", `Successfully created a new check with ID \`${response.data.checks[0].checkId}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import app from "../../onlinecheckwriter.app.mjs";

export default {
key: "onlinecheckwriter-create-email-check",
name: "Create Email Check",
description: "Create an email check for a payee. [See the documentation](https://apiv3.onlinecheckwriter.com/#211cb6e4-bda7-46de-9e84-a5e8b2709206).",
version: "0.0.1",
type: "action",
props: {
app,
checkId: {
propDefinition: [
app,
"checkId",
],
},
payeeEmail: {
optional: false,
propDefinition: [
app,
"payeeEmail",
],
},
enableSmsInform: {
propDefinition: [
app,
"enableSmsInform",
],
},
payeePhone: {
optional: false,
description: "Required if **Enable SMS Inform** is `true` and not exist any phone on associated payee,",
propDefinition: [
app,
"payeePhone",
],
},
sendAttachment: {
type: "boolean",
label: "Send Attachment",
description: "This will send added attachments along with the check.",
optional: true,
},
},
methods: {
createEmailChecks(args = {}) {
return this.app.post({
path: "/emailchecks",
...args,
});
},
},
async run({ $ }) {
const {
createEmailChecks,
checkId,
payeeEmail,
enableSmsInform,
payeePhone,
sendAttachment,
} = this;

const response = await createEmailChecks({
$,
data: {
emailChecks: [
{
checkId,
payeeEmail,
enableSmsInform,
payeePhone,
...(sendAttachment !== undefined && {
sendAttachment: +sendAttachment,
}),
},
],
},
});
jcortes marked this conversation as resolved.
Show resolved Hide resolved
$.export("$summary", "Successfully created email checks.");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import app from "../../onlinecheckwriter.app.mjs";

export default {
key: "onlinecheckwriter-create-mail-check",
name: "Create Mail Check",
description: "Creates a mail check. [See the documentation](https://apiv3.onlinecheckwriter.com/#f4562b65-70e8-4c4d-8444-8898e61ab7f0).",
version: "0.0.1",
type: "action",
props: {
app,
isShippingToCustomAddress: {
type: "boolean",
label: "Shipping To Custom Address?",
description: "Value is `true` if sending mail to custom address. Default `false`",
optional: true,
},
customFromAddressId: {
description: "Must be a custom from address ID. Required if **Shipping To Custom Address?** is `true`.",
propDefinition: [
app,
"customFromAddressId",
],
},
customToAddressId: {
description: "Must be a custom to address ID. Required if **Shipping To Custom Address?** is `true`.",
propDefinition: [
app,
"customToAddressId",
],
},
customShippingTypeId: {
label: "Custom Shipping Type ID",
description: "Must be a valid custom shipping type ID. Required if **Shipping To Custom Address?** is `true`.",
propDefinition: [
app,
"shippingTypeId",
],
},
checkId: {
propDefinition: [
app,
"checkId",
],
},
shippingTypeId: {
optional: false,
description: "The shipping type ID of the check.",
propDefinition: [
app,
"shippingTypeId",
],
},
paperTypeId: {
propDefinition: [
app,
"paperTypeId",
],
},
informTypeId: {
propDefinition: [
app,
"informTypeId",
],
},
enableSmsInform: {
propDefinition: [
app,
"enableSmsInform",
],
},
enableEmailInform: {
type: "boolean",
label: "Enable Email Inform",
description: "Value is `true` if email inform is enabled. Default `false`.",
optional: true,
},
payeeEmail: {
description: "Required if **Enable Email Inform** is `true` and there is no email on the associated payee.",
propDefinition: [
app,
"payeeEmail",
],
},
payeePhone: {
description: "Required if **Enable SMS Inform** is `true` and there is no phone on the associated payee.",
propDefinition: [
app,
"payeePhone",
],
},
},
methods: {
createMailChecks(args = {}) {
return this.app.post({
path: "/mailchecks",
...args,
});
},
},
async run({ $ }) {
const {
createMailChecks,
isShippingToCustomAddress,
customFromAddressId,
customToAddressId,
customShippingTypeId,
checkId,
shippingTypeId,
paperTypeId,
informTypeId,
enableSmsInform,
enableEmailInform,
payeeEmail,
payeePhone,
} = this;
jcortes marked this conversation as resolved.
Show resolved Hide resolved

const response = await createMailChecks({
$,
data: {
isShippingToCustomAddress,
customFromAddressId,
customToAddressId,
customShippingTypeId,
mailChecks: [
{
checkId,
shippingTypeId,
paperTypeId,
informTypeId,
...(enableSmsInform !== undefined && {
enableSmsInform: +enableSmsInform,
}),
...(enableEmailInform !== undefined && {
enableEmailInform: +enableEmailInform,
}),
payeeEmail,
payeePhone,
},
],
},
});
$.export("$summary", "Successfully created and mailed checks.");
return response;
},
};
Loading
Loading