diff --git a/components/zoho_books/actions/create-customer-payment/create-customer-payment.mjs b/components/zoho_books/actions/create-customer-payment/create-customer-payment.mjs index 4d94c8e00c936..c69de4f5dd9ae 100644 --- a/components/zoho_books/actions/create-customer-payment/create-customer-payment.mjs +++ b/components/zoho_books/actions/create-customer-payment/create-customer-payment.mjs @@ -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, diff --git a/components/zoho_books/actions/create-customer/create-customer.mjs b/components/zoho_books/actions/create-customer/create-customer.mjs index 2bce073964637..f69996e783820 100644 --- a/components/zoho_books/actions/create-customer/create-customer.mjs +++ b/components/zoho_books/actions/create-customer/create-customer.mjs @@ -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, diff --git a/components/zoho_books/actions/create-employee/create-employee.mjs b/components/zoho_books/actions/create-employee/create-employee.mjs index 9c0c005a67db9..fafb15850b938 100644 --- a/components/zoho_books/actions/create-employee/create-employee.mjs +++ b/components/zoho_books/actions/create-employee/create-employee.mjs @@ -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, diff --git a/components/zoho_books/actions/create-estimate/create-estimate.mjs b/components/zoho_books/actions/create-estimate/create-estimate.mjs index 2e137819a4d85..eb0d0a0534c38 100644 --- a/components/zoho_books/actions/create-estimate/create-estimate.mjs +++ b/components/zoho_books/actions/create-estimate/create-estimate.mjs @@ -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, @@ -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: [ diff --git a/components/zoho_books/actions/create-invoice/create-invoice.mjs b/components/zoho_books/actions/create-invoice/create-invoice.mjs index bcfe3c3f3f043..03920f96abc21 100644 --- a/components/zoho_books/actions/create-invoice/create-invoice.mjs +++ b/components/zoho_books/actions/create-invoice/create-invoice.mjs @@ -6,7 +6,7 @@ export default { 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, diff --git a/components/zoho_books/actions/create-item/create-item.mjs b/components/zoho_books/actions/create-item/create-item.mjs index 85f792da09a8e..57d618d047912 100644 --- a/components/zoho_books/actions/create-item/create-item.mjs +++ b/components/zoho_books/actions/create-item/create-item.mjs @@ -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, diff --git a/components/zoho_books/actions/create-salesorder/create-salesorder.mjs b/components/zoho_books/actions/create-salesorder/create-salesorder.mjs index 47105c681f75b..74c1b3e720a1a 100644 --- a/components/zoho_books/actions/create-salesorder/create-salesorder.mjs +++ b/components/zoho_books/actions/create-salesorder/create-salesorder.mjs @@ -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, diff --git a/components/zoho_books/actions/delete-contact/delete-contact.mjs b/components/zoho_books/actions/delete-contact/delete-contact.mjs index 1813944967478..2df67081d2af9 100644 --- a/components/zoho_books/actions/delete-contact/delete-contact.mjs +++ b/components/zoho_books/actions/delete-contact/delete-contact.mjs @@ -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, diff --git a/components/zoho_books/actions/get-invoice/get-invoice.mjs b/components/zoho_books/actions/get-invoice/get-invoice.mjs index fd5862f4c8b3d..9df10792d87bc 100644 --- a/components/zoho_books/actions/get-invoice/get-invoice.mjs +++ b/components/zoho_books/actions/get-invoice/get-invoice.mjs @@ -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, diff --git a/components/zoho_books/actions/get-item/get-item.mjs b/components/zoho_books/actions/get-item/get-item.mjs index 1e80975355f28..b40be8fe7d9d4 100644 --- a/components/zoho_books/actions/get-item/get-item.mjs +++ b/components/zoho_books/actions/get-item/get-item.mjs @@ -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, diff --git a/components/zoho_books/actions/list-contacts/list-contacts.mjs b/components/zoho_books/actions/list-contacts/list-contacts.mjs index ce1d8e17da69f..9ac978f861cab 100644 --- a/components/zoho_books/actions/list-contacts/list-contacts.mjs +++ b/components/zoho_books/actions/list-contacts/list-contacts.mjs @@ -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, diff --git a/components/zoho_books/actions/list-expenses/list-expenses.mjs b/components/zoho_books/actions/list-expenses/list-expenses.mjs index 66fd2fac864b0..f791f13e031a9 100644 --- a/components/zoho_books/actions/list-expenses/list-expenses.mjs +++ b/components/zoho_books/actions/list-expenses/list-expenses.mjs @@ -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, diff --git a/components/zoho_books/actions/list-invoices/list-invoices.mjs b/components/zoho_books/actions/list-invoices/list-invoices.mjs index ac176923441c9..af606b081e625 100644 --- a/components/zoho_books/actions/list-invoices/list-invoices.mjs +++ b/components/zoho_books/actions/list-invoices/list-invoices.mjs @@ -10,7 +10,7 @@ export default { 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, diff --git a/components/zoho_books/actions/make-api-call/make-api-call.mjs b/components/zoho_books/actions/make-api-call/make-api-call.mjs index 7c1d0c4d5c928..cb7569271a03b 100644 --- a/components/zoho_books/actions/make-api-call/make-api-call.mjs +++ b/components/zoho_books/actions/make-api-call/make-api-call.mjs @@ -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, diff --git a/components/zoho_books/actions/update-salesorder/update-salesorder.mjs b/components/zoho_books/actions/update-salesorder/update-salesorder.mjs index 0f9b94ed28650..75f416b2f44f9 100644 --- a/components/zoho_books/actions/update-salesorder/update-salesorder.mjs +++ b/components/zoho_books/actions/update-salesorder/update-salesorder.mjs @@ -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, diff --git a/components/zoho_books/package.json b/components/zoho_books/package.json index 6c5d0cca37ec9..badbf52c28c48 100644 --- a/components/zoho_books/package.json +++ b/components/zoho_books/package.json @@ -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": [ diff --git a/components/zoho_books/sources/common/base.mjs b/components/zoho_books/sources/common/base.mjs index 11929a8bb4406..3d1123104b99a 100644 --- a/components/zoho_books/sources/common/base.mjs +++ b/components/zoho_books/sources/common/base.mjs @@ -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)); }, }; diff --git a/components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs b/components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs new file mode 100644 index 0000000000000..d9e0566fa5cf7 --- /dev/null +++ b/components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs @@ -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, +}; diff --git a/components/zoho_books/sources/new-customer-instant/test-event.mjs b/components/zoho_books/sources/new-customer-instant/test-event.mjs new file mode 100644 index 0000000000000..9df48f11ae373 --- /dev/null +++ b/components/zoho_books/sources/new-customer-instant/test-event.mjs @@ -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": "willsmith@bowmanfurniture.com", + "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" + } +} \ No newline at end of file diff --git a/components/zoho_books/sources/new-customer/new-customer.mjs b/components/zoho_books/sources/new-customer/new-customer.mjs deleted file mode 100644 index 42e7b48b08a30..0000000000000 --- a/components/zoho_books/sources/new-customer/new-customer.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import common from "../common/base.mjs"; -import sampleEmit from "./test-event.mjs"; - -export default { - ...common, - key: "zoho_books-new-customer", - name: "New Customer", - description: "Emit new event when a new customer is created.", - version: "0.0.1", - type: "source", - dedupe: "unique", - methods: { - ...common.methods, - getFunction() { - return this.zohoBooks.listContacts; - }, - getFieldName() { - return "contacts"; - }, - getFieldId() { - return "contact_id"; - }, - getSummary(item) { - return `New Customer: ${item.contact_name}`; - }, - }, - sampleEmit, -}; diff --git a/components/zoho_books/sources/new-customer/test-event.mjs b/components/zoho_books/sources/new-customer/test-event.mjs deleted file mode 100644 index 2f6b157db1e12..0000000000000 --- a/components/zoho_books/sources/new-customer/test-event.mjs +++ /dev/null @@ -1,20 +0,0 @@ -export default { - "contact_id": 460000000026049, - "contact_name": "Bowman and Co", - "company_name": "Bowman and Co", - "contact_type": "customer", - "status": "active", - "payment_terms": 15, - "payment_terms_label": "Net 15", - "currency_id": 460000000000097, - "currency_code": "USD", - "outstanding_receivable_amount": 250, - "unused_credits_receivable_amount": 1369.66, - "first_name": "Will", - "last_name": "Smith", - "email": "willsmith@bowmanfurniture.com", - "phone": "+1-925-921-9201", - "mobile": "+1-4054439562", - "created_time": "2013-08-05T12:06:10+0530", - "last_modified_time": "2013-10-07T18:24:51+0530" -} \ No newline at end of file diff --git a/components/zoho_books/sources/new-expense/new-expense.mjs b/components/zoho_books/sources/new-expense-instant/new-expense-instant.mjs similarity index 50% rename from components/zoho_books/sources/new-expense/new-expense.mjs rename to components/zoho_books/sources/new-expense-instant/new-expense-instant.mjs index 799e4cf4b6cd4..ef165d3a481ad 100644 --- a/components/zoho_books/sources/new-expense/new-expense.mjs +++ b/components/zoho_books/sources/new-expense-instant/new-expense-instant.mjs @@ -3,25 +3,23 @@ import sampleEmit from "./test-event.mjs"; export default { ...common, - key: "zoho_books-new-expense", - name: "New Expense", + key: "zoho_books-new-expense-instant", + name: "New Expense (Instant)", description: "Emit new event when a new expense is created.", version: "0.0.1", type: "source", dedupe: "unique", methods: { ...common.methods, - getFunction() { - return this.zohoBooks.listExpenses; + getEntity() { + return "expense"; }, - getFieldName() { - return "expenses"; - }, - getFieldId() { - return "expense_id"; - }, - getSummary(item) { - return `New Expense: ${item.expense_id}`; + generateMeta({ expense }) { + return { + id: expense.expense_id, + summary: `New Expense: ${expense.expense_id}`, + ts: Date.parse(expense.created_time), + }; }, }, sampleEmit, diff --git a/components/zoho_books/sources/new-expense-instant/test-event.mjs b/components/zoho_books/sources/new-expense-instant/test-event.mjs new file mode 100644 index 0000000000000..211bc40106c7b --- /dev/null +++ b/components/zoho_books/sources/new-expense-instant/test-event.mjs @@ -0,0 +1,97 @@ +export default { + "expense": { + "expense_id": 982000000030049, + "transaction_id": " ", + "transaction_type": "expense", + "gst_no": "22AAAAA0000A1Z5", + "gst_treatment": "business_gst", + "tax_treatment": "vat_registered", + "destination_of_supply": "TN", + "destination_of_supply_state": "TN", + "place_of_supply": "DU", + "hsn_or_sac": 80540, + "source_of_supply": "AP", + "paid_through_account_name": "Petty Cash", + "vat_reg_no": "string", + "reverse_charge_tax_id": 982000000561063, + "reverse_charge_tax_name": "intra", + "reverse_charge_tax_percentage": 10, + "reverse_charge_tax_amount": 12, + "tax_amount": 11.85, + "is_itemized_expense": false, + "is_pre_gst": "fasle", + "trip_id": "", + "trip_number": "", + "reverse_charge_vat_total": 1.2, + "acquisition_vat_total": 0, + "acquisition_vat_summary": [ + { + "tax": { + "tax_name": "SalesTax", + "tax_amount": 11.85 + } + } + ], + "reverse_charge_vat_summary": [ + { + "tax": { + "tax_name": "SalesTax", + "tax_amount": 11.85 + } + } + ], + "expense_item_id": 982000000567220, + "account_id": 982000000561057, + "account_name": "Rent", + "date": "2013-11-18", + "tax_id": 982000000566007, + "tax_name": "SalesTax", + "tax_percentage": 10.5, + "currency_id": 982000000567001, + "currency_code": "USD", + "exchange_rate": 1, + "sub_total": 90, + "total": 100, + "bcy_total": 100, + "amount": 112.5, + "is_inclusive_tax": false, + "reference_number": null, + "description": "Marketing", + "is_billable": true, + "is_personal": false, + "customer_id": 982000000567001, + "customer_name": "Bowman & Co", + "expense_receipt_name": " ", + "expense_receipt_type": " ", + "last_modified_time": " ", + "status": "unbilled", + "invoice_id": " ", + "invoice_number": " ", + "project_id": 982000000567226, + "project_name": " ", + "mileage_rate": " ", + "mileage_type": "non_mileage", + "expense_type": "non-mileage", + "start_reading": " ", + "end_reading": " ", + "line_item": { + "line_item_id": 10763000000140068, + "account_id": 982000000561057, + "account_name": "Rent", + "description": "Marketing", + "tax_amount": 11.85, + "tax_id": 982000000566007, + "tax_name": "SalesTax", + "tax_type": "tax", + "tax_percentage": 10.5, + "item_total": 100, + "item_order": 1, + "amount": 112.5, + "hsn_or_sac": 80540, + "reverse_charge_tax_id": 982000000561063, + "reverse_charge_tax_name": "intra", + "reverse_charge_tax_percentage": 10, + "reverse_charge_tax_amount": 12 + } + } +} \ No newline at end of file diff --git a/components/zoho_books/sources/new-expense/test-event.mjs b/components/zoho_books/sources/new-expense/test-event.mjs deleted file mode 100644 index 75a5cccedbbdd..0000000000000 --- a/components/zoho_books/sources/new-expense/test-event.mjs +++ /dev/null @@ -1,25 +0,0 @@ -export default { - "expense_id": 982000000030049, - "date": "2013-11-18", - "account_name": "Rent", - "description": "Marketing", - "currency_id": 982000000567001, - "currency_code": "USD", - "bcy_total": 100, - "bcy_total_without_tax": 100, - "total": 100, - "total_without_tax": 100, - "is_billable": true, - "reference_number": null, - "customer_id": 982000000567001, - "customer_name": "Bowman & Co", - "status": "unbilled", - "created_time": "2013-11-18T00:00:00.000Z", - "last_modified_time": " ", - "expense_receipt_name": " ", - "mileage_rate": " ", - "mileage_unit": " ", - "expense_type": "non-mileage", - "start_reading": " ", - "end_reading": " " -} \ No newline at end of file diff --git a/components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs b/components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs new file mode 100644 index 0000000000000..69c8c4e5dbd99 --- /dev/null +++ b/components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs @@ -0,0 +1,26 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "zoho_books-new-sales-order-instant", + name: "New Sales Order (Instant)", + description: "Emit new event when a new sales order is created.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEntity() { + return "salesorder"; + }, + generateMeta({ salesorder }) { + return { + id: salesorder.salesorder_number, + summary: `New Sales Order: ${salesorder.salesorder_number}`, + ts: Date.parse(salesorder.created_time), + }; + }, + }, + sampleEmit, +}; diff --git a/components/zoho_books/sources/new-sales-order-instant/test-event.mjs b/components/zoho_books/sources/new-sales-order-instant/test-event.mjs new file mode 100644 index 0000000000000..b2bd389e6720d --- /dev/null +++ b/components/zoho_books/sources/new-sales-order-instant/test-event.mjs @@ -0,0 +1,110 @@ +export default { + "salesorder": { + "customer_id": "460000000017138", + "billing_address_id": 460000000032174, + "shipping_address_id": "string", + "is_pre_gst": false, + "gst_no": "22AAAAA0000A1Z5", + "gst_treatment": "business_gst", + "place_of_supply": "TN", + "crm_owner_id": "string", + "crm_custom_reference_id": "string", + "zcrm_potential_id": "460000000033001", + "vat_treatment": "string", + "tax_treatment": "vat_registered", + "is_reverse_charge_applied": true, + "is_update_customer": false, + "contact_persons": [ + { + "contact_person_id": "string" + } + ], + "salesorder_number": "SO-00001", + "reference_number": "REF-001", + "template_id": "460000000021001", + "date": "string", + "documents": [ + "document_id", + "file_name" + ], + "shipment_date": "string", + "exchange_rate": 1.233, + "discount": "string", + "is_discount_before_tax": true, + "discount_type": "entity_level", + "salesperson_id": "460000000000097", + "salesperson_name": "John Roberts", + "merchant_id": "460000000000597", + "merchant_name": "John Louis", + "estimate_id": "string", + "tax_id": "460000000017094", + "tax_authority_id": "string", + "tax_authority_name": "string", + "tax_exemption_id": "string", + "tax_exemption_code": "string", + "avatax_exempt_no": "string", + "avatax_use_code": "string", + "is_inclusive_tax": false, + "sub_statuses": [ + { + "status_id": "460000000000097", + "status_code": "cs_openshi", + "parent_status": "open", + "description": "Packed is shipped.", + "display_name": "Open Shipped", + "label_name": "cs_openshi", + "color_code": "208eff" + } + ], + "custom_fields": [ + { + "customfield_id": "460000000639129", + "index": 1, + "value": "Normal", + "label": "Priority" + } + ], + "line_items": [ + { + "line_item_id": "460000000039131", + "sku": "string", + "bcy_rate": 120, + "tax_name": "string", + "tax_type": "string", + "tax_percentage": 0.1, + "tax_id": "460000000017094", + "tds_tax_id": "460000000017098", + "tax_treatment_code": "uae_others", + "is_taxable": false, + "product_exemption_id": "string", + "product_exemption_code": "string", + "avatax_use_code_id": "string", + "avatax_use_code_desc": "string", + "avatax_tax_code_id": "string", + "avatax_tax_code_desc": "string", + "item_total_inclusive_of_tax": 48, + "product_type": "goods", + "hsn_or_sac": 80540, + "sat_item_key_code": 71121206, + "unitkey_code": "E48", + "is_invoiced": false, + "stock_on_hand": "string", + "image_id": "string", + "image_name": "string", + "image_type": "string", + "project_id": 90300000087378, + "project_name": "Sample Project", + "warehouse_id": "460000000041001" + } + ], + "pricebook_id": "string", + "shipping_charge": 2, + "adjustment": 0.2, + "adjustment_description": "Adjustment", + "delivery_method": "Air", + "notes": "string", + "notes_default": "string", + "terms": "string", + "terms_default": "string" + } +} \ No newline at end of file diff --git a/components/zoho_books/sources/new-sales-order/new-sales-order.mjs b/components/zoho_books/sources/new-sales-order/new-sales-order.mjs deleted file mode 100644 index 5078c8b6074be..0000000000000 --- a/components/zoho_books/sources/new-sales-order/new-sales-order.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import common from "../common/base.mjs"; -import sampleEmit from "./test-event.mjs"; - -export default { - ...common, - key: "zoho_books-new-sales-order", - name: "New Sales Order", - description: "Emit new event when a new sales order is created.", - version: "0.0.1", - type: "source", - dedupe: "unique", - methods: { - ...common.methods, - getFunction() { - return this.zohoBooks.listSalesorders; - }, - getFieldName() { - return "salesorders"; - }, - getFieldId() { - return "salesorder_id"; - }, - getSummary(item) { - return `New Sales Order: ${item.salesorder_number}`; - }, - }, - sampleEmit, -}; diff --git a/components/zoho_books/sources/new-sales-order/test-event.mjs b/components/zoho_books/sources/new-sales-order/test-event.mjs deleted file mode 100644 index 4386460147a04..0000000000000 --- a/components/zoho_books/sources/new-sales-order/test-event.mjs +++ /dev/null @@ -1,30 +0,0 @@ -export default { - "salesorder_id": "460000000039129", - "zcrm_potential_id": "460000000033001", - "zcrm_potential_name": "string", - "customer_name": "SAF Instruments Inc", - "customer_id": "460000000017138", - "status": "open", - "salesorder_number": "SO-00001", - "reference_number": "REF-001", - "date": "2014-07-28", - "shipment_date": "string", - "shipment_days": 2, - "currency_id": "460000000000097", - "currency_code": "USD", - "total": 12400, - "sub_total": 11800, - "bcy_total": 400, - "created_time": "2014-07-28T08:29:07+0530", - "last_modified_time": "2014-08-25T11:23:26+0530", - "is_emailed": false, - "has_attachment": false, - "custom_fields": [ - { - "customfield_id": "460000000639129", - "index": 1, - "value": "Normal", - "label": "Priority" - } - ] -} \ No newline at end of file diff --git a/components/zoho_books/zoho_books.app.mjs b/components/zoho_books/zoho_books.app.mjs index 09c5f6ec1cb58..ec98292cf485c 100644 --- a/components/zoho_books/zoho_books.app.mjs +++ b/components/zoho_books/zoho_books.app.mjs @@ -603,6 +603,19 @@ export default { ...opts, }); }, + createWebhook(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/settings/webhooks", + ...opts, + }); + }, + deleteWebhook(webhookId) { + return this._makeRequest({ + method: "DELETE", + path: `/settings/webhooks/${webhookId}`, + }); + }, deleteContact({ customerId, ...opts }) {