Skip to content

Commit

Permalink
the_bookie init
Browse files Browse the repository at this point in the history
  • Loading branch information
luancazarine committed Sep 18, 2024
1 parent db59016 commit 27b7ce9
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 6 deletions.
53 changes: 53 additions & 0 deletions components/the_bookie/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { axios } from "@pipedream/platform";

Check failure on line 1 in components/the_bookie/actions/create-contact/create-contact.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used
import thebookie from "../../the_bookie.app.mjs";

Check failure on line 2 in components/the_bookie/actions/create-contact/create-contact.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'thebookie' is defined but never used

export default {
key: "the_bookie-create-contact",
name: "Create Contact",
description: "Instantly creates a new contact in the address book. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
version: "0.0.{{ts}}",
type: "action",
props: {
the_bookie,

Check failure on line 11 in components/the_bookie/actions/create-contact/create-contact.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'the_bookie' is not defined
name: {
type: "string",
label: "Name",
description: "The name of the contact",
},
email: {
type: "string",
label: "Email",
description: "The email of the contact",
},
phoneNumber: {
type: "string",
label: "Phone Number",
description: "The phone number of the contact",
},
address: {
type: "string",
label: "Address",
description: "The address of the contact",
optional: true,
},
notes: {
type: "string",
label: "Notes",
description: "Any extra notes for the contact",
optional: true,
},
},
async run({ $ }) {
const response = await this.the_bookie.createContact({
name: this.name,
email: this.email,
phoneNumber: this.phoneNumber,
address: this.address,
notes: this.notes,
});

$.export("$summary", `Successfully created contact with ID ${response.id}`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import theBookie from "../../the_bookie.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/the_bookie/actions/create-sales-invoice/create-sales-invoice.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "the_bookie-create-sales-invoice",
name: "Create Sales Invoice",
description: "Creates a new sales invoice. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
version: "0.0.1",
type: "action",
props: {
theBookie,
invoiceNumber: {
propDefinition: [
theBookie,
"invoiceNumber",
],
},
clientIdentifier: {
propDefinition: [
theBookie,
"clientIdentifier",
],
},
productServiceDetails: {
propDefinition: [
theBookie,
"productServiceDetails",
],
},
appliedDiscounts: {
propDefinition: [
theBookie,
"appliedDiscounts",
{
optional: true,
},
],
},
taxInformation: {
propDefinition: [
theBookie,
"taxInformation",
{
optional: true,
},
],
},
dueDate: {
propDefinition: [
theBookie,
"dueDate",
{
optional: true,
},
],
},
paymentTerms: {
propDefinition: [
theBookie,
"paymentTerms",
{
optional: true,
},
],
},
},
async run({ $ }) {
const response = await this.theBookie.createInvoice({
invoiceNumber: this.invoiceNumber,
clientIdentifier: this.clientIdentifier,
productServiceDetails: this.productServiceDetails,
appliedDiscounts: this.appliedDiscounts,
taxInformation: this.taxInformation,
dueDate: this.dueDate,
paymentTerms: this.paymentTerms,
});

$.export("$summary", `Successfully created invoice with number ${response.invoiceNumber}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import theBookie from "../../the_bookie.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/the_bookie/actions/find-or-create-contact/find-or-create-contact.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "the_bookie-find-or-create-contact",
name: "Find or Create Contact",
description: "Searches for a contact from the address book. If not found, creates a new contact. [See the documentation]()",
version: "0.0.{{ts}}",
type: "action",
props: {
theBookie,
addressBookId: {
propDefinition: [
theBookie,
"addressBookId",
],
},
name: {
propDefinition: [
theBookie,
"name",
],
},
email: {
propDefinition: [
theBookie,
"email",
],
},
phoneNumber: {
propDefinition: [
theBookie,
"phoneNumber",
],
},
address: {
propDefinition: [
theBookie,
"address",
],
optional: true,
},
notes: {
propDefinition: [
theBookie,
"notes",
],
optional: true,
},
},
async run({ $ }) {
const contact = await this.theBookie.searchCreateContact({
addressBookId: this.addressBookId,
name: this.name,
email: this.email,
phoneNumber: this.phoneNumber,
address: this.address,
notes: this.notes,
});

$.export("$summary", `Contact ${contact.name
? contact.name
: "created"} successfully`);
return contact;
},
};
2 changes: 1 addition & 1 deletion components/the_bookie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"publishConfig": {
"access": "public"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import theBookie from "../../the_bookie.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/the_bookie/sources/new-contact-updated-instant/new-contact-updated-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "the_bookie-new-contact-updated-instant",
name: "New Contact Created or Updated",
description: "Emit new event when a contact is created or updated. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
theBookie,
addressBookId: {
propDefinition: [
theBookie,
"addressBookId",
],
},
contactId: {
propDefinition: [
theBookie,
"contactId",
],
},
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: 60,
},
},
},
hooks: {
async deploy() {
await this.processEvents();
},
async activate() {
await this.processEvents();
},
async deactivate() {
// Perform any necessary cleanup
},
},
methods: {
async processEvents() {
const events = await this.theBookie.emitContactCreatedUpdated({
addressBookId: this.addressBookId,
contactId: this.contactId,
});
events.forEach((event) => {
this.$emit(event, {
id: event.contactId,
summary: `Contact created/updated: ${event.contactId}`,
ts: Date.now(),
});
});
},
},
async run() {
await this.processEvents();
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import theBookie from "../../the_bookie.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/the_bookie/sources/new-invoice-created-instant/new-invoice-created-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "the_bookie-new-invoice-created-instant",
name: "New Invoice Created",
description: "Emit new event when a new invoice is created. [See the documentation](https://app.thebookie.nl/nl/help/category/developers/)",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
theBookie,
db: "$.service.db",
invoiceId: {
propDefinition: [
theBookie,
"invoiceId",
],
},
customerId: {
propDefinition: [
theBookie,
"customerId",
],
optional: true,
},
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: 60,
},
},
},
hooks: {
async deploy() {
const invoices = await this.emitInitialInvoices();
for (const invoice of invoices.slice(0, 50)) {
this.$emit(invoice, {
id: invoice.invoiceId,
summary: `New Invoice: ${invoice.invoiceNumber}`,
ts: new Date(invoice.created).getTime(),
});
}
},
async activate() {
console.log("Source activated");
},
async deactivate() {
console.log("Source deactivated");
},
},
methods: {
async emitInitialInvoices() {
return this.theBookie.emitInvoiceCreated({
invoiceId: this.invoiceId,
customerId: this.customerId,
});
},
},
async run() {
const newInvoice = await this.theBookie.emitInvoiceCreated({
invoiceId: this.invoiceId,
customerId: this.customerId,
});

this.$emit(newInvoice, {
id: newInvoice.invoiceId,
summary: `New Invoice: ${newInvoice.invoiceId}`,
ts: new Date().getTime(),
});
},
};
Loading

0 comments on commit 27b7ce9

Please sign in to comment.