Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "zoho_books-create-customer-payment",
name: "Create Customer Payment",
description: "Creates a new payment. [See the documentation](https://www.zoho.com/books/api/v3/customer-payments/#create-a-payment)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
key: "zoho_books-create-customer",
name: "Create Customer",
description: "Creates a new customer. [See the documentation](https://www.zoho.com/books/api/v3/items/#create-an-item)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zoho_books-create-employee",
name: "Create Employee",
description: "Creates an employee for an expense. [See the documentation](https://www.zoho.com/books/api/v3/expenses/#create-an-employee)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "zoho_books-create-estimate",
name: "Create Estimate",
description: "Creates a new estimate. [See the documentation](https://www.zoho.com/books/api/v3/estimates/#create-an-estimate)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zohoBooks,
Expand Down Expand Up @@ -156,7 +156,7 @@ export default {
zohoBooks,
"lineItems",
],
description: "A list of line items objects of an estimate. **Example: {\"item_id\": \"1352827000000156060\", \"name\": \"name\", \"description\": \"description\", \"quantity\": \"1\" }** [See the documentation](https://www.zoho.com/books/api/v3/sales-order/#create-a-sales-order) for further details.",
description: "A list of line items objects of an estimate. **Example: {\"item_id\": \"1352827000.0.256060\", \"name\": \"name\", \"description\": \"description\", \"quantity\": \"1\" }** [See the documentation](https://www.zoho.com/books/api/v3/sales-order/#create-a-sales-order) for further details.",
},
notes: {
propDefinition: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
key: "zoho_books-create-invoice",
name: "Create Invoice",
description: "Creates an invoice for your customer. [See the documentation](https://www.zoho.com/books/api/v3/invoices/#create-an-invoice)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down Expand Up @@ -212,7 +212,7 @@
],
optional: true,
},
reason: {

Check warning on line 215 in components/zoho_books/actions/create-invoice/create-invoice.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop reason must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "string",
label: "Reason",
optional: true,
Expand Down
2 changes: 1 addition & 1 deletion components/zoho_books/actions/create-item/create-item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: "zoho_books-create-item",
name: "Create Item",
description: "Creates a new item. [See the documentation](https://www.zoho.com/books/api/v3/items/#create-an-item)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "zoho_books-create-salesorder",
name: "Create Sales Order",
description: "Creates a sales order. [See the documentation](https://www.zoho.com/books/api/v3/sales-order/#create-a-sales-order)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zoho_books-delete-contact",
name: "Delete Contact",
description: "Deletes an existing contact. [See the documentation](https://www.zoho.com/books/api/v3/contacts/#delete-a-contact)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
2 changes: 1 addition & 1 deletion components/zoho_books/actions/get-invoice/get-invoice.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "zoho_books-get-invoice",
name: "Get Invoice",
description: "Gets the details of an invoice. [See the documentation](https://www.zoho.com/books/api/v3/invoices/#get-an-invoice)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
2 changes: 1 addition & 1 deletion components/zoho_books/actions/get-item/get-item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zoho_books-get-item",
name: "Get Item",
description: "Gets the details of an existing item. [See the documentation](https://www.zoho.com/books/api/v3/items/#get-an-item)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zoho_books-list-contacts",
name: "List Contacts",
description: "Lists all contacts given the organization_id. [See the documentation](https://www.zoho.com/books/api/v3/contacts/#list-contacts)",
version: "0.5.0",
version: "0.5.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
key: "zoho_books-list-expenses",
name: "List Expenses",
description: "List all the Expenses. [See the documentation](https://www.zoho.com/books/api/v3/expenses/#list-expenses)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
key: "zoho_books-list-invoices",
name: "List Invoices",
description: "Lists all invoices. [See the documentation](https://www.zoho.com/books/api/v3/contacts/#list-contacts)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down Expand Up @@ -92,7 +92,7 @@
description: "Search invoices by due date. Default date format is `yyyy-mm-dd`.",
optional: true,
},
lastModifiedTime: {

Check warning on line 95 in components/zoho_books/actions/list-invoices/list-invoices.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop lastModifiedTime must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "string",
label: "Last Modified Time",
optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "zoho_books-make-api-call",
name: "Make API Call",
description: "Makes an aribitrary call to Zoho Books API",
version: "0.4.0",
version: "0.4.1",
type: "action",
props: {
zohoBooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: "zoho_books-update-salesorder",
name: "Update Sales Order",
description: "Updates an existing sales order. [See the documentation](https://www.zoho.com/books/api/v3/sales-order/#update-a-sales-order)",
version: "0.3.0",
version: "0.3.1",
type: "action",
props: {
zohoBooks,
Expand Down
2 changes: 1 addition & 1 deletion components/zoho_books/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zoho_books",
"version": "0.2.0",
"version": "0.2.1",
"description": "Pipedream Zoho Books Components",
"main": "zoho_books.app.mjs",
"keywords": [
Expand Down
71 changes: 28 additions & 43 deletions components/zoho_books/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -1,60 +1,45 @@
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import zohoBooks from "../../zoho_books.app.mjs";

export default {
props: {
zohoBooks,
http: "$.interface.http",
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
webhookName: {
type: "string",
label: "Webhook Name",
description: "A name to identify the webhook.",
},
},
methods: {
_getLastDate() {
return this.db.get("lastDate") || 0;
_getHookId() {
return this.db.get("hookId");
},
_setLastDate(lastDate) {
this.db.set("lastDate", lastDate);
},
async emitEvent(maxResults = false) {
const lastDate = this._getLastDate();

const response = this.zohoBooks.paginate({
fn: this.getFunction(),
fieldName: this.getFieldName(),
});

let responseArray = [];
for await (const item of response) {
if (item.created_time <= lastDate) break;
responseArray.push(item);
}

if (responseArray.length) {
if (maxResults && (responseArray.length > maxResults)) {
responseArray.length = maxResults;
}
this._setLastDate(Date.parse(responseArray[0].created_time));
}

for (const item of responseArray.reverse()) {
this.$emit(item, {
id: item[this.getFieldId()],
summary: this.getSummary(item),
ts: Date.parse(item.created_time),
});
}
_setHookId(hookId) {
this.db.set("hookId", hookId);
},
},
hooks: {
async deploy() {
await this.emitEvent(25);
async activate() {
const { webhook } = await this.zohoBooks.createWebhook({
data: {
webhook_name: this.webhookName,
url: this.http.endpoint,
entity: this.getEntity(),
method: "POST",
body_type: "application/json",
raw_data: "${JSONString}",
},
});
this._setHookId(webhook.webhook_id);
},
async deactivate() {
const webhookId = this._getHookId();
await this.zohoBooks.deleteWebhook(webhookId);
},
},
async run() {
await this.emitEvent();
async run({ body }) {
if (body.payload === "") return true;
this.$emit(body, this.generateMeta(body));
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "zoho_books-new-customer-instant",
name: "New Customer (Instant)",
description: "Emit new event when a new customer is created.",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEntity() {
return "customer";
},
generateMeta({ contact }) {
return {
id: contact.contact_id,
summary: `New Customer: ${contact.contact_name}`,
ts: Date.parse(contact.created_time),
};
},
},
sampleEmit,
};
114 changes: 114 additions & 0 deletions components/zoho_books/sources/new-customer-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
export default {
"contact": {
"contact_id": 460000000026049,
"contact_name": "Bowman and Co",
"company_name": "Bowman and Co",
"has_transaction": true,
"contact_type": "customer",
"customer_sub_type": "business",
"credit_limit": 1000,
"is_taxable": true,
"tax_id": 11149000000061058,
"tax_name": "CGST",
"tax_percentage": 12,
"tax_authority_id": 11149000000061052,
"tax_exemption_id": 11149000000061054,
"tax_authority_name": "string",
"tax_exemption_code": "string",
"place_of_contact": "TN",
"gst_no": "22AAAAA0000A1Z5",
"tax_treatment": "string",
"tax_regime": "general_legal_person",
"legal_name": "ESCUELA KEMPER URGATE",
"is_tds_registered": true,
"vat_treatment": "string",
"gst_treatment": "business_gst",
"is_linked_with_zohocrm": false,
"website": "www.bowmanfurniture.com",
"owner_id": 460000000016051,
"primary_contact_id": 460000000026051,
"payment_terms": 15,
"payment_terms_label": "Net 15",
"currency_id": 460000000000097,
"currency_code": "USD",
"currency_symbol": "$",
"opening_balance_amount": 1200,
"exchange_rate": 1,
"outstanding_receivable_amount": 250,
"outstanding_receivable_amount_bcy": 250,
"unused_credits_receivable_amount": 1369.66,
"unused_credits_receivable_amount_bcy": 1369.66,
"status": "active",
"facebook": "zoho",
"twitter": "zoho",
"payment_reminder_enabled": true,
"custom_fields": [
{
"index": 1,
"value": "GBGD078",
"label": "VAT ID"
}
],
"billing_address": {
"attention": "Mr.John",
"address": "4900 Hopyard Rd",
"street2": "Suite 310",
"state_code": "CA",
"city": "Pleasanton",
"state": "CA",
"zip": 94588,
"country": "U.S.A",
"fax": "+1-925-924-9600",
"phone": "+1-925-921-9201"
},
"shipping_address": {
"attention": "Mr.John",
"address": "4900 Hopyard Rd",
"street2": "Suite 310",
"state_code": "CA",
"city": "Pleasanton",
"state": "CA",
"zip": 94588,
"country": "U.S.A",
"fax": "+1-925-924-9600",
"phone": "+1-925-921-9201"
},
"contact_persons": [
{
"contact_person_id": 460000000026051,
"salutation": "Mr",
"first_name": "Will",
"last_name": "Smith",
"email": "[email protected]",
"phone": "+1-925-921-9201",
"mobile": "+1-4054439562",
"designation": "Sales Executive",
"department": "Sales and Marketing",
"skype": "Zoho",
"is_primary_contact": true,
"enable_portal": true
}
],
"default_templates": {
"invoice_template_id": 460000000052069,
"estimate_template_id": 460000000000179,
"creditnote_template_id": 460000000000211,
"purchaseorder_template_id": 460000000000213,
"salesorder_template_id": 460000000000214,
"retainerinvoice_template_id": 460000000000215,
"paymentthankyou_template_id": 460000000000216,
"retainerinvoice_paymentthankyou_template_id": 460000000000217,
"invoice_email_template_id": 460000000052071,
"estimate_email_template_id": 460000000052073,
"creditnote_email_template_id": 460000000052075,
"purchaseorder_email_template_id": 460000000000218,
"salesorder_email_template_id": 460000000000219,
"retainerinvoice_email_template_id": 460000000000220,
"paymentthankyou_email_template_id": 460000000000221,
"retainerinvoice_paymentthankyou_email_template_id": 460000000000222
},
"notes": "Payment option : Through check",
"created_time": "2013-08-05T12:06:10+0530",
"last_modified_time": "2013-10-07T18:24:51+0530"
}
}
Loading
Loading