-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db59016
commit 27b7ce9
Showing
8 changed files
with
586 additions
and
6 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
components/the_bookie/actions/create-contact/create-contact.mjs
This file contains 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,53 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import thebookie from "../../the_bookie.app.mjs"; | ||
|
||
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, | ||
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; | ||
}, | ||
}; |
81 changes: 81 additions & 0 deletions
81
components/the_bookie/actions/create-sales-invoice/create-sales-invoice.mjs
This file contains 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,81 @@ | ||
import theBookie from "../../the_bookie.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
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; | ||
}, | ||
}; |
66 changes: 66 additions & 0 deletions
66
components/the_bookie/actions/find-or-create-contact/find-or-create-contact.mjs
This file contains 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,66 @@ | ||
import theBookie from "../../the_bookie.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
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; | ||
}, | ||
}; |
This file contains 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 |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
"publishConfig": { | ||
"access": "public" | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
components/the_bookie/sources/new-contact-updated-instant/new-contact-updated-instant.mjs
This file contains 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,62 @@ | ||
import theBookie from "../../the_bookie.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
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(); | ||
}, | ||
}; |
72 changes: 72 additions & 0 deletions
72
components/the_bookie/sources/new-invoice-created-instant/new-invoice-created-instant.mjs
This file contains 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,72 @@ | ||
import theBookie from "../../the_bookie.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
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(), | ||
}); | ||
}, | ||
}; |
Oops, something went wrong.