Skip to content

Commit 27b7ce9

Browse files
committed
the_bookie init
1 parent db59016 commit 27b7ce9

File tree

8 files changed

+586
-6
lines changed

8 files changed

+586
-6
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { axios } from "@pipedream/platform";
2+
import thebookie from "../../the_bookie.app.mjs";
3+
4+
export default {
5+
key: "the_bookie-create-contact",
6+
name: "Create Contact",
7+
description: "Instantly creates a new contact in the address book. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
the_bookie,
12+
name: {
13+
type: "string",
14+
label: "Name",
15+
description: "The name of the contact",
16+
},
17+
email: {
18+
type: "string",
19+
label: "Email",
20+
description: "The email of the contact",
21+
},
22+
phoneNumber: {
23+
type: "string",
24+
label: "Phone Number",
25+
description: "The phone number of the contact",
26+
},
27+
address: {
28+
type: "string",
29+
label: "Address",
30+
description: "The address of the contact",
31+
optional: true,
32+
},
33+
notes: {
34+
type: "string",
35+
label: "Notes",
36+
description: "Any extra notes for the contact",
37+
optional: true,
38+
},
39+
},
40+
async run({ $ }) {
41+
const response = await this.the_bookie.createContact({
42+
name: this.name,
43+
email: this.email,
44+
phoneNumber: this.phoneNumber,
45+
address: this.address,
46+
notes: this.notes,
47+
});
48+
49+
$.export("$summary", `Successfully created contact with ID ${response.id}`);
50+
51+
return response;
52+
},
53+
};
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import theBookie from "../../the_bookie.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "the_bookie-create-sales-invoice",
6+
name: "Create Sales Invoice",
7+
description: "Creates a new sales invoice. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
theBookie,
12+
invoiceNumber: {
13+
propDefinition: [
14+
theBookie,
15+
"invoiceNumber",
16+
],
17+
},
18+
clientIdentifier: {
19+
propDefinition: [
20+
theBookie,
21+
"clientIdentifier",
22+
],
23+
},
24+
productServiceDetails: {
25+
propDefinition: [
26+
theBookie,
27+
"productServiceDetails",
28+
],
29+
},
30+
appliedDiscounts: {
31+
propDefinition: [
32+
theBookie,
33+
"appliedDiscounts",
34+
{
35+
optional: true,
36+
},
37+
],
38+
},
39+
taxInformation: {
40+
propDefinition: [
41+
theBookie,
42+
"taxInformation",
43+
{
44+
optional: true,
45+
},
46+
],
47+
},
48+
dueDate: {
49+
propDefinition: [
50+
theBookie,
51+
"dueDate",
52+
{
53+
optional: true,
54+
},
55+
],
56+
},
57+
paymentTerms: {
58+
propDefinition: [
59+
theBookie,
60+
"paymentTerms",
61+
{
62+
optional: true,
63+
},
64+
],
65+
},
66+
},
67+
async run({ $ }) {
68+
const response = await this.theBookie.createInvoice({
69+
invoiceNumber: this.invoiceNumber,
70+
clientIdentifier: this.clientIdentifier,
71+
productServiceDetails: this.productServiceDetails,
72+
appliedDiscounts: this.appliedDiscounts,
73+
taxInformation: this.taxInformation,
74+
dueDate: this.dueDate,
75+
paymentTerms: this.paymentTerms,
76+
});
77+
78+
$.export("$summary", `Successfully created invoice with number ${response.invoiceNumber}`);
79+
return response;
80+
},
81+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import theBookie from "../../the_bookie.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "the_bookie-find-or-create-contact",
6+
name: "Find or Create Contact",
7+
description: "Searches for a contact from the address book. If not found, creates a new contact. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
theBookie,
12+
addressBookId: {
13+
propDefinition: [
14+
theBookie,
15+
"addressBookId",
16+
],
17+
},
18+
name: {
19+
propDefinition: [
20+
theBookie,
21+
"name",
22+
],
23+
},
24+
email: {
25+
propDefinition: [
26+
theBookie,
27+
"email",
28+
],
29+
},
30+
phoneNumber: {
31+
propDefinition: [
32+
theBookie,
33+
"phoneNumber",
34+
],
35+
},
36+
address: {
37+
propDefinition: [
38+
theBookie,
39+
"address",
40+
],
41+
optional: true,
42+
},
43+
notes: {
44+
propDefinition: [
45+
theBookie,
46+
"notes",
47+
],
48+
optional: true,
49+
},
50+
},
51+
async run({ $ }) {
52+
const contact = await this.theBookie.searchCreateContact({
53+
addressBookId: this.addressBookId,
54+
name: this.name,
55+
email: this.email,
56+
phoneNumber: this.phoneNumber,
57+
address: this.address,
58+
notes: this.notes,
59+
});
60+
61+
$.export("$summary", `Contact ${contact.name
62+
? contact.name
63+
: "created"} successfully`);
64+
return contact;
65+
},
66+
};

components/the_bookie/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import theBookie from "../../the_bookie.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "the_bookie-new-contact-updated-instant",
6+
name: "New Contact Created or Updated",
7+
description: "Emit new event when a contact is created or updated. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
theBookie,
13+
addressBookId: {
14+
propDefinition: [
15+
theBookie,
16+
"addressBookId",
17+
],
18+
},
19+
contactId: {
20+
propDefinition: [
21+
theBookie,
22+
"contactId",
23+
],
24+
},
25+
db: "$.service.db",
26+
timer: {
27+
type: "$.interface.timer",
28+
default: {
29+
intervalSeconds: 60,
30+
},
31+
},
32+
},
33+
hooks: {
34+
async deploy() {
35+
await this.processEvents();
36+
},
37+
async activate() {
38+
await this.processEvents();
39+
},
40+
async deactivate() {
41+
// Perform any necessary cleanup
42+
},
43+
},
44+
methods: {
45+
async processEvents() {
46+
const events = await this.theBookie.emitContactCreatedUpdated({
47+
addressBookId: this.addressBookId,
48+
contactId: this.contactId,
49+
});
50+
events.forEach((event) => {
51+
this.$emit(event, {
52+
id: event.contactId,
53+
summary: `Contact created/updated: ${event.contactId}`,
54+
ts: Date.now(),
55+
});
56+
});
57+
},
58+
},
59+
async run() {
60+
await this.processEvents();
61+
},
62+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import theBookie from "../../the_bookie.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "the_bookie-new-invoice-created-instant",
6+
name: "New Invoice Created",
7+
description: "Emit new event when a new invoice is created. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
theBookie,
13+
db: "$.service.db",
14+
invoiceId: {
15+
propDefinition: [
16+
theBookie,
17+
"invoiceId",
18+
],
19+
},
20+
customerId: {
21+
propDefinition: [
22+
theBookie,
23+
"customerId",
24+
],
25+
optional: true,
26+
},
27+
timer: {
28+
type: "$.interface.timer",
29+
default: {
30+
intervalSeconds: 60,
31+
},
32+
},
33+
},
34+
hooks: {
35+
async deploy() {
36+
const invoices = await this.emitInitialInvoices();
37+
for (const invoice of invoices.slice(0, 50)) {
38+
this.$emit(invoice, {
39+
id: invoice.invoiceId,
40+
summary: `New Invoice: ${invoice.invoiceNumber}`,
41+
ts: new Date(invoice.created).getTime(),
42+
});
43+
}
44+
},
45+
async activate() {
46+
console.log("Source activated");
47+
},
48+
async deactivate() {
49+
console.log("Source deactivated");
50+
},
51+
},
52+
methods: {
53+
async emitInitialInvoices() {
54+
return this.theBookie.emitInvoiceCreated({
55+
invoiceId: this.invoiceId,
56+
customerId: this.customerId,
57+
});
58+
},
59+
},
60+
async run() {
61+
const newInvoice = await this.theBookie.emitInvoiceCreated({
62+
invoiceId: this.invoiceId,
63+
customerId: this.customerId,
64+
});
65+
66+
this.$emit(newInvoice, {
67+
id: newInvoice.invoiceId,
68+
summary: `New Invoice: ${newInvoice.invoiceId}`,
69+
ts: new Date().getTime(),
70+
});
71+
},
72+
};

0 commit comments

Comments
 (0)