Skip to content

Commit 0b1c546

Browse files
committed
OnlineCheckWriter: New action components
1 parent 2cf235b commit 0b1c546

File tree

8 files changed

+1019
-8
lines changed

8 files changed

+1019
-8
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import app from "../../onlinecheckwriter.app.mjs";
2+
3+
export default {
4+
key: "onlinecheckwriter-create-check",
5+
name: "Create Check",
6+
description: "Creates a new check. [See the documentation](https://apiv3.onlinecheckwriter.com/#211cb6e4-bda7-46de-9e84-a5e8b2709206)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
bankAccountId: {
12+
propDefinition: [
13+
app,
14+
"bankAccountId",
15+
],
16+
},
17+
payeeId: {
18+
propDefinition: [
19+
app,
20+
"payeeId",
21+
],
22+
},
23+
categoryId: {
24+
propDefinition: [
25+
app,
26+
"categoryId",
27+
],
28+
},
29+
issueDate: {
30+
propDefinition: [
31+
app,
32+
"issueDate",
33+
],
34+
},
35+
amount: {
36+
propDefinition: [
37+
app,
38+
"amount",
39+
],
40+
},
41+
memo: {
42+
propDefinition: [
43+
app,
44+
"memo",
45+
],
46+
},
47+
note: {
48+
propDefinition: [
49+
app,
50+
"note",
51+
],
52+
},
53+
invoiceNumber: {
54+
propDefinition: [
55+
app,
56+
"invoiceNumber",
57+
],
58+
},
59+
noSign: {
60+
propDefinition: [
61+
app,
62+
"noSign",
63+
],
64+
},
65+
noAmount: {
66+
propDefinition: [
67+
app,
68+
"noAmount",
69+
],
70+
},
71+
noDate: {
72+
propDefinition: [
73+
app,
74+
"noDate",
75+
],
76+
},
77+
noPayee: {
78+
propDefinition: [
79+
app,
80+
"noPayee",
81+
],
82+
},
83+
},
84+
methods: {
85+
createChecks(args = {}) {
86+
return this.app.post({
87+
path: "/checks",
88+
...args,
89+
});
90+
},
91+
},
92+
async run({ $ }) {
93+
const {
94+
createChecks,
95+
bankAccountId,
96+
payeeId,
97+
categoryId,
98+
issueDate,
99+
amount,
100+
memo,
101+
note,
102+
invoiceNumber,
103+
noSign,
104+
noAmount,
105+
noDate,
106+
noPayee,
107+
} = this;
108+
109+
const response = await createChecks({
110+
$,
111+
data: {
112+
checks: [
113+
{
114+
bankAccountId,
115+
payeeId,
116+
categoryId,
117+
issueDate,
118+
amount,
119+
memo,
120+
note,
121+
invoiceNumber,
122+
noSign,
123+
noAmount,
124+
noDate,
125+
noPayee,
126+
},
127+
],
128+
},
129+
});
130+
131+
$.export("$summary", `Successfully created a new check with ID \`${response.data.checks[0].checkId}\`.`);
132+
return response;
133+
},
134+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import app from "../../onlinecheckwriter.app.mjs";
2+
3+
export default {
4+
key: "onlinecheckwriter-create-email-check",
5+
name: "Create Email Check",
6+
description: "Create an email check for a payee. [See the documentation](https://apiv3.onlinecheckwriter.com/#211cb6e4-bda7-46de-9e84-a5e8b2709206).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
checkId: {
12+
propDefinition: [
13+
app,
14+
"checkId",
15+
],
16+
},
17+
payeeEmail: {
18+
optional: false,
19+
propDefinition: [
20+
app,
21+
"payeeEmail",
22+
],
23+
},
24+
enableSmsInform: {
25+
propDefinition: [
26+
app,
27+
"enableSmsInform",
28+
],
29+
},
30+
payeePhone: {
31+
optional: false,
32+
description: "Required if **Enable SMS Inform** is `true` and not exist any phone on associated payee,",
33+
propDefinition: [
34+
app,
35+
"payeePhone",
36+
],
37+
},
38+
sendAttachment: {
39+
type: "boolean",
40+
label: "Send Attachment",
41+
description: "This will send added attachments along with the check.",
42+
optional: true,
43+
},
44+
},
45+
methods: {
46+
createEmailChecks(args = {}) {
47+
return this.app.post({
48+
path: "/emailchecks",
49+
...args,
50+
});
51+
},
52+
},
53+
async run({ $ }) {
54+
const {
55+
createEmailChecks,
56+
checkId,
57+
payeeEmail,
58+
enableSmsInform,
59+
payeePhone,
60+
sendAttachment,
61+
} = this;
62+
63+
const response = await createEmailChecks({
64+
$,
65+
data: {
66+
emailChecks: [
67+
{
68+
checkId,
69+
payeeEmail,
70+
enableSmsInform,
71+
payeePhone,
72+
...(sendAttachment !== undefined && {
73+
sendAttachment: +sendAttachment,
74+
}),
75+
},
76+
],
77+
},
78+
});
79+
$.export("$summary", "Successfully created email checks.");
80+
return response;
81+
},
82+
};
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import app from "../../onlinecheckwriter.app.mjs";
2+
3+
export default {
4+
key: "onlinecheckwriter-create-mail-check",
5+
name: "Create Mail Check",
6+
description: "Creates a mail check. [See the documentation](https://apiv3.onlinecheckwriter.com/#f4562b65-70e8-4c4d-8444-8898e61ab7f0).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
isShippingToCustomAddress: {
12+
type: "boolean",
13+
label: "Shipping To Custom Address?",
14+
description: "Value is `true` if sending mail to custom address. Default `false`",
15+
optional: true,
16+
},
17+
customFromAddressId: {
18+
description: "Must be a custom from address ID. Required if **Shipping To Custom Address?** is `true`.",
19+
propDefinition: [
20+
app,
21+
"customFromAddressId",
22+
],
23+
},
24+
customToAddressId: {
25+
description: "Must be a custom to address ID. Required if **Shipping To Custom Address?** is `true`.",
26+
propDefinition: [
27+
app,
28+
"customToAddressId",
29+
],
30+
},
31+
customShippingTypeId: {
32+
label: "Custom Shipping Type ID",
33+
description: "Must be a valid custom shipping type ID. Required if **Shipping To Custom Address?** is `true`.",
34+
propDefinition: [
35+
app,
36+
"shippingTypeId",
37+
],
38+
},
39+
checkId: {
40+
propDefinition: [
41+
app,
42+
"checkId",
43+
],
44+
},
45+
shippingTypeId: {
46+
optional: false,
47+
description: "The shipping type ID of the check.",
48+
propDefinition: [
49+
app,
50+
"shippingTypeId",
51+
],
52+
},
53+
paperTypeId: {
54+
propDefinition: [
55+
app,
56+
"paperTypeId",
57+
],
58+
},
59+
informTypeId: {
60+
propDefinition: [
61+
app,
62+
"informTypeId",
63+
],
64+
},
65+
enableSmsInform: {
66+
propDefinition: [
67+
app,
68+
"enableSmsInform",
69+
],
70+
},
71+
enableEmailInform: {
72+
type: "boolean",
73+
label: "Enable Email Inform",
74+
description: "Value is `true` if email inform is enabled. Default `false`.",
75+
optional: true,
76+
},
77+
payeeEmail: {
78+
description: "Required if **Enable Email Inform** is `true` and there is no email on the associated payee.",
79+
propDefinition: [
80+
app,
81+
"payeeEmail",
82+
],
83+
},
84+
payeePhone: {
85+
description: "Required if **Enable SMS Inform** is `true` and there is no phone on the associated payee.",
86+
propDefinition: [
87+
app,
88+
"payeePhone",
89+
],
90+
},
91+
},
92+
methods: {
93+
createMailChecks(args = {}) {
94+
return this.app.post({
95+
path: "/mailchecks",
96+
...args,
97+
});
98+
},
99+
},
100+
async run({ $ }) {
101+
const {
102+
createMailChecks,
103+
isShippingToCustomAddress,
104+
customFromAddressId,
105+
customToAddressId,
106+
customShippingTypeId,
107+
checkId,
108+
shippingTypeId,
109+
paperTypeId,
110+
informTypeId,
111+
enableSmsInform,
112+
enableEmailInform,
113+
payeeEmail,
114+
payeePhone,
115+
} = this;
116+
117+
const response = await createMailChecks({
118+
$,
119+
data: {
120+
isShippingToCustomAddress,
121+
customFromAddressId,
122+
customToAddressId,
123+
customShippingTypeId,
124+
mailChecks: [
125+
{
126+
checkId,
127+
shippingTypeId,
128+
paperTypeId,
129+
informTypeId,
130+
...(enableSmsInform !== undefined && {
131+
enableSmsInform: +enableSmsInform,
132+
}),
133+
...(enableEmailInform !== undefined && {
134+
enableEmailInform: +enableEmailInform,
135+
}),
136+
payeeEmail,
137+
payeePhone,
138+
},
139+
],
140+
},
141+
});
142+
$.export("$summary", "Successfully created and mailed checks.");
143+
return response;
144+
},
145+
};

0 commit comments

Comments
 (0)