From bb67812d33fd1b4fbbdad5fcc08d1d02c922e4ba Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 28 Nov 2024 14:04:56 -0300 Subject: [PATCH 1/9] [Components] zoho-books #14645 - Component refactoring Sources - New Customer - New Expense - New Sales Invoice Actions - Create Customer - Create Estimate --- .../create-customer-payment.mjs | 148 ++-- .../create-customer/create-customer.mjs | 166 ++++ .../create-employee/create-employee.mjs | 34 +- .../create-estimate/create-estimate.mjs | 391 +++++++++ .../actions/create-invoice/create-invoice.mjs | 405 +++++----- .../actions/create-item/create-item.mjs | 167 ++-- .../create-salesorder/create-salesorder.mjs | 523 +++++++----- .../actions/delete-contact/delete-contact.mjs | 42 +- .../actions/get-invoice/get-invoice.mjs | 63 +- .../zoho_books/actions/get-item/get-item.mjs | 41 +- .../actions/list-contacts/list-contacts.mjs | 48 +- .../actions/list-expenses/list-expenses.mjs | 157 ++-- .../actions/list-invoices/list-invoices.mjs | 184 ++--- .../actions/make-api-call/make-api-call.mjs | 40 +- .../update-salesorder/update-salesorder.mjs | 553 +++++++------ components/zoho_books/common/constants.mjs | 196 +++++ components/zoho_books/common/utils.mjs | 41 + components/zoho_books/package.json | 18 + components/zoho_books/sources/common/base.mjs | 60 ++ .../sources/new-customer/new-customer.mjs | 28 + .../sources/new-customer/test-event.mjs | 20 + .../sources/new-expense/new-expense.mjs | 28 + .../sources/new-expense/test-event.mjs | 25 + .../new-sales-order/new-sales-order.mjs | 28 + .../sources/new-sales-order/test-event.mjs | 30 + components/zoho_books/zoho_books.app.mjs | 744 +++++++++++++++++- 26 files changed, 3029 insertions(+), 1151 deletions(-) create mode 100644 components/zoho_books/actions/create-customer/create-customer.mjs create mode 100644 components/zoho_books/actions/create-estimate/create-estimate.mjs create mode 100644 components/zoho_books/common/constants.mjs create mode 100644 components/zoho_books/common/utils.mjs create mode 100644 components/zoho_books/package.json create mode 100644 components/zoho_books/sources/common/base.mjs create mode 100644 components/zoho_books/sources/new-customer/new-customer.mjs create mode 100644 components/zoho_books/sources/new-customer/test-event.mjs create mode 100644 components/zoho_books/sources/new-expense/new-expense.mjs create mode 100644 components/zoho_books/sources/new-expense/test-event.mjs create mode 100644 components/zoho_books/sources/new-sales-order/new-sales-order.mjs create mode 100644 components/zoho_books/sources/new-sales-order/test-event.mjs 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 bd019dddc916d..4d94c8e00c936 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 @@ -1,131 +1,137 @@ // legacy_hash_id: a_XziR2J -import { axios } from "@pipedream/platform"; +import { PAYMENT_MODE_OPTIONS } from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-create-customer-payment", name: "Create Customer Payment", - description: "Creates a new payment.", - version: "0.2.1", + description: "Creates a new payment. [See the documentation](https://www.zoho.com/books/api/v3/customer-payments/#create-a-payment)", + version: "0.3.0", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - customer_id: { - type: "string", - description: "Customer ID of the customer involved in the payment.", - }, - payment_mode: { - type: "string", - description: "Mode through which payment is made. This can be `check`, `cash`, `creditcard`, `banktransfer`, `bankremittance`, `autotransaction` or `others`. Max-length [100]", - options: [ - "check", - "cash", - "creditcard", - "banktransfer", - "bankremittance", - "autotransaction", - "others", + zohoBooks, + customerId: { + propDefinition: [ + zohoBooks, + "customerId", ], }, - invoices: { - type: "any", - description: "List of invoices associated with the payment. Each invoice object contains `invoice_id`, `invoice_number`, `date`, `invoice_amount`, `amount_applied` and `balance_amount`.", + paymentMode: { + type: "string", + label: "Payment Mode", + description: "Mode through which payment is made.", + options: PAYMENT_MODE_OPTIONS, }, amount: { type: "string", + label: "Amount", description: "Amount paid in the respective payment.", }, date: { type: "string", + label: "Date", description: "Date on which payment is made. Format [yyyy-mm-dd]", }, - reference_number: { + referenceNumber: { type: "string", + label: "Reference Number", description: "Reference number generated for the payment. A string of your choice can also be used as the reference number. Max-length [100]", optional: true, }, description: { type: "string", + label: "Description", description: "Description about the payment.", optional: true, }, - exchange_rate: { + invoices: { + type: "string[]", + label: "Invoices", + description: "List of invoice objects associated with the payment. Each invoice object contains `invoice_id`, `invoice_number`, `date`, `invoice_amount`, `amount_applied` and `balance_amount`. **Example: {\"invoice_id\": \"90300000079426\", \"amount_applied\": 450}**", + }, + exchangeRate: { type: "string", + label: "Exchange Rate", description: "Exchange rate for the currency used in the invoices and customer's currency. The payment amount would be the multiplicative product of the original amount and the exchange rate. Default is 1.", optional: true, }, - bank_charges: { + bankCharges: { type: "string", + label: "Bank Charges", description: "Denotes any additional bank charges.", optional: true, }, - custom_fields: { - type: "any", - description: "Additional fields for the payments.", + customFields: { + propDefinition: [ + zohoBooks, + "customFields", + ], + description: "A list of Additional field objects for the payments. **Example: {\"label\": \"label\", \"value\": 129890}**", optional: true, }, - invoice_id: { - type: "string", - description: "ID of the invoice to get payments of.", - optional: true, + invoiceId: { + propDefinition: [ + zohoBooks, + "invoiceId", + ({ customerId }) => ({ + customerId, + }), + ], }, - amount_applied: { + amountApplied: { type: "string", + label: "Amount Applied", description: "Amount paid for the invoice.", optional: true, }, - tax_amount_withheld: { + taxAmountWithheld: { type: "string", + label: "Tax Amount Withheld", description: "Amount withheld for tax.", optional: true, }, - account_id: { - type: "string", - description: "ID of the cash/bank account the payment has to be deposited.", + accountId: { + propDefinition: [ + zohoBooks, + "accountId", + ], optional: true, }, - contact_persons: { - type: "string", - description: "IDs of the contact personsthe thank you mail has to be triggered.", + contactPersons: { + propDefinition: [ + zohoBooks, + "contactPersons", + ({ customerId }) => ({ + customerId, + }), + ], optional: true, }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Customer-Payments_Create_a_payment - - if (!this.organization_id || !this.customer_id || !this.payment_mode || !this.invoices || !this.amount || !this.date) { - throw new Error("Must provide organization_id, customer_id, payment_mode, invoices, amount, and date parameters."); - } - - return await axios($, { - method: "post", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/customerpayments?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = await this.zohoBooks.createCustomerPayment({ + $, data: { - customer_id: this.customer_id, - payment_mode: this.payment_mode, + customer_id: this.customerId, + payment_mode: this.paymentMode, amount: this.amount, date: this.date, - reference_number: this.reference_number, + reference_number: this.referenceNumber, description: this.description, - invoices: this.invoices, - exchange_rate: this.exchange_rate, - bank_charges: this.bank_charges, - custom_fields: this.custom_fields, - invoice_id: this.invoice_id, - amount_applied: this.amount_applied, - tax_amount_withheld: this.tax_amount_withheld, - account_id: this.account_id, - contact_persons: this.contact_persons, + invoices: parseObject(this.invoices), + exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), + bank_charges: this.bankCharges && parseFloat(this.bankCharges), + custom_fields: parseObject(this.customFields), + invoice_id: this.invoiceId, + amount_applied: this.amountApplied && parseFloat(this.amountApplied), + tax_amount_withheld: this.taxAmountWithheld && parseFloat(this.taxAmountWithheld), + account_id: this.accountId, + contact_persons: parseObject(this.contactPersons), }, }); + + $.export("$summary", `Customer payment successfully created with Id: ${response.payment.payment_id}`); + return response; }, }; diff --git a/components/zoho_books/actions/create-customer/create-customer.mjs b/components/zoho_books/actions/create-customer/create-customer.mjs new file mode 100644 index 0000000000000..2bce073964637 --- /dev/null +++ b/components/zoho_books/actions/create-customer/create-customer.mjs @@ -0,0 +1,166 @@ +// legacy_hash_id: a_Xzi1qo +import { + CUSTOMER_SUB_TYPE_OPTIONS, + LANGUAGE_CODE_OPTIONS, +} from "../../common/constants.mjs"; +import { + clearObj, + parseObject, +} from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; + +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", + type: "action", + props: { + zohoBooks, + contactName: { + type: "string", + label: "Contact Name", + description: "Display Name of the contact. Max-length [200].", + }, + companyName: { + type: "string", + label: "Company Name", + description: "Company Name of the contact. Max-length [200].", + optional: true, + }, + website: { + type: "string", + label: "Website", + description: "Website of the contact.", + optional: true, + }, + languageCode: { + type: "string", + label: "Language Code", + description: "The language of a contact.", + options: LANGUAGE_CODE_OPTIONS, + optional: true, + }, + customerSubType: { + type: "string", + label: "Customer Sub Type", + description: "Type of the customer.", + options: CUSTOMER_SUB_TYPE_OPTIONS, + optional: true, + }, + creditLimit: { + type: "string", + label: "Credit Limit", + description: "Credit limit for a customer.", + optional: true, + }, + tags: { + type: "string[]", + label: "Tags", + description: "An array of tag objects. **Example: {\"tag_id\":\"124567890\",\"tag_option_id\":\"1234567890\"}**", + optional: true, + }, + isPortalEnabled: { + type: "boolean", + label: "Is Portal Enabled", + description: "To enable client portal for the contact.", + optional: true, + }, + currencyId: { + propDefinition: [ + zohoBooks, + "currencyId", + ], + optional: true, + }, + paymentTerms: { + propDefinition: [ + zohoBooks, + "paymentTerms", + ], + description: "Net payment term for the customer.", + optional: true, + }, + paymentTermsLabel: { + propDefinition: [ + zohoBooks, + "paymentTermsLabel", + ], + description: "Label for the paymet due details.", + optional: true, + }, + notes: { + propDefinition: [ + zohoBooks, + "notes", + ], + description: "Commennts about the payment made by the contact.", + optional: true, + }, + exchangeRate: { + propDefinition: [ + zohoBooks, + "exchangeRate", + ], + description: "Exchange rate for the opening balance.", + optional: true, + }, + vatTreatment: { + propDefinition: [ + zohoBooks, + "vatTreatment", + ], + optional: true, + }, + gstNo: { + propDefinition: [ + zohoBooks, + "gstNo", + ], + optional: true, + }, + avataxUseCode: { + propDefinition: [ + zohoBooks, + "avataxUseCode", + ], + optional: true, + }, + taxId: { + propDefinition: [ + zohoBooks, + "taxId", + ], + description: "ID of the tax to be associated to the estimate.", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.zohoBooks.createContact({ + $, + data: clearObj({ + contact_name: this.contactName, + company_name: this.companyName, + website: this.website, + language_code: this.languageCode, + contact_type: "customer", + customer_sub_type: this.customerSubType, + credit_limit: this.creditLimit, + tags: parseObject(this.tags), + is_portal_enabled: this.isPortalEnabled, + currency_id: this.currencyId, + payment_terms: this.paymentTerms, + payment_terms_label: this.paymentTermsLabel, + notes: this.notes, + exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), + vat_treatment: this.vatTreatment, + gst_no: this.gstNo, + avatax_use_code: this.avataxUseCode, + tax_id: this.taxId, + }), + }); + + $.export("$summary", `Contact successfully created with Id: ${response.contact.contact_id}`); + return response; + }, +}; diff --git a/components/zoho_books/actions/create-employee/create-employee.mjs b/components/zoho_books/actions/create-employee/create-employee.mjs index f11fe759efd11..9c0c005a67db9 100644 --- a/components/zoho_books/actions/create-employee/create-employee.mjs +++ b/components/zoho_books/actions/create-employee/create-employee.mjs @@ -1,47 +1,35 @@ // legacy_hash_id: a_rJiaL2 -import { axios } from "@pipedream/platform"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-create-employee", name: "Create Employee", - description: "Creates an employee for an expense.", - version: "0.2.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, + zohoBooks, name: { type: "string", + label: "Name", description: "Name of the employee.", }, email: { type: "string", + label: "Email", description: "Email of the employee.", }, }, async run({ $ }) { - // See the API docs: https://www.zoho.com/books/api/v3/#Expenses_Create_an_employee - - if (!this.organization_id || !this.name || !this.email) { - throw new Error("Must provide organization_id, name, and email parameters."); - } - - return await axios($, { - method: "post", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/employees?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = await this.zohoBooks.createEmployee({ + $, data: { name: this.name, email: this.email, }, }); + + $.export("$summary", `Employee successfully created with Id: ${response.employee.employee_id}`); + return response; }, }; diff --git a/components/zoho_books/actions/create-estimate/create-estimate.mjs b/components/zoho_books/actions/create-estimate/create-estimate.mjs new file mode 100644 index 0000000000000..dfdafe1f36010 --- /dev/null +++ b/components/zoho_books/actions/create-estimate/create-estimate.mjs @@ -0,0 +1,391 @@ +// legacy_hash_id: a_Xzi1qo +import { parseObject } from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; + +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/items/#create-an-item)", + version: "0.0.1", + type: "action", + props: { + zohoBooks, + customerId: { + propDefinition: [ + zohoBooks, + "customerId", + ], + }, + currencyId: { + propDefinition: [ + zohoBooks, + "currencyId", + ], + optional: true, + }, + contactPersons: { + propDefinition: [ + zohoBooks, + "contactPersons", + ({ customerId }) => ({ + customerId, + }), + ], + description: "Array if contact person(S) for whom estimate has to be sent.", + optional: true, + }, + templateId: { + propDefinition: [ + zohoBooks, + "pdfTemplateId", + ], + optional: true, + }, + placeOfSupply: { + propDefinition: [ + zohoBooks, + "placeOfSupply", + ], + optional: true, + }, + gstTreatment: { + propDefinition: [ + zohoBooks, + "gstTreatment", + ], + optional: true, + }, + gstNo: { + propDefinition: [ + zohoBooks, + "gstNo", + ], + optional: true, + }, + estimateNumber: { + type: "string", + label: "Estimate Number", + description: "Search estimates by estimate number.", + optional: true, + }, + referenceNumber: { + type: "string", + label: "Reference Number", + description: "Search estimates by reference number.", + optional: true, + }, + date: { + type: "string", + label: "Date", + description: "Search estimates by estimate date.", + optional: true, + }, + expiryDate: { + type: "string", + label: "Expiry Date", + description: "The date of expiration of the estimates.", + optional: true, + }, + exchangeRate: { + propDefinition: [ + zohoBooks, + "exchangeRate", + ], + optional: true, + }, + discount: { + propDefinition: [ + zohoBooks, + "discount", + ], + optional: true, + description: "Discount applied to the invoice. It can be either in % or in amount. e.g. 12.5% or 190. Max-length [100]", + }, + isDiscountBeforeTax: { + propDefinition: [ + zohoBooks, + "isDiscountBeforeTax", + ], + optional: true, + }, + discountType: { + propDefinition: [ + zohoBooks, + "discountType", + ], + optional: true, + }, + isInclusiveTax: { + propDefinition: [ + zohoBooks, + "isInclusiveTax", + ], + optional: true, + }, + customBody: { + propDefinition: [ + zohoBooks, + "customBody", + ], + optional: true, + }, + customSubject: { + propDefinition: [ + zohoBooks, + "customSubject", + ], + optional: true, + }, + salespersonName: { + propDefinition: [ + zohoBooks, + "salespersonName", + ], + optional: true, + }, + customFields: { + propDefinition: [ + zohoBooks, + "customFields", + ], + description: "A list of Additional field objects for the payments. **Example: {\"index\": 1, \"value\": \"value\"}**", + optional: true, + }, + lineItems: { + propDefinition: [ + 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.", + }, + notes: { + propDefinition: [ + zohoBooks, + "notes", + ], + description: "The notes added below expressing gratitude or for conveying some information.", + optional: true, + }, + terms: { + propDefinition: [ + zohoBooks, + "terms", + ], + optional: true, + }, + shippingCharge: { + propDefinition: [ + zohoBooks, + "shippingCharge", + ], + optional: true, + }, + adjustment: { + propDefinition: [ + zohoBooks, + "adjustment", + ], + optional: true, + }, + adjustmentDescription: { + propDefinition: [ + zohoBooks, + "adjustmentDescription", + ], + optional: true, + }, + taxId: { + propDefinition: [ + zohoBooks, + "taxId", + ], + description: "ID of the tax to be associated to the estimate.", + optional: true, + }, + taxExemptionId: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], + optional: true, + }, + taxAuthorityId: { + propDefinition: [ + zohoBooks, + "taxAuthorityId", + ], + optional: true, + }, + avataxUseCode: { + propDefinition: [ + zohoBooks, + "avataxUseCode", + ], + optional: true, + }, + avataxExemptNo: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], + optional: true, + }, + vatTreatment: { + propDefinition: [ + zohoBooks, + "vatTreatment", + ], + optional: true, + }, + taxTreatment: { + propDefinition: [ + zohoBooks, + "taxTreatment", + ], + description: "VAT treatment for the estimate.", + optional: true, + }, + isReverseChargeApplied: { + type: "boolean", + label: "Is Reverse Charge Applied.", + description: "Used to specify whether the transaction is applicable for Domestic Reverse Charge (DRC) or not.", + optional: true, + }, + itemId: { + propDefinition: [ + zohoBooks, + "itemId", + ], + optional: true, + }, + lineItemId: { + type: "string", + label: "Line Item Id", + description: "ID of the line item. Mandatory, if the existing line item has to be updated. If empty, a new line item will be created.", + optional: true, + }, + name: { + type: "string", + label: "Name", + description: "Name of the line item.", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Description of the line item.", + optional: true, + }, + rate: { + type: "string", + label: "Rate", + description: "Rate of the line item.", + optional: true, + }, + unit: { + type: "string", + label: "Unit", + description: "Unit of the line item. E.g. kgs, Nos", + optional: true, + }, + quantity: { + type: "integer", + label: "Quantity", + description: "The quantity of line item.", + optional: true, + }, + projectId: { + type: "string", + label: "Project Id", + description: "Id of the project", + optional: true, + }, + acceptRetainer: { + type: "boolean", + label: "Accept Retainer", + description: "The \"Accept Retainer\" node should be passed for the retainer invoice to be created automatically, provided that the customer has accepted the quote.", + optional: true, + }, + retainerPercentage: { + type: "integer", + label: "Retainer Percentage", + description: "Pass the \"Retainer Percentage\" node to create the retainer invoice automatically.", + min: 1, + max: 100, + optional: true, + }, + send: { + propDefinition: [ + zohoBooks, + "send", + ], + optional: true, + }, + ignoreAutoNumberGeneration: { + propDefinition: [ + zohoBooks, + "ignoreAutoNumberGeneration", + ], + optional: true, + description: "Ignore auto estimate number generation for this estimate. This mandates the estimate number.", + }, + }, + async run({ $ }) { + const response = await this.zohoBooks.createEstimate({ + $, + params: { + send: this.send, + ignore_auto_number_generation: this.ignoreAutoNumberGeneration, + }, + data: { + customer_id: this.customerId, + currency_id: this.currencyId, + contact_persons: parseObject(this.contactPersons), + template_id: this.templateId, + place_of_supply: this.placeOfSupply, + gst_treatment: this.gstTreatment, + gst_no: this.gstNo, + estimate_number: this.estimateNumber, + reference_number: this.referenceNumber, + date: this.date, + expiry_date: this.expiryDate, + exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), + discount: this.discount && parseFloat(this.discount), + is_discount_before_tax: this.isDiscountBeforeTax, + discount_type: this.discountType, + is_inclusive_tax: this.isInclusiveTax, + custom_body: this.customBody, + custom_subject: this.customSubject, + salesperson_name: this.salespersonName, + custom_fields: parseObject(this.customFields), + line_items: parseObject(this.lineItems), + notes: this.notes, + terms: this.terms, + shipping_charge: this.shippingCharge, + adjustment: this.adjustment && parseFloat(this.adjustment), + adjustment_description: this.adjustmentDescription, + tax_id: this.taxId, + tax_exemption_id: this.taxExemptionId, + tax_authority_id: this.taxAuthorityId, + avatax_use_code: this.avataxUseCode, + avatax_exempt_no: this.avataxExemptNo, + vat_treatment: this.vatTreatment, + tax_treatment: this.taxTreatment, + is_reverse_charge_applied: this.isReverseChargeApplied, + item_id: this.itemId, + line_item_id: this.lineItemId, + name: this.name, + description: this.description, + rate: this.rate && parseFloat(this.rate), + unit: this.unit, + quantity: this.quantity, + project_id: this.projectId, + accept_retainer: this.acceptRetainer, + retainer_percentage: this.retainerPercentage, + }, + }); + + $.export("$summary", `Item successfully created with Id: ${response.estimate.estimate_id}`); + return response; + }, +}; diff --git a/components/zoho_books/actions/create-invoice/create-invoice.mjs b/components/zoho_books/actions/create-invoice/create-invoice.mjs index 1ffdc682743b7..d8a75f975223b 100644 --- a/components/zoho_books/actions/create-invoice/create-invoice.mjs +++ b/components/zoho_books/actions/create-invoice/create-invoice.mjs @@ -1,317 +1,334 @@ // legacy_hash_id: a_EVix1V -import { axios } from "@pipedream/platform"; +import { parseObject } from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-create-invoice", name: "Create Invoice", - description: "Creates an invoice for your customer.", - version: "0.2.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - customer_id: { - type: "string", + zohoBooks, + customerId: { + propDefinition: [ + zohoBooks, + "customerId", + ], description: "ID of the customer the invoice has to be created.", }, - line_items: { - type: "any", - description: "Line items of an estimate.", - optional: true, - }, - contact_persons: { - type: "any", - description: "Array of contact person(s) for whom invoice has to be sent.", - optional: true, - }, - invoice_number: { + invoiceNumber: { type: "string", + label: "Invoice Number", description: "Search invoices by invoice number.Variants: `invoice_number_startswith` and `invoice_number_contains`. Max-length [100]", optional: true, }, - place_of_supply: { - type: "string", - description: "Place where the goods/services are supplied to. (If not given, `place of contact` given for the contact will be taken)\nSupported codes for UAE emirates are :\nAbu Dhabi - AB`,\nAjman - `AJ`,\nDubai - `DU`,\nFujairah - `FU`,\nRas al-Khaimah - `RA`,\nSharjah - `SH`,\nUmm al-Quwain - `UM`\nSupported codes for the GCC countries are :\nUnited Arab Emirates - `AE`,\nSaudi Arabia - `SA`,\nBahrain - `BH`,\nKuwait - `KW`,\nOman - `OM`,\nQatar - `QA`.", - optional: true, - }, - vat_treatment: { - type: "string", - description: "Enter vat treatment.", - optional: true, - }, - tax_treatment: { - type: "string", - description: "VAT treatment for the invoice .Choose whether the contact falls under: `vat_registered`, `vat_not_registered`, `gcc_vat_not_registered`, `gcc_vat_registered`, `non_gcc` , `dz_vat_registered` and `dz_vat_not_registered` supported only for UAE.", + placeOfSupply: { + propDefinition: [ + zohoBooks, + "placeOfSupply", + ], optional: true, }, - gst_treatment: { - type: "string", - description: "Choose whether the contact is GST registered/unregistered/consumer/overseas. Allowed values are `business_gst`, `business_none`, `overseas`, `consumer`.", - optional: true, - options: [ - "business_gst", - "business_none", - "overseas", - "consumer", + vatTreatment: { + propDefinition: [ + zohoBooks, + "vatTreatment", ], - }, - gst_no: { - type: "string", - description: "15 digit GST identification number of the customer.", optional: true, }, - reference_number: { + referenceNumber: { type: "string", + label: "Reference Number", description: "The reference number of the invoice.", optional: true, }, - template_id: { - type: "string", - description: "ID of the pdf template associated with the invoice.", + templateId: { + propDefinition: [ + zohoBooks, + "templateId", + ], optional: true, }, date: { type: "string", + label: "Date", description: "Search invoices by invoice date. Default date format is yyyy-mm-dd. `Variants: due_date_start, due_date_end, due_date_before and due_date_after.`", optional: true, }, - payment_terms: { - type: "string", - description: "Payment terms in days e.g. 15, 30, 60. Invoice due date will be calculated based on this. Max-length [100]", + paymentTerms: { + propDefinition: [ + zohoBooks, + "paymentTerms", + ], optional: true, }, - payment_terms_label: { - type: "boolean", - description: "Used to override the default payment terms label. Default value for 15 days is \"Net 15 Days\". Max-length [100]", + paymentTermsLabel: { + propDefinition: [ + zohoBooks, + "paymentTermsLabel", + ], optional: true, }, - due_date: { + dueDate: { type: "string", + label: "Due Date", description: "Search invoices by due date. Default date format is yyyy-mm-dd. `Variants: due_date_start, due_date_end, due_date_before and due_date_after`", optional: true, - options: [ - "entity_level", - "item_level", - ], }, discount: { - type: "boolean", - description: "Discount applied to the invoice. It can be either in % or in amount. e.g. 12.5% or 190. Max-length [100]", + propDefinition: [ + zohoBooks, + "discount", + ], optional: true, + description: "Discount applied to the invoice. It can be either in % or in amount. e.g. 12.5% or 190. Max-length [100]", }, - is_discount_before_tax: { - type: "boolean", - description: "Used to specify how the discount has to applied. Either before or after the calculation of tax.", + isDiscountBeforeTax: { + propDefinition: [ + zohoBooks, + "isDiscountBeforeTax", + ], optional: true, }, - discount_type: { - type: "string", - description: "How the discount is specified. Allowed values: `entity_level` and `item_level`.", + discountType: { + propDefinition: [ + zohoBooks, + "discountType", + ], optional: true, - options: [ - "entity_level", - "item_level", + }, + isInclusiveTax: { + propDefinition: [ + zohoBooks, + "isInclusiveTax", ], + optional: true, }, - is_inclusive_tax: { + exchangeRate: { type: "string", - description: "Used to specify whether the line item rates are inclusive or exclusivr of tax.", + label: "Exchange Rate", + description: "Exchange rate of the currency.", optional: true, }, - exchange_rate: { - type: "any", - description: "Exchange rate of the currency.", + recurringInvoiceId: { + propDefinition: [ + zohoBooks, + "recurringInvoiceId", + ({ customerId }) => ({ + customerId, + }), + ], optional: true, }, - recurring_invoice_id: { + invoicedEstimateId: { type: "string", - description: "ID of the recurring invoice from which the invoice is created.", + label: "Invoiced Estimate Id", + description: "ID of the invoice from which the invoice is created.", optional: true, }, - invoiced_estimate_id: { - type: "string", - description: "The notes added below expressing gratitude or for conveying some information.", + salespersonName: { + propDefinition: [ + zohoBooks, + "salespersonName", + ], optional: true, }, - salesperson_name: { - type: "string", - description: "ID of the invoice from which the invoice is created.", + customFields: { + propDefinition: [ + zohoBooks, + "customFields", + ], + description: "A list of custom fields objects for an invoice. **Example: {\"customfield_id\": 123123, \"value\": \"value\"}**", optional: true, }, - custom_fields: { - type: "any", - description: "Custom fields for an invoice.", + lineItems: { + propDefinition: [ + zohoBooks, + "lineItems", + ], optional: true, + description: "A list of line items objects of an estimate. **Example: {\"item_id\": \"1352827000000156060\", \"notes\": \"note\", \"name\": \"Item name\", \"quantity\": \"1\" }** [See the documentation](https://www.zoho.com/books/api/v3/invoices/#create-an-invoice) for further details.", }, - payment_options: { + paymentOptions: { type: "object", - description: "Payment options for the invoice, online payment gateways and bank accounts. Will be displayed in the pdf.", + label: "Payment Options", + description: "Payment options for the invoice, online payment gateways and bank accounts. Will be displayed in the pdf. **Example: {\"payment_gateways\": [\"configured\": true, \"additional_field1\": \"standard\", \"gateway_name\": \"paypal\"]}** [See the documentation](https://www.zoho.com/books/api/v3/invoices/#create-an-invoice) for further details.", optional: true, }, - allow_partial_payments: { + allowPartialPayments: { type: "boolean", + label: "Allow Partial Payments", description: "Boolean to check if partial payments are allowed for the contact", optional: true, }, - custom_body: { - type: "string", + customBody: { + propDefinition: [ + zohoBooks, + "customBody", + ], optional: true, }, - custom_subject: { - type: "string", + customSubject: { + propDefinition: [ + zohoBooks, + "customSubject", + ], optional: true, }, notes: { - type: "string", + propDefinition: [ + zohoBooks, + "notes", + ], description: "The notes added below expressing gratitude or for conveying some information.", optional: true, }, terms: { - type: "string", - description: "The terms added below expressing gratitude or for conveying some information.", + propDefinition: [ + zohoBooks, + "terms", + ], optional: true, }, - shipping_charge: { - type: "string", - description: "Shipping charges applied to the invoice. Max-length [100]", + shippingCharge: { + propDefinition: [ + zohoBooks, + "shippingCharge", + ], optional: true, }, adjustment: { - type: "string", + propDefinition: [ + zohoBooks, + "adjustment", + ], optional: true, }, - adjustment_description: { - type: "string", - description: "Adjustments made to the invoice.", + adjustmentDescription: { + propDefinition: [ + zohoBooks, + "adjustmentDescription", + ], optional: true, }, reason: { type: "string", + label: "Reason", optional: true, }, - tax_authority_id: { - type: "string", - description: "ID of the tax authority. Tax authority depends on the location of the customer. For example, if the customer is located in NY, then the tax authority is NY tax authority.", - optional: true, - }, - tax_exemption_id: { - type: "string", - description: "ID of the tax exemption.", - optional: true, - }, - avatax_use_code: { - type: "string", - description: "Used to group like customers for exemption purposes. It is a custom value that links customers to a tax rule. Select from Avalara [standard codes][1] or enter a custom code. Max-length [25]", + taxAuthorityId: { + propDefinition: [ + zohoBooks, + "taxAuthorityId", + ], optional: true, }, - avatax_exempt_no: { - type: "string", - description: "Exemption certificate number of the customer. Max-length [25]", + taxExemptionId: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], optional: true, }, - tax_id: { - type: "string", - description: "ID of the tax.", + taxId: { + propDefinition: [ + zohoBooks, + "taxId", + ], optional: true, }, - expense_id: { - type: "string", + expenseId: { + propDefinition: [ + zohoBooks, + "expenseId", + ], optional: true, }, - salesorder_item_id: { + salesorderItemId: { type: "string", + label: "Salesorder Item Id", description: "ID of the sales order line item which is invoices.", optional: true, }, - avatax_tax_code: { + avataxTaxCode: { type: "string", + label: "Avatax Tax Code", description: "A tax code is a unique label used to group Items (products, services, or charges) together. Refer the [link][2] for more deails. Max-length [25]", optional: true, }, - time_entry_ids: { - type: "any", - description: "IDs of the time entries associated with the project.", + timeEntryIds: { + propDefinition: [ + zohoBooks, + "timeEntryIds", + ], optional: true, }, send: { - type: "boolean", - description: "Send the estimate to the contact person(s) associated with the estimate.Allowed Values: `true` and `false`", + propDefinition: [ + zohoBooks, + "send", + ], optional: true, }, - ignore_auto_number_generation: { - type: "boolean", - description: "Ignore auto estimate number generation for this estimate. This mandates the estimate number.", + ignoreAutoNumberGeneration: { + propDefinition: [ + zohoBooks, + "ignoreAutoNumberGeneration", + ], optional: true, + description: "Ignore auto estimate number generation for this estimate. This mandates the estimate number.", }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Invoices_Create_an_invoice - - if (!this.organization_id || !this.customer_id || !this.line_items) { - throw new Error("Must provide organization_id, customer_id, and line_items parameters."); - } - - return await axios($, { - method: "post", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/invoices?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, + const response = await this.zohoBooks.createInvoice({ + $, + params: { + send: this.send, + ignore_auto_number_generation: this.ignoreAutoNumberGeneration, }, data: { - customer_id: this.customer_id, - contact_persons: this.contact_persons, - invoice_number: this.invoice_number, - place_of_supply: this.place_of_supply, - vat_treatment: this.vat_treatment, - tax_treatment: this.tax_treatment, - gst_treatment: this.gst_treatment, - gst_no: this.gst_no, - reference_number: this.reference_number, - template_id: this.template_id, + customer_id: this.customerId, + invoice_number: this.invoiceNumber, + place_of_supply: this.placeOfSupply, + vat_treatment: this.vatTreatment, + reference_number: this.referenceNumber, + template_id: this.templateId, date: this.date, - payment_terms: this.payment_terms, - payment_terms_label: this.payment_terms_label, - due_date: this.due_date, - discount: this.discount, - is_discount_before_tax: this.is_discount_before_tax, - discount_type: this.discount_type, - is_inclusive_tax: this.is_inclusive_tax, - exchange_rate: this.exchange_rate, - recurring_invoice_id: this.recurring_invoice_id, - invoiced_estimate_id: this.invoiced_estimate_id, - salesperson_name: this.salesperson_name, - custom_fields: this.custom_fields, - line_items: this.line_items, - payment_options: this.payment_options, - allow_partial_payments: this.allow_partial_payments, - custom_body: this.custom_body, - custom_subject: this.custom_subject, + payment_terms: this.paymentTerms, + payment_terms_label: this.paymentTermsLabel, + due_date: this.dueDate, + discount: this.discount && parseFloat(this.discount), + is_discount_before_tax: this.isDiscountBeforeTax, + discount_type: this.discountType, + is_inclusive_tax: this.isInclusiveTax, + exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), + recurring_invoice_id: this.recurringInvoiceId, + invoiced_estimate_id: this.invoicedEstimateId, + salesperson_name: this.salespersonName, + custom_fields: parseObject(this.customFields), + line_items: parseObject(this.lineItems), + payment_options: parseObject(this.paymentOptions), + allow_partial_payments: this.allowPartialPayments, + custom_body: this.customBody, + custom_subject: this.customSubject, notes: this.notes, terms: this.terms, - shipping_charge: this.shipping_charge, - adjustment: this.adjustment, - adjustment_description: this.adjustment_description, + shipping_charge: this.shippingCharge && parseFloat(this.shippingCharge), + adjustment: this.adjustment && parseFloat(this.adjustment), + adjustment_description: this.adjustmentDescription, reason: this.reason, - tax_authority_id: this.tax_authority_id, - tax_exemption_id: this.tax_exemption_id, - avatax_use_code: this.avatax_use_code, - avatax_exempt_no: this.avatax_exempt_no, - tax_id: this.tax_id, - expense_id: this.expense_id, - salesorder_item_id: this.salesorder_item_id, - avatax_tax_code: this.avatax_tax_code, - time_entry_ids: this.time_entry_ids, - }, - params: { - send: this.send, - ignore_auto_number_generation: this.ignore_auto_number_generation, + tax_authority_id: this.taxAuthorityId, + tax_exemption_id: this.taxExemptionId, + tax_id: this.taxId, + expense_id: this.expenseId, + salesorder_item_id: this.salesorderItemId, + avatax_tax_code: this.avataxTaxCode, + time_entry_ids: parseObject(this.timeEntryIds), }, }); + + $.export("$summary", `Invoice successfully created with Id: ${response.invoice.invoice_id}`); + return response; }, }; diff --git a/components/zoho_books/actions/create-item/create-item.mjs b/components/zoho_books/actions/create-item/create-item.mjs index aaf62faf17741..6f7d737e94ba4 100644 --- a/components/zoho_books/actions/create-item/create-item.mjs +++ b/components/zoho_books/actions/create-item/create-item.mjs @@ -1,183 +1,178 @@ // legacy_hash_id: a_Xzi1qo -import { axios } from "@pipedream/platform"; +import { + ITEM_TYPE_OPTIONS, PRODUCT_TYPE_OPTIONS, +} from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-create-item", name: "Create Item", - description: "Creates a new item.", - version: "0.2.1", + description: "Creates a new item. [See the documentation](https://www.zoho.com/books/api/v3/items/#create-an-item)", + version: "0.3.0", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, + zohoBooks, name: { type: "string", + label: "Name", description: "Name of the item. Max-length [100]", }, rate: { type: "string", + label: "Rate", description: "Price of the item.", }, description: { type: "string", + label: "Description", description: "Description for the item. Max-length [2000]", optional: true, }, - tax_id: { - type: "string", + taxId: { + propDefinition: [ + zohoBooks, + "taxId", + ], description: "ID of the tax to be associated to the item.", optional: true, }, - tax_percentage: { + taxPercentage: { type: "string", + label: "Tax Percentage", description: "Percent of the tax.", optional: true, }, sku: { type: "string", + label: "SKU", description: "SKU value of item,should be unique throughout the product", optional: true, }, - product_type: { + productType: { type: "string", - description: "Specify the type of an item. Allowed values: `goods` or `service` or `digital_service`.", + label: "Product Type", + description: "Specify the type of an item.", optional: true, - options: [ - "goods", - "service", - "digital_service", - ], + options: PRODUCT_TYPE_OPTIONS, }, - hsn_or_sac: { + hsnOrSac: { type: "string", + label: "HSN Or SAC", description: "HSN Code.", optional: true, }, - is_taxable: { + isTaxable: { type: "boolean", + label: "Is Taxable", description: "Boolean to track the taxability of the item.", optional: true, }, - tax_exemption_id: { + taxExemptionId: { type: "string", + label: "Tax Exemption Id", description: "ID of the tax exemption. Mandatory, if is_taxable is false.", optional: true, }, - account_id: { - type: "string", + accountId: { + propDefinition: [ + zohoBooks, + "accountId", + ], description: "ID of the account to which the item has to be associated with.", optional: true, }, - avatax_tax_code: { + itemType: { type: "string", - description: "A tax code is a unique label used to group Items (products, services, or charges) together. Max-length [25]", + label: "Item Type", + description: "Type of the item. Default value will be sales.", optional: true, + options: ITEM_TYPE_OPTIONS, }, - avatax_use_code: { - type: "string", - description: "Used to group like customers for exemption purposes. It is a custom value that links customers to a tax rule. Select from Avalara [standard codes][1] or enter a custom code. Max-length [25]", - optional: true, - }, - item_type: { - type: "string", - description: "Type of the item. Allowed values: `sales`,`purchases`,`sales_and_purchases` and `inventory`. Default value will be sales.", - optional: true, - options: [ - "sales", - "purchases", - "sales_and_purchases", - "inventory", - ], - }, - purchase_description: { + purchaseDescription: { type: "string", + label: "Purchase Description", description: "Purchase description for the item.", optional: true, }, - purchase_rate: { + purchaseRate: { type: "string", + label: "Purchase Rate", description: "Purchase price of the item.", optional: true, }, - purchase_account_id: { + purchaseAccountId: { type: "string", + label: "Purchase Account Id", description: "ID of the COGS account to which the item has to be associated with. Mandatory, if item_type is purchase / sales and purchase / inventory.", optional: true, }, - inventory_account_id: { + inventoryAccountId: { type: "string", + label: "Inventory Account Id", description: "ID of the stock account to which the item has to be associated with. Mandatory, if item_type is inventory.", optional: true, }, - vendor_id: { + vendorId: { type: "string", + label: "Vendor Id", description: "Preferred vendor ID.", optional: true, }, - reorder_level: { + reorderLevel: { type: "string", + label: "Reorder Level", description: "Reorder level of the item.", optional: true, }, - initial_stock: { + initialStock: { type: "string", + label: "Initial Stock", description: "Opening stock of the item.", optional: true, }, - initial_stock_rate: { + initialStockRate: { type: "string", + label: "Initial Stock Rate", description: "Unit price of the opening stock.", optional: true, }, - item_tax_preferences: { - type: "any", + itemTaxPreferences: { + type: "string[]", + label: "Item Tax Preferences", + desctiption: "A list of item tax objects. **Format: {\"tax_id\":\"12312312031200\",\"tax_specification\":\"intra\"}**", optional: true, }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Items_Create_an_Item - - if (!this.organization_id || !this.name || !this.rate) { - throw new Error("Must provide organization_id, name, and rate parameters."); - } - - return await axios($, { - method: "post", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/items?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = await this.zohoBooks.createItem({ + $, data: { name: this.name, - rate: this.rate, + rate: this.rate && parseFloat(this.rate), description: this.description, - tax_id: this.tax_id, - tax_percentage: this.tax_percentage, + tax_id: this.taxId, + tax_percentage: this.taxPercentage, sku: this.sku, - product_type: this.product_type, - hsn_or_sac: this.hsn_or_sac, - is_taxable: this.is_taxable, - tax_exemption_id: this.tax_exemption_id, - account_id: this.account_id, - avatax_tax_code: this.avatax_tax_code, - avatax_use_code: this.avatax_use_code, - item_type: this.item_type, - purchase_description: this.purchase_description, - purchase_rate: this.purchase_rate, - purchase_account_id: this.purchase_account_id, - inventory_account_id: this.inventory_account_id, - vendor_id: this.vendor_id, - reorder_level: this.reorder_level, - initial_stock: this.initial_stock, - initial_stock_rate: this.initial_stock_rate, - item_tax_preferences: this.item_tax_preferences, + product_type: this.productType, + hsn_or_sac: this.hsnOrSac, + is_taxable: this.isTaxable, + tax_exemption_id: this.taxExemptionId, + account_id: this.accountId, + item_type: this.itemType, + purchase_description: this.purchaseDescription, + purchase_rate: this.purchaseRate, + purchase_account_id: this.purchaseAccountId, + inventory_account_id: this.inventoryAccountId, + vendor_id: this.vendorId, + reorder_level: this.reorderLevel, + initial_stock: this.initialStock, + initial_stock_rate: this.initialStockRate, + item_tax_preferences: parseObject(this.itemTaxPreferences), }, }); + + $.export("$summary", `Item successfully created with Id: ${response.item.item_id}`); + return response; }, }; diff --git a/components/zoho_books/actions/create-salesorder/create-salesorder.mjs b/components/zoho_books/actions/create-salesorder/create-salesorder.mjs index 5536a9d17774d..47105c681f75b 100644 --- a/components/zoho_books/actions/create-salesorder/create-salesorder.mjs +++ b/components/zoho_books/actions/create-salesorder/create-salesorder.mjs @@ -1,333 +1,438 @@ // legacy_hash_id: a_WYi46K -import { axios } from "@pipedream/platform"; +import { + clearObj, parseObject, +} from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-create-salesorder", name: "Create Sales Order", - description: "Creates a sales order.", - version: "0.2.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - customer_id: { - type: "string", + zohoBooks, + customerId: { + propDefinition: [ + zohoBooks, + "customerId", + ], description: "ID of the customer to whom the sales order has to be created.", }, - line_items: { - type: "any", - description: "Line items of a sales order.", - optional: true, - }, - contact_persons: { - type: "any", - description: "Array of contact person(s) for whom sales order has to be sent.", + contactPersons: { + propDefinition: [ + zohoBooks, + "contactPersons", + ({ customerId }) => ({ + customerId, + }), + ], + description: "A list of contact person(s) for whom sales order has to be sent.", optional: true, }, date: { - type: "string", - description: "The date, the sales order is created.", + propDefinition: [ + zohoBooks, + "date", + ], optional: true, }, - shipment_date: { - type: "string", - description: "Shipping date of sales order.", + shipmentDate: { + propDefinition: [ + zohoBooks, + "shipmentDate", + ], optional: true, }, - custom_fields: { - type: "any", - description: "Custom fields for a sales order.", + customFields: { + propDefinition: [ + zohoBooks, + "customFields", + ], optional: true, }, - place_of_supply: { - type: "string", - description: "Place where the goods/services are supplied to. (If not given, `place of contact` given for the contact will be taken)\nSupported codes for UAE emirates are :\nAbu Dhabi - AB`,\nAjman - `AJ`,\nDubai - `DU`,\nFujairah - `FU`,\nRas al-Khaimah - `RA`,\nSharjah - `SH`,\nUmm al-Quwain - `UM`\nSupported codes for the GCC countries are :\nUnited Arab Emirates - `AE`,\nSaudi Arabia - `SA`,\nBahrain - `BH`,\nKuwait - `KW`,\nOman - `OM`,\nQatar - `QA`.", + placeOfSupply: { + propDefinition: [ + zohoBooks, + "placeOfSupply", + ], optional: true, }, - salesperson_id: { - type: "string", - description: "ID of the salesperson.", + salespersonId: { + propDefinition: [ + zohoBooks, + "salespersonId", + ], optional: true, }, - merchant_id: { - type: "string", - description: "ID of the merchant.", + merchantId: { + propDefinition: [ + zohoBooks, + "merchantId", + ], optional: true, }, - gst_treatment: { - type: "string", - description: "Choose whether the contact is GST registered/unregistered/consumer/overseas. Allowed values are `business_gst`, `business_none`, `overseas`, `consumer`.", + gstTreatment: { + propDefinition: [ + zohoBooks, + "gstTreatment", + ], optional: true, }, - gst_no: { - type: "string", - description: "15 digit GST identification number of the customer.", + gstNo: { + propDefinition: [ + zohoBooks, + "gstNo", + ], optional: true, }, - is_inclusive_tax: { - type: "boolean", - description: "Used to specify whether the line item rates are inclusive or exclusive of tax.", + isInclusiveTax: { + propDefinition: [ + zohoBooks, + "isInclusiveTax", + ], optional: true, }, + lineItems: { + propDefinition: [ + zohoBooks, + "lineItems", + ], + }, notes: { - type: "string", - description: "Notes for this Sales Order.", + propDefinition: [ + zohoBooks, + "notes", + ], optional: true, }, terms: { - type: "string", + propDefinition: [ + zohoBooks, + "terms", + ], optional: true, }, - billing_address_id: { - type: "string", - description: "ID of the Billing Address", + billingAddressId: { + propDefinition: [ + zohoBooks, + "billingAddressId", + ], optional: true, }, - shipping_address_id: { - type: "string", - description: "ID of the Shipping Address.", + shippingAddressId: { + propDefinition: [ + zohoBooks, + "shippingAddressId", + ], optional: true, }, - crm_owner_id: { - type: "string", + crmOwnerId: { + propDefinition: [ + zohoBooks, + "crmOwnerId", + ], optional: true, }, - crm_custom_reference_id: { - type: "string", + crmCustomReferenceId: { + propDefinition: [ + zohoBooks, + "crmCustomReferenceId", + ], optional: true, }, - vat_treatment: { - type: "string", - description: "Enter vat treatment.", + vatTreatment: { + propDefinition: [ + zohoBooks, + "vatTreatment", + ], optional: true, }, - tax_treatment: { - type: "string", - description: "VAT treatment for the invoice .Choose whether the contact falls under: `vat_registered`, `vat_not_registered`, `gcc_vat_not_registered`, `gcc_vat_registered`, `non_gcc` , `dz_vat_registered` and `dz_vat_not_registered` supported only for UAE.", + taxTreatment: { + propDefinition: [ + zohoBooks, + "taxTreatment", + ], optional: true, }, - salesorder_number: { - type: "string", - description: "Mandatory if auto number generation is disabled.", + salesorderNumber: { + propDefinition: [ + zohoBooks, + "salesorderNumber", + ], optional: true, }, - reference_number: { - type: "string", - description: "**For Customer Only** : If a contact is assigned to any particular user, that user can manage transactions for the contact", + referenceNumber: { + propDefinition: [ + zohoBooks, + "referenceNumber", + ], optional: true, }, - is_update_customer: { - type: "boolean", - description: "Boolean to update billing address of customer.", + isUpdateCustomer: { + propDefinition: [ + zohoBooks, + "isUpdateCustomer", + ], optional: true, }, discount: { - type: "string", - description: "Discount applied to the sales order. It can be either in % or in amount. e.g. 12.5% or 190.", + propDefinition: [ + zohoBooks, + "discount", + ], optional: true, }, - exchange_rate: { - type: "string", - description: "Exchange rate of the currency.", + exchangeRate: { + propDefinition: [ + zohoBooks, + "exchangeRate", + ], optional: true, }, - salesperson_name: { - type: "string", - description: "Name of the sales person.", + salespersonName: { + propDefinition: [ + zohoBooks, + "salespersonName", + ], optional: true, }, - notes_default: { - type: "string", - description: "Default Notes for the Sales Order", + notesDefault: { + propDefinition: [ + zohoBooks, + "notesDefault", + ], optional: true, }, - terms_default: { - type: "string", - description: "Default Terms of the Sales Order.", + termsDefault: { + propDefinition: [ + zohoBooks, + "termsDefault", + ], optional: true, }, - tax_id: { - type: "string", - description: "Tax ID for the Sales Order.", + taxId: { + propDefinition: [ + zohoBooks, + "taxId", + ], optional: true, }, - tax_authority_id: { - type: "string", - description: "ID of the tax authority. Tax authority depends on the location of the customer.", + taxAuthorityId: { + propDefinition: [ + zohoBooks, + "taxAuthorityId", + ], optional: true, }, - tax_exemption_id: { - type: "string", - description: "ID of the tax exemption applied.", + taxExemptionId: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], optional: true, }, - tax_authority_name: { - type: "string", - description: "Tax Authority's name.", + taxAuthorityName: { + propDefinition: [ + zohoBooks, + "taxAuthorityName", + ], optional: true, }, - tax_exemption_code: { - type: "string", - description: "Code of Tax Exemption that is applied.", + taxExemptionCode: { + propDefinition: [ + zohoBooks, + "taxExemptionCode", + ], optional: true, }, - avatax_exempt_no: { - type: "string", - description: "Exemption certificate number of the customer.", + avataxExemptNo: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], optional: true, }, - avatax_use_code: { - type: "string", - description: "Used to group like customers for exemption purposes. It is a custom value that links customers to a tax rule.", + avataxUseCode: { + propDefinition: [ + zohoBooks, + "avataxUseCode", + ], optional: true, }, - shipping_charge: { - type: "string", + shippingCharge: { + propDefinition: [ + zohoBooks, + "shippingCharge", + ], optional: true, }, adjustment: { - type: "string", + propDefinition: [ + zohoBooks, + "adjustment", + ], optional: true, }, - delivery_method: { - type: "string", + adjustmentDescription: { + propDefinition: [ + zohoBooks, + "adjustmentDescription", + ], optional: true, }, - estimate_id: { - type: "string", - description: "ID of the estimate associated with the Sales Order.", + deliveryMethod: { + propDefinition: [ + zohoBooks, + "deliveryMethod", + ], optional: true, }, - is_discount_before_tax: { - type: "boolean", - description: "Used to specify how the discount has to applied. Either before or after the calculation of tax.", + estimateId: { + type: "string", + label: "Estimate Id", + description: "ID of the estimate associated with the Sales Order.", optional: true, }, - discount_type: { - type: "string", - description: "How the discount is specified. Allowed values are entity_level or item_level. Allowed Values: `entity_level` and `item_level`.", + isDiscountBeforeTax: { + propDefinition: [ + zohoBooks, + "isDiscountBeforeTax", + ], optional: true, }, - adjustment_description: { - type: "string", + discountType: { + propDefinition: [ + zohoBooks, + "discountType", + ], optional: true, }, - pricebook_id: { - type: "string", + pricebookId: { + propDefinition: [ + zohoBooks, + "pricebookId", + ], optional: true, }, - template_id: { - type: "string", - description: "ID of the pdf template.", + templateId: { + propDefinition: [ + zohoBooks, + "pdfTemplateId", + ], optional: true, }, documents: { - type: "any", + propDefinition: [ + zohoBooks, + "documents", + ], optional: true, }, - zcrm_potential_id: { - type: "string", + zcrmPotentialId: { + propDefinition: [ + zohoBooks, + "zcrmPotentialId", + ], optional: true, }, - zcrm_potential_name: { - type: "string", + zcrmPotentialName: { + propDefinition: [ + zohoBooks, + "zcrmPotentialName", + ], optional: true, }, - ignore_auto_number_generation: { - type: "string", - description: "Ignore auto sales order number generation for this sales order. This mandates the sales order number.", + ignoreAutoNumberGeneration: { + propDefinition: [ + zohoBooks, + "ignoreAutoNumberGeneration", + ], optional: true, }, - can_send_in_mail: { - type: "string", - description: "Can the file be sent in mail.", + canSendInMail: { + propDefinition: [ + zohoBooks, + "canSendInMail", + ], optional: true, }, totalFiles: { - type: "string", - description: "Total number of files.", + propDefinition: [ + zohoBooks, + "totalFiles", + ], optional: true, }, doc: { - type: "string", - description: "Document that is to be attached", + propDefinition: [ + zohoBooks, + "doc", + ], optional: true, }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Sales-Order_Create_a_sales_order - - if (!this.organization_id || !this.customer_id || !this.line_items) { - throw new Error("Must provide organization_id, customer_id, and line_items parameters."); - } - - return await axios($, { - method: "post", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/salesorders?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, - data: { - customer_id: this.customer_id, - contact_persons: this.contact_persons, + const response = await this.zohoBooks.createSalesorder({ + $, + params: clearObj({ + ignore_auto_number_generation: this.ignoreAutoNumberGeneration, + can_send_in_mail: this.canSendInMail, + totalFiles: this.totalFiles, + doc: this.doc, + }), + data: clearObj({ + customer_id: this.customerId, + contact_persons: this.contactPersons, date: this.date, - shipment_date: this.shipment_date, - custom_fields: this.custom_fields, - place_of_supply: this.place_of_supply, - salesperson_id: this.salesperson_id, - merchant_id: this.merchant_id, - gst_treatment: this.gst_treatment, - gst_no: this.gst_no, - is_inclusive_tax: this.is_inclusive_tax, - line_items: this.line_items, + shipment_date: this.shipmentDate, + custom_fields: parseObject(this.customFields), + place_of_supply: this.placeOfSupply, + salesperson_id: this.salespersonId, + merchant_id: this.merchantId, + gst_treatment: this.gstTreatment, + gst_no: this.gstNo, + is_inclusive_tax: this.isInclusiveTax, + line_items: parseObject(this.lineItems), notes: this.notes, terms: this.terms, - billing_address_id: this.billing_address_id, - shipping_address_id: this.shipping_address_id, - crm_owner_id: this.crm_owner_id, - crm_custom_reference_id: this.crm_custom_reference_id, - vat_treatment: this.vat_treatment, - tax_treatment: this.tax_treatment, - salesorder_number: this.salesorder_number, - reference_number: this.reference_number, - is_update_customer: this.is_update_customer, + billing_address_id: this.billingAddressId, + shipping_address_id: this.shippingAddressId, + crm_owner_id: this.crmOwnerId, + crm_custom_reference_id: this.crmCustomReferenceId, + vat_treatment: this.vatTreatment, + tax_treatment: this.taxTreatment, + salesorder_number: this.salesorderNumber, + reference_number: this.referenceNumber, + is_update_customer: this.isUpdateCustomer, discount: this.discount, - exchange_rate: this.exchange_rate, - salesperson_name: this.salesperson_name, - notes_default: this.notes_default, - terms_default: this.terms_default, - tax_id: this.tax_id, - tax_authority_id: this.tax_authority_id, - tax_exemption_id: this.tax_exemption_id, - tax_authority_name: this.tax_authority_name, - tax_exemption_code: this.tax_exemption_code, - avatax_exempt_no: this.avatax_exempt_no, - avatax_use_code: this.avatax_use_code, - shipping_charge: this.shipping_charge, - adjustment: this.adjustment, - delivery_method: this.delivery_method, - estimate_id: this.estimate_id, - is_discount_before_tax: this.is_discount_before_tax, - discount_type: this.discount_type, - adjustment_description: this.adjustment_description, - pricebook_id: this.pricebook_id, - template_id: this.template_id, - documents: this.documents, - zcrm_potential_id: this.zcrm_potential_id, - zcrm_potential_name: this.zcrm_potential_name, - }, - params: { - ignore_auto_number_generation: this.ignore_auto_number_generation, - can_send_in_mail: this.can_send_in_mail, - totalFiles: this.totalFiles, - doc: this.doc, - }, + exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), + salesperson_name: this.salespersonName, + notes_default: this.notesDefault, + terms_default: this.termsDefault, + tax_id: this.taxId, + tax_authority_id: this.taxAuthorityId, + tax_exemption_id: this.taxExemptionId, + tax_authority_name: this.taxAuthorityName, + tax_exemption_code: this.taxExemptionCode, + avatax_exempt_no: this.avataxExemptNo, + avatax_use_code: this.avataxUseCode, + shipping_charge: this.shippingCharge && parseFloat(this.shippingCharge), + adjustment: this.adjustment && parseFloat(this.adjustment), + delivery_method: this.deliveryMethod, + estimate_id: this.estimateId, + is_discount_before_tax: this.isDiscountBeforeTax, + discount_type: this.discountType, + adjustment_description: this.adjustmentDescription, + pricebook_id: this.pricebookId, + template_id: this.templateId, + documents: parseObject(this.documents), + zcrm_potential_id: this.zcrmPotentialId, + zcrm_potential_name: this.zcrmPotentialName, + }), }); + + $.export("$summary", `Salesorder successfully created with Id: ${response.salesorder.salesorder_id}`); + return response; }, }; diff --git a/components/zoho_books/actions/delete-contact/delete-contact.mjs b/components/zoho_books/actions/delete-contact/delete-contact.mjs index b1cd312c7baaa..1813944967478 100644 --- a/components/zoho_books/actions/delete-contact/delete-contact.mjs +++ b/components/zoho_books/actions/delete-contact/delete-contact.mjs @@ -1,39 +1,29 @@ // legacy_hash_id: a_Lgiern -import { axios } from "@pipedream/platform"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-delete-contact", name: "Delete Contact", - description: "Deletes an existing contact.", - version: "0.2.1", + description: "Deletes an existing contact. [See the documentation](https://www.zoho.com/books/api/v3/contacts/#delete-a-contact)", + version: "0.3.0", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - contact_id: { - type: "string", - description: "ID of the contact to delete.", + zohoBooks, + customerId: { + propDefinition: [ + zohoBooks, + "customerId", + ], + description: "The Id of the contact which will be deleted.", }, }, async run({ $ }) { - // See the API docs: https://www.zoho.com/books/api/v3/#Contacts_Delete_a_Contact - - if (!this.organization_id || !this.contact_id) { - throw new Error("Must provide organization_id, and contact_id parameters."); - } - - return await axios($, { - method: "delete", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/contacts/${this.contact_id}?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = await this.zohoBooks.deleteContact({ + $, + customerId: this.customerId, }); + + $.export("$summary", `Contact successfully deleted with Id: ${this.customerId}`); + return response; }, }; diff --git a/components/zoho_books/actions/get-invoice/get-invoice.mjs b/components/zoho_books/actions/get-invoice/get-invoice.mjs index 103806175eaef..fd5862f4c8b3d 100644 --- a/components/zoho_books/actions/get-invoice/get-invoice.mjs +++ b/components/zoho_books/actions/get-invoice/get-invoice.mjs @@ -1,64 +1,41 @@ // legacy_hash_id: a_Mdie64 -import { axios } from "@pipedream/platform"; +import { PRINT_OPTIONS } from "../../common/constants.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-get-invoice", name: "Get Invoice", - description: "Gets the details of an invoice.", - version: "0.2.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - invoice_id: { - type: "string", + zohoBooks, + invoiceId: { + propDefinition: [ + zohoBooks, + "invoiceId", + ], description: "ID of the invoice to get details.", }, print: { type: "string", - description: "Print the exported pdf. Allowed Values: `true`, `false`, `on` and `off`", - optional: true, - options: [ - "true", - "false", - "on", - "off", - ], - }, - accept: { - type: "string", - description: "Get the details of a particular invoice in formats such as json/ pdf/ html. Default format is json. Allowed values: `json`, `pdf`, and `html`.", + label: "Print", + description: "Print the exported pdf.", + options: PRINT_OPTIONS, optional: true, - options: [ - "json", - "pdf", - "html", - ], }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Invoices_Get_an_invoice - - if (!this.organization_id || !this.invoice_id) { - throw new Error("Must provide organization_id, and invoice_id parameters."); - } - - return await axios($, { - method: "get", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/invoices/${this.invoice_id}?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = await this.zohoBooks.getInvoice({ + $, + invoiceId: this.invoiceId, params: { print: this.print, - accept: this.accept, + accept: "json", }, }); + + $.export("$summary", `Successfully fetched invoice with Id: ${this.invoiceId}`); + return response; }, }; diff --git a/components/zoho_books/actions/get-item/get-item.mjs b/components/zoho_books/actions/get-item/get-item.mjs index 5320d0a209d31..1e80975355f28 100644 --- a/components/zoho_books/actions/get-item/get-item.mjs +++ b/components/zoho_books/actions/get-item/get-item.mjs @@ -1,39 +1,28 @@ // legacy_hash_id: a_wdiVqz -import { axios } from "@pipedream/platform"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-get-item", name: "Get Item", - description: "Gets the details of an existing item.", - version: "0.2.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - item_id: { - type: "string", - description: "ID of the item to get details.", + zohoBooks, + itemId: { + propDefinition: [ + zohoBooks, + "itemId", + ], }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Items_Get_an_item - - if (!this.organization_id || !this.item_id) { - throw new Error("Must provide organization_id, and item_id parameters."); - } - - return await axios($, { - method: "get", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/items/${this.item_id}?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = await this.zohoBooks.getItem({ + $, + itemId: this.itemId, }); + + $.export("$summary", `Successfully fetched item with Id: ${this.itemId}`); + return response; }, }; diff --git a/components/zoho_books/actions/list-contacts/list-contacts.mjs b/components/zoho_books/actions/list-contacts/list-contacts.mjs index 8ff3a06bef155..ce1d8e17da69f 100644 --- a/components/zoho_books/actions/list-contacts/list-contacts.mjs +++ b/components/zoho_books/actions/list-contacts/list-contacts.mjs @@ -1,45 +1,27 @@ // legacy_hash_id: a_RAiV28 -import { axios } from "@pipedream/platform"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-list-contacts", name: "List Contacts", - description: "Lists all contacts given the organization_id.", - version: "0.4.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - page: { - type: "string", - description: "By default first page will be listed. For navigating through pages, use the `page` parameter.", - optional: true, - }, - per_page: { - type: "string", - description: "The `per_page` parameter can be used to set the number of records that you want to receive in response.", - optional: true, - }, + zohoBooks, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Contacts_List_Contacts - - return await axios($, { - method: "get", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/contacts?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, - params: { - page: this.page, - per_page: this.per_page, - }, + const response = this.zohoBooks.paginate({ + fn: this.zohoBooks.listContacts, + fieldName: "contacts", }); + + const responseArray = []; + for await (const item of response) { + responseArray.push(item); + } + + $.export("$summary", `Successfully fetched ${responseArray.length} item(s)`); + return responseArray; }, }; diff --git a/components/zoho_books/actions/list-expenses/list-expenses.mjs b/components/zoho_books/actions/list-expenses/list-expenses.mjs index 676f559832910..66fd2fac864b0 100644 --- a/components/zoho_books/actions/list-expenses/list-expenses.mjs +++ b/components/zoho_books/actions/list-expenses/list-expenses.mjs @@ -1,163 +1,142 @@ -// legacy_hash_id: a_gnir81 -import { axios } from "@pipedream/platform"; +// legacy_hash_id: a_gnir81// legacy_hash_id: a_RAiV28 +import { + FILTER_BY_OPTIONS, + SORT_COLUMN_OPTIONS, + STATUS_OPTIONS, +} from "../../common/constants.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-list-expenses", name: "List Expenses", - description: "List all the Expenses.", - version: "0.2.1", + description: "List all the Expenses. [See the documentation](https://www.zoho.com/books/api/v3/expenses/#list-expenses)", + version: "0.3.0", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, + zohoBooks, description: { type: "string", + label: "Description", description: "Search expenses by description.Variants `description_startswith` and `description_contains`. Max-length [100]", optional: true, }, - reference_number: { + referenceNumber: { type: "string", + label: "Reference Number", description: "Search expenses by reference number. Variants `reference_number_startswith` and `reference_number_contains`. Max-length [100]", optional: true, }, date: { type: "string", + label: "Date", description: "Search expenses by expense date. Variants `date_start`, `date_end`, `date_before` and `date_after`. Format [yyyy-mm-dd]", optional: true, }, status: { type: "string", - description: "Search expenses by expense status. Allowed Values `unbilled`, `invoiced`, `reimbursed`, `non-billable` and `billable`.", + label: "Status", + description: "Search expenses by expense status.", + options: STATUS_OPTIONS, optional: true, - options: [ - "unbilled", - "invoiced", - "reimbursed", - "non-billable", - "billable", - ], }, amount: { type: "string", - description: "Search expenses by amount. Variants: `amount_less_than`, `amount_less_equals`, `amount_greater_than` and `amount_greater_than`.", + label: "Amount", + description: "Search expenses by amount.", optional: true, }, - account_name: { + accountName: { type: "string", - description: "Search expenses by expense account name. Variants `account_name_startswith` and `account_name_contains`. Max-length [100", + label: "Account Name", + description: "Search expenses by expense account name. Max-length [100]", optional: true, }, - customer_name: { + customerName: { type: "string", - description: "Search expenses by customer name. Variants: `customer_name_startswith` and `customer_name_contains`. Max-length [100]", + label: "Customer Name", + description: "Search expenses by customer name. Max-length [100]", optional: true, }, - vendor_name: { + vendorName: { type: "string", - description: "Search expenses by vendor name. Variants: `vendor_name_startswith` and `vendor_name_contains`.", + label: "Vendor Name", + description: "Search expenses by vendor name.", optional: true, }, - customer_id: { + customerId: { type: "string", + label: "Customer Id", description: "ID of the expense account.", optional: true, }, - vendor_id: { + vendorId: { type: "string", + label: "Vendor Id", description: "ID of the vendor the expense is made.", optional: true, }, - recurring_expense_id: { + recurringExpenseId: { type: "string", + label: "Recurring Expense Id", description: "Search expenses by recurring expense id.", optional: true, }, - paid_through_account_id: { + paidThroughAccountId: { type: "string", + label: "Paid Through Account Id", description: "Search expenses by paid through account id.", optional: true, }, - search_text: { + searchText: { type: "string", + label: "Search Text", description: "Search expenses by account name or description or `customer name` or `vendor name`. Max-length [100]", optional: true, }, - sort_column: { - type: "string", - description: "Sort expenses.Allowed Values `date`, `account_name`, `total`, `bcy_total`, `reference_number`, `customer_name` and `created_time`.", - optional: true, - options: [ - "date", - "account_name", - "total", - "bcy_total", - "reference_number", - "customer_name", - "created_time", - ], - }, - filter_by: { - type: "string", - description: "Filter expenses by expense status. Allowed Values `Status.All`, `Status.Billable`, `Status.Nonbillable`, `Status.Reimbursed`, `Status.Invoiced` and `Status.Unbilled`.", - optional: true, - options: [ - "Status.All", - "Status.Billable", - "Status.Nonbillable", - "Status.Reimbursed", - "Status.Invoiced", - "Status.Unbilled", - ], - }, - page: { + sortColumn: { type: "string", - description: "By default first page will be listed. For navigating through `pages`, use the `page` parameter.", + label: "Sort Column", + description: "Sort expenses.", optional: true, + options: SORT_COLUMN_OPTIONS, }, - per_page: { + filterBy: { type: "string", - description: "The `per_page` parameter can be used to set the number of records that you want to receive in response.", + label: "Filter By", + description: "Filter expenses by expense status.", optional: true, + options: FILTER_BY_OPTIONS, }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Expenses_List_Expenses - - if (!this.organization_id) { - throw new Error("Must provide organization_id parameters."); - } - - return await axios($, { - method: "get", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/expenses?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = this.zohoBooks.paginate({ + fn: this.zohoBooks.listExpenses, + fieldName: "expenses", params: { description: this.description, - reference_number: this.reference_number, + reference_number: this.referenceNumber, date: this.date, status: this.status, amount: this.amount, - account_name: this.account_name, - customer_name: this.customer_name, - vendor_name: this.vendor_name, - customer_id: this.customer_id, - vendor_id: this.vendor_id, - recurring_expense_id: this.recurring_expense_id, - paid_through_account_id: this.paid_through_account_id, - search_text: this.search_text, - sort_column: this.sort_column, - filter_by: this.filter_by, - page: this.page, - per_page: this.per_page, + account_name: this.accountName, + customer_name: this.customerName, + vendor_name: this.vendorName, + customer_id: this.customerId, + vendor_id: this.vendorId, + recurring_expense_id: this.recurringExpenseId, + paid_through_account_id: this.paidThroughAccountId, + search_text: this.searchText, + sort_column: this.sortColumn, + filter_by: this.filterBy, }, }); + + const responseArray = []; + for await (const item of response) { + responseArray.push(item); + } + + $.export("$summary", `Successfully fetched ${responseArray.length} expenses(s)`); + return responseArray; }, }; diff --git a/components/zoho_books/actions/list-invoices/list-invoices.mjs b/components/zoho_books/actions/list-invoices/list-invoices.mjs index 48fd06679d9d1..ac176923441c9 100644 --- a/components/zoho_books/actions/list-invoices/list-invoices.mjs +++ b/components/zoho_books/actions/list-invoices/list-invoices.mjs @@ -1,193 +1,169 @@ -// legacy_hash_id: a_PNin2N -import { axios } from "@pipedream/platform"; +// legacy_hash_id: a_PNin2N// legacy_hash_id: a_RAiV28 +import { + INVOICE_FILTER_BY_OPTIONS, + INVOICE_SORT_COLUMN_OPTIONS, + INVOICE_STATUS_OPTIONS, +} from "../../common/constants.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-list-invoices", name: "List Invoices", - description: "Lists all invoices with pagination.", - version: "0.2.1", + description: "Lists all invoices. [See the documentation](https://www.zoho.com/books/api/v3/contacts/#list-contacts)", + version: "0.3.0", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - invoice_number: { + zohoBooks, + invoiceNumber: { type: "string", - description: "Search invoices by invoice number.Variants: `invoice_number_startswith` and `invoice_number_contains`. Max-length [100]", + label: "Invoice Number", + description: "Search invoices by invoice number. Max-length [100]", optional: true, }, - item_name: { + itemName: { type: "string", - description: "Search invoices by item name. Variants: `item_name_startswith` and `item_name_contains`. Max-length [100]", + label: "Item Name", + description: "Search invoices by item name. Max-length [100]", optional: true, }, - item_id: { + itemId: { type: "string", + label: "Item Id", description: "Search invoices by item id.", optional: true, }, - item_description: { + itemDescription: { type: "string", - description: "Search invoices by item description. Variants: `item_description_startswith` and `item_description_contains`. Max-length [100]", + label: "Item Description", + description: "Search invoices by item description. Max-length [100]", optional: true, }, - reference_number: { + referenceNumber: { type: "string", + label: "Reference Number", description: "The reference number of the invoice.", optional: true, }, - customer_name: { + customerName: { type: "string", + label: "Customer Name", description: "The name of the customer. Max-length [100]", optional: true, }, - recurring_invoice_id: { + recurringInvoiceId: { type: "string", + label: "Recurring Invoice Id", description: "ID of the recurring invoice from which the invoice is created.", optional: true, }, email: { type: "string", + label: "Email", description: "Search contacts by email id. Max-length [100]", optional: true, }, total: { type: "string", + label: "Total", description: "The total amount to be paid.", optional: true, }, balance: { type: "string", + label: "Balance", description: "The unpaid amount.", optional: true, }, - custom_field: { + customField: { type: "string", - description: "Search invoices by custom fields. Variants: `custom_field_startswith` and `custom_field_contains`.", + label: "Custom Field", + description: "Search invoices by custom fields.", optional: true, }, date: { type: "string", - description: "Search invoices by invoice date. Default date format is `yyyy-mm-dd`. Variants: `due_date_start`, `due_date_end`, `due_date_before` and `due_date_after`.", + label: "Date", + description: "Search invoices by invoice date. Default date format is `yyyy-mm-dd`.", optional: true, }, - due_date: { + dueDate: { type: "string", - description: "Search invoices by due date. Default date format is `yyyy-mm-dd`. Variants: `due_date_start`, `due_date_end`, `due_date_before` and `due_date_after`", + label: "Due Date", + description: "Search invoices by due date. Default date format is `yyyy-mm-dd`.", optional: true, }, - last_modified_time: { + lastModifiedTime: { type: "string", + label: "Last Modified Time", optional: true, }, status: { type: "string", - description: "Search invoices by invoice status. Allowed Values: `sent`, `draft`, `overdue`, `paid`, `void`, `unpaid`, `partially_paid` and `viewed`", + label: "Status", + description: "Search invoices by invoice status.", + options: INVOICE_STATUS_OPTIONS, optional: true, - options: [ - "sent", - "draft", - "overdue", - "paid", - "void", - "unpaid", - "partially_paid", - "viewed", - ], }, - customer_id: { + customerId: { type: "string", + label: "Customer Id", description: "ID of the customer the invoice has to be created.", optional: true, }, - filter_by: { + filterBy: { type: "string", - description: "Filter invoices by any status or payment expected date.Allowed Values: `Status.All`, `Status.Sent`, `Status.Draft`, `Status.OverDue`, `Status.Paid`, `Status.Void`, `Status.Unpaid`, `Status.PartiallyPaid`, `Status.Viewed` and `Date.PaymentExpectedDate`", + label: "Filter By", + description: "Filter invoices by any status or payment expected date.", optional: true, - options: [ - "Status.All", - "Status.Sent", - "Status.Draft", - "Status.OverDue", - "Status.Paid", - "Status.Void", - "Status.Unpaid", - "Status.PartiallyPaid", - "Status.Viewed", - "Date.PaymentExpectedDate", - ], + options: INVOICE_FILTER_BY_OPTIONS, }, - search_text: { + searchText: { type: "string", + label: "Search Text", description: "Search invoices by invoice number or purchase order or customer name. Max-length [100]", optional: true, }, - sort_column: { - type: "string", - description: "Sort invoices. Allowed Values: `customer_name`, `invoice_number`, `date`, `due_date`, `total`, `balance` and `created_time`.", - optional: true, - options: [ - "customer_name", - "invoice_number", - "date", - "due_date", - "total", - "balance", - "created_time", - ], - }, - page: { - type: "string", - description: "By default first page will be listed. For navigating through pages, use the `page` parameter.", - optional: true, - }, - per_page: { + sortColumn: { type: "string", - description: "The `per_page` parameter can be used to set the number of records that you want to receive in response.", + label: "Sort Column", + description: "Sort invoices.", + options: INVOICE_SORT_COLUMN_OPTIONS, optional: true, }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Invoices_List_invoices - - if (!this.organization_id) { - throw new Error("Must provide organization_id parameter."); - } - - return await axios($, { - method: "get", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/invoices?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, + const response = this.zohoBooks.paginate({ + fn: this.zohoBooks.listInvoices, + fieldName: "invoices", params: { - invoice_number: this.invoice_number, - item_name: this.item_name, - item_id: this.item_id, - item_description: this.item_description, - reference_number: this.reference_number, - customer_name: this.customer_name, - recurring_invoice_id: this.recurring_invoice_id, + invoice_number: this.invoiceNumber, + item_name: this.itemName, + item_id: this.itemId, + item_description: this.itemDescription, + reference_number: this.referenceNumber, + customer_name: this.customerName, + recurring_invoice_id: this.recurringInvoiceId, email: this.email, total: this.total, balance: this.balance, - custom_field: this.custom_field, + custom_field: this.customField, date: this.date, - due_date: this.due_date, - last_modified_time: this.last_modified_time, + due_date: this.dueDate, + last_modified_time: this.lastModifiedTime, status: this.status, - customer_id: this.customer_id, - filter_by: this.filter_by, - search_text: this.search_text, - sort_column: this.sort_column, - page: this.page, - per_page: this.per_page, + customer_id: this.customerId, + filter_by: this.filterBy, + search_text: this.searchText, + sort_column: this.sortColumn, }, }); + + const responseArray = []; + for await (const item of response) { + responseArray.push(item); + } + + $.export("$summary", `Successfully fetched ${responseArray.length} invoices(s)`); + return responseArray; }, }; 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 77fa7606da69c..cac6e8601f1fc 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 @@ -1,24 +1,23 @@ // legacy_hash_id: a_PNinw1 -import { axios } from "@pipedream/platform"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-make-api-call", name: "Make API Call", description: "Makes an aribitrary call to Zoho Books API", - version: "0.3.1", + version: "0.4.0", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - query_string: { + zohoBooks, + queryString: { type: "string", + label: "Query String", description: "Query string of the request.", optional: true, }, - request_method: { + requestMethod: { type: "string", + label: "Request Method", description: "Http method to use in the request.", options: [ "get", @@ -28,30 +27,35 @@ export default { "delete", ], }, - relative_url: { + relativeUrl: { type: "string", + label: "Relative Url", description: "A path relative to Zoho Books to send the request against.", }, headers: { type: "object", + label: "Headers", description: "Headers to send in the request.", + optional: true, }, - request_body: { + requestBody: { type: "object", + label: "Request Body", description: "Body of the request.", optional: true, }, }, async run({ $ }) { - // See the API docs: https://www.zoho.com/books/api/v3/#introduction - - this.query_string = this.query_string || ""; - - return await axios($, { - method: this.request_method, - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/${this.relative_url}${this.query_string}`, + const response = await this.zohoBooks._makeRequest({ + $, + path: this.relativeUrl, + params: this.queryString, + method: this.requestMethod, headers: this.headers, - data: this.request_body, + data: this.requestBody, }); + + $.export("$summary", `Successfully called the path: ${this.path}`); + return response; }, }; diff --git a/components/zoho_books/actions/update-salesorder/update-salesorder.mjs b/components/zoho_books/actions/update-salesorder/update-salesorder.mjs index 7b261d66c93ae..0f9b94ed28650 100644 --- a/components/zoho_books/actions/update-salesorder/update-salesorder.mjs +++ b/components/zoho_books/actions/update-salesorder/update-salesorder.mjs @@ -1,350 +1,453 @@ // legacy_hash_id: a_m8iYLJ -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import { + clearObj, parseObject, +} from "../../common/utils.mjs"; +import zohoBooks from "../../zoho_books.app.mjs"; export default { key: "zoho_books-update-salesorder", name: "Update Sales Order", - description: "Updates an existing sales order.", - version: "0.2.1", + 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", type: "action", props: { - zoho_books: { - type: "app", - app: "zoho_books", - }, - organization_id: { - type: "string", - description: "In Zoho Books, your business is termed as an organization. If you have multiple businesses, you simply set each of those up as an individual organization. Each organization is an independent Zoho Books Organization with it's own organization ID, base currency, time zone, language, contacts, reports, etc.\n\nThe parameter `organization_id` should be sent in with every API request to identify the organization.\n\nThe `organization_id` can be obtained from the GET `/organizations` API's JSON response. Alternatively, it can be obtained from the **Manage Organizations** page in the admin console.", - }, - salesorder_id: { - type: "string", - description: "ID of the sales order to update.", + zohoBooks, + salesorderId: { + propDefinition: [ + zohoBooks, + "salesorderId", + ], }, - customer_id: { - type: "string", - description: "ID of the customer to whom the sales order has to be updated.", + customerId: { + propDefinition: [ + zohoBooks, + "customerId", + ], + description: "ID of the customer to whom the sales order has to be created.", + optional: true, }, - contact_persons: { - type: "any", - description: "Array of contact person(s) for whom sales order has to be sent.", + contactPersons: { + propDefinition: [ + zohoBooks, + "contactPersons", + ({ customerId }) => ({ + customerId, + }), + ], + description: "A list of contact person(s) for whom sales order has to be sent.", optional: true, }, date: { - type: "string", - description: "The date, the sales order is created.", + propDefinition: [ + zohoBooks, + "date", + ], optional: true, }, - shipment_date: { - type: "string", - description: "Shipping date of sales order.", + shipmentDate: { + propDefinition: [ + zohoBooks, + "shipmentDate", + ], optional: true, }, - custom_fields: { - type: "any", - description: "Custom fields for a sales order.", + customFields: { + propDefinition: [ + zohoBooks, + "customFields", + ], optional: true, }, - place_of_supply: { - type: "string", - description: "Place where the goods/services are supplied to. (If not given, `place of contact` given for the contact will be taken)\nSupported codes for UAE emirates are :\nAbu Dhabi - AB`,\nAjman - `AJ`,\nDubai - `DU`,\nFujairah - `FU`,\nRas al-Khaimah - `RA`,\nSharjah - `SH`,\nUmm al-Quwain - `UM`\nSupported codes for the GCC countries are :\nUnited Arab Emirates - `AE`,\nSaudi Arabia - `SA`,\nBahrain - `BH`,\nKuwait - `KW`,\nOman - `OM`,\nQatar - `QA`.", + placeOfSupply: { + propDefinition: [ + zohoBooks, + "placeOfSupply", + ], optional: true, }, - salesperson_id: { - type: "string", - description: "ID of the salesperson.", + salespersonId: { + propDefinition: [ + zohoBooks, + "salespersonId", + ], optional: true, }, - merchant_id: { - type: "string", - description: "ID of the merchant.", + merchantId: { + propDefinition: [ + zohoBooks, + "merchantId", + ], optional: true, }, - gst_treatment: { - type: "string", - description: "Choose whether the contact is GST registered/unregistered/consumer/overseas. Allowed values are `business_gst`, `business_none`, `overseas`, `consumer`.", - optional: true, - options: [ - "business_gst", - "business_none", - "overseas", - "consumer", + gstTreatment: { + propDefinition: [ + zohoBooks, + "gstTreatment", ], + optional: true, }, - gst_no: { - type: "string", - description: "15 digit GST identification number of the customer.", + gstNo: { + propDefinition: [ + zohoBooks, + "gstNo", + ], optional: true, }, - is_inclusive_tax: { - type: "boolean", - description: "Used to specify whether the line item rates are inclusive or exclusive of tax.", + isInclusiveTax: { + propDefinition: [ + zohoBooks, + "isInclusiveTax", + ], optional: true, }, - line_items: { - type: "any", - description: "Line items of a sales order. To delete a line item just remove it from this line_items list.", + lineItems: { + propDefinition: [ + zohoBooks, + "lineItems", + ], optional: true, }, notes: { - type: "string", - description: "Notes for this Sales Order.", + propDefinition: [ + zohoBooks, + "notes", + ], optional: true, }, terms: { - type: "string", + propDefinition: [ + zohoBooks, + "terms", + ], optional: true, }, - billing_address_id: { - type: "string", - description: "ID of the Billing Address", + billingAddressId: { + propDefinition: [ + zohoBooks, + "billingAddressId", + ], optional: true, }, - shipping_address_id: { - type: "string", - description: "ID of the Shipping Address.", + shippingAddressId: { + propDefinition: [ + zohoBooks, + "shippingAddressId", + ], optional: true, }, - crm_owner_id: { - type: "string", + crmOwnerId: { + propDefinition: [ + zohoBooks, + "crmOwnerId", + ], optional: true, }, - crm_custom_reference_id: { - type: "string", + crmCustomReferenceId: { + propDefinition: [ + zohoBooks, + "crmCustomReferenceId", + ], optional: true, }, - vat_treatment: { - type: "string", - description: "Enter vat treatment.", + vatTreatment: { + propDefinition: [ + zohoBooks, + "vatTreatment", + ], optional: true, }, - tax_treatment: { - type: "string", - description: "VAT treatment for the invoice .Choose whether the contact falls under: `vat_registered`, `vat_not_registered`, `gcc_vat_not_registered`, `gcc_vat_registered`, `non_gcc` , `dz_vat_registered` and `dz_vat_not_registered` supported only for UAE.", - optional: true, - options: [ - "vat_registered", - "vat_not_registered", - "gcc_vat_not_registered", - "gcc_vat_registered", - "non_gcc", - "dz_vat_registered", - "dz_vat_not_registered", + taxTreatment: { + propDefinition: [ + zohoBooks, + "taxTreatment", ], + optional: true, }, - salesorder_number: { - type: "string", - description: "Mandatory if auto number generation is disabled.", + salesorderNumber: { + propDefinition: [ + zohoBooks, + "salesorderNumber", + ], optional: true, }, - reference_number: { - type: "string", - description: "**For Customer Only** : If a contact is assigned to any particular user, that user can manage transactions for the contact", + referenceNumber: { + propDefinition: [ + zohoBooks, + "referenceNumber", + ], optional: true, }, - is_update_customer: { - type: "boolean", - description: "Boolean to update billing address of customer.", + isUpdateCustomer: { + propDefinition: [ + zohoBooks, + "isUpdateCustomer", + ], optional: true, }, discount: { - type: "string", - description: "Discount applied to the sales order. It can be either in % or in amount. e.g. 12.5% or 190.", + propDefinition: [ + zohoBooks, + "discount", + ], optional: true, }, - exchange_rate: { - type: "string", - description: "Exchange rate of the currency.", + exchangeRate: { + propDefinition: [ + zohoBooks, + "exchangeRate", + ], optional: true, }, - salesperson_name: { - type: "string", - description: "Name of the sales person.", + salespersonName: { + propDefinition: [ + zohoBooks, + "salespersonName", + ], optional: true, }, - notes_default: { - type: "string", - description: "Default Notes for the Sales Order.", + notesDefault: { + propDefinition: [ + zohoBooks, + "notesDefault", + ], optional: true, }, - terms_default: { - type: "string", - description: "Default Terms of the Sales Order.", + termsDefault: { + propDefinition: [ + zohoBooks, + "termsDefault", + ], optional: true, }, - tax_id: { - type: "string", - description: "Tax ID for the Sales Order.", + taxId: { + propDefinition: [ + zohoBooks, + "taxId", + ], optional: true, }, - tax_authority_id: { - type: "string", - description: "ID of the tax authority. Tax authority depends on the location of the customer.", + taxAuthorityId: { + propDefinition: [ + zohoBooks, + "taxAuthorityId", + ], optional: true, }, - tax_exemption_id: { - type: "string", - description: "ID of the tax exemption applied.", + taxExemptionId: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], optional: true, }, - tax_authority_name: { - type: "string", - description: "Tax Authority's name.", + taxAuthorityName: { + propDefinition: [ + zohoBooks, + "taxAuthorityName", + ], optional: true, }, - tax_exemption_code: { - type: "string", - description: "Code of Tax Exemption that is applied.", + taxExemptionCode: { + propDefinition: [ + zohoBooks, + "taxExemptionCode", + ], optional: true, }, - avatax_exempt_no: { - type: "string", - description: "Exemption certificate number of the customer.", + avataxExemptNo: { + propDefinition: [ + zohoBooks, + "taxExemptionId", + ], optional: true, }, - avatax_use_code: { - type: "string", - description: "Used to group like customers for exemption purposes. It is a custom value that links customers to a tax rule.", + avataxUseCode: { + propDefinition: [ + zohoBooks, + "avataxUseCode", + ], optional: true, }, - shipping_charge: { - type: "string", + shippingCharge: { + propDefinition: [ + zohoBooks, + "shippingCharge", + ], optional: true, }, adjustment: { - type: "string", + propDefinition: [ + zohoBooks, + "adjustment", + ], optional: true, }, - delivery_method: { - type: "string", + deliveryMethod: { + propDefinition: [ + zohoBooks, + "deliveryMethod", + ], optional: true, }, - is_discount_before_tax: { - type: "boolean", - description: "Used to specify how the discount has to applied. Either before or after the calculation of tax.", + estimateId: { + type: "string", + label: "Estimate Id", + description: "ID of the estimate associated with the Sales Order.", optional: true, }, - discount_type: { - type: "string", - description: "How the discount is specified. Allowed values are entity_level or item_level.", + isDiscountBeforeTax: { + propDefinition: [ + zohoBooks, + "isDiscountBeforeTax", + ], optional: true, - options: [ - "entity_level", - "item_level", + }, + discountType: { + propDefinition: [ + zohoBooks, + "discountType", ], + optional: true, }, - adjustment_description: { - type: "string", + adjustmentDescription: { + propDefinition: [ + zohoBooks, + "adjustmentDescription", + ], optional: true, }, - pricebook_id: { - type: "string", + pricebookId: { + propDefinition: [ + zohoBooks, + "pricebookId", + ], optional: true, }, - template_id: { - type: "string", - description: "ID of the pdf template.", + templateId: { + propDefinition: [ + zohoBooks, + "pdfTemplateId", + ], optional: true, }, documents: { - type: "any", + propDefinition: [ + zohoBooks, + "documents", + ], optional: true, }, - zcrm_potential_id: { - type: "string", + zcrmPotentialId: { + propDefinition: [ + zohoBooks, + "zcrmPotentialId", + ], optional: true, }, - zcrm_potential_name: { - type: "string", + zcrmPotentialName: { + propDefinition: [ + zohoBooks, + "zcrmPotentialName", + ], optional: true, }, - ignore_auto_number_generation: { - type: "string", - description: "Ignore auto sales order number generation for this sales order. This mandates the sales order number.", + ignoreAutoNumberGeneration: { + propDefinition: [ + zohoBooks, + "ignoreAutoNumberGeneration", + ], optional: true, }, - can_send_in_mail: { - type: "string", - description: "Can the file be sent in mail.", + canSendInMail: { + propDefinition: [ + zohoBooks, + "canSendInMail", + ], optional: true, }, totalFiles: { - type: "string", - description: "Total number of files.", + propDefinition: [ + zohoBooks, + "totalFiles", + ], optional: true, }, doc: { - type: "string", - description: "Document that is to be attached", + propDefinition: [ + zohoBooks, + "doc", + ], optional: true, }, }, async run({ $ }) { - //See the API docs: https://www.zoho.com/books/api/v3/#Sales-Order_Update_a_sales_order + const data = clearObj({ + customer_id: this.customerId, + contact_persons: this.contactPersons, + date: this.date, + shipment_date: this.shipmentDate, + custom_fields: parseObject(this.customFields), + place_of_supply: this.placeOfSupply, + salesperson_id: this.salespersonId, + merchant_id: this.merchantId, + gst_treatment: this.gstTreatment, + gst_no: this.gstNo, + is_inclusive_tax: this.isInclusiveTax, + line_items: parseObject(this.lineItems), + notes: this.notes, + terms: this.terms, + billing_address_id: this.billingAddressId, + shipping_address_id: this.shippingAddressId, + crm_owner_id: this.crmOwnerId, + crm_custom_reference_id: this.crmCustomReferenceId, + vat_treatment: this.vatTreatment, + tax_treatment: this.taxTreatment, + salesorder_number: this.salesorderNumber, + reference_number: this.referenceNumber, + is_update_customer: this.isUpdateCustomer, + discount: this.discount, + exchange_rate: this.exchangeRate && parseFloat(this.exchangeRate), + salesperson_name: this.salespersonName, + notes_default: this.notesDefault, + terms_default: this.termsDefault, + tax_id: this.taxId, + tax_authority_id: this.taxAuthorityId, + tax_exemption_id: this.taxExemptionId, + tax_authority_name: this.taxAuthorityName, + tax_exemption_code: this.taxExemptionCode, + avatax_exempt_no: this.avataxExemptNo, + avatax_use_code: this.avataxUseCode, + shipping_charge: this.shippingCharge && parseFloat(this.shippingCharge), + adjustment: this.adjustment && parseFloat(this.adjustment), + delivery_method: this.deliveryMethod, + estimate_id: this.estimateId, + is_discount_before_tax: this.isDiscountBeforeTax, + discount_type: this.discountType, + adjustment_description: this.adjustmentDescription, + pricebook_id: this.pricebookId, + template_id: this.templateId, + documents: parseObject(this.documents), + zcrm_potential_id: this.zcrmPotentialId, + zcrm_potential_name: this.zcrmPotentialName, + }); - if (!this.organization_id || !this.salesorder_id) { - throw new Error("Must provide organization_id, salesorder_id parameters."); + if (!Object.keys(data).length) { + throw new ConfigurationError("You must provide at least one field."); } - - return await axios($, { - method: "put", - url: `https://books.${this.zoho_books.$auth.base_api_uri}/api/v3/salesorders/${this.salesorder_id}?organization_id=${this.organization_id}`, - headers: { - Authorization: `Zoho-oauthtoken ${this.zoho_books.$auth.oauth_access_token}`, - }, - data: { - customer_id: this.customer_id, - contact_persons: this.contact_persons, - date: this.date, - shipment_date: this.shipment_date, - custom_fields: this.custom_fields, - place_of_supply: this.place_of_supply, - salesperson_id: this.salesperson_id, - merchant_id: this.merchant_id, - gst_treatment: this.gst_treatment, - gst_no: this.gst_no, - is_inclusive_tax: this.is_inclusive_tax, - line_items: this.line_items, - notes: this.notes, - terms: this.terms, - billing_address_id: this.billing_address_id, - shipping_address_id: this.shipping_address_id, - crm_owner_id: this.crm_owner_id, - crm_custom_reference_id: this.crm_custom_reference_id, - vat_treatment: this.vat_treatment, - tax_treatment: this.tax_treatment, - salesorder_number: this.salesorder_number, - reference_number: this.reference_number, - is_update_customer: this.is_update_customer, - discount: this.discount, - exchange_rate: this.exchange_rate, - salesperson_name: this.salesperson_name, - notes_default: this.notes_default, - terms_default: this.terms_default, - tax_id: this.tax_id, - tax_authority_id: this.tax_authority_id, - tax_exemption_id: this.tax_exemption_id, - tax_authority_name: this.tax_authority_name, - tax_exemption_code: this.tax_exemption_code, - avatax_exempt_no: this.avatax_exempt_no, - avatax_use_code: this.avatax_use_code, - shipping_charge: this.shipping_charge, - adjustment: this.adjustment, - delivery_method: this.delivery_method, - is_discount_before_tax: this.is_discount_before_tax, - discount_type: this.discount_type, - adjustment_description: this.adjustment_description, - pricebook_id: this.pricebook_id, - template_id: this.template_id, - documents: this.documents, - zcrm_potential_id: this.zcrm_potential_id, - zcrm_potential_name: this.zcrm_potential_name, - }, - params: { - ignore_auto_number_generation: this.ignore_auto_number_generation, - can_send_in_mail: this.can_send_in_mail, + const response = await this.zohoBooks.updateSalesorder({ + $, + salesorderId: this.salesorderId, + params: clearObj({ + ignore_auto_number_generation: this.ignoreAutoNumberGeneration, + can_send_in_mail: this.canSendInMail, totalFiles: this.totalFiles, doc: this.doc, - }, + }), + data, }); + + $.export("$summary", `Salesorder successfully updated with Id: ${this.salesorderId}`); + return response; }, }; diff --git a/components/zoho_books/common/constants.mjs b/components/zoho_books/common/constants.mjs new file mode 100644 index 0000000000000..673ea47bcc472 --- /dev/null +++ b/components/zoho_books/common/constants.mjs @@ -0,0 +1,196 @@ +export const PAYMENT_MODE_OPTIONS = [ + "check", + "cash", + "creditcard", + "banktransfer", + "bankremittance", + "autotransaction", + "others", +]; + +export const PLACE_OF_SUPPLY_OPTIONS = [ + { + label: "Abu Dhabi (UAE Supported)", + value: "AB", + }, + { + label: "Ajman (UAE Supported)", + value: "AJ", + }, + { + label: "Dubai (UAE Supported)", + value: "DU", + }, + { + label: "Fujairah (UAE Supported)", + value: "FU", + }, + { + label: "Ras al-Khaimah (UAE Supported)", + value: "RA", + }, + { + label: "Sharjah (UAE Supported)", + value: "SH", + }, + { + label: "Umm al-Quwain (UAE Supported)", + value: "UM", + }, + { + label: "United Arab Emirates (GCC Supported)", + value: "AE", + }, + { + label: "Saudi Arabia (GCC Supported)", + value: "SA", + }, + { + label: "Bahrain (GCC Supported)", + value: "BH", + }, + { + label: "Kuwait (GCC Supported)", + value: "KW", + }, + { + label: "Oman (GCC Supported)", + value: "OM", + }, + { + label: "Qatar (GCC Supported)", + value: "QA", + }, +]; + +export const GST_TREATMENT_OPTIONS = [ + "business_gst", + "business_none", + "overseas", + "consumer", +]; + +export const DISCOUNT_TYPE_OPTIONS = [ + "entity_level", + "item_level", +]; + +export const PRODUCT_TYPE_OPTIONS = [ + "goods", + "service", + "digital_service", +]; + +export const ITEM_TYPE_OPTIONS = [ + "sales", + "purchases", + "sales_and_purchases", + "inventory", +]; + +export const TAX_TREATMENT_OPTIONS = [ + "vat_registered", + "vat_not_registered", + "gcc_vat_not_registered", + "gcc_vat_registered", + "non_gcc", + "dz_vat_registered", + "dz_vat_not_registered", + "home_country_mexico", + "border_region_mexico", + "non_mexico", + "vat_registered ", + "vat_not_registered ", + "non_kenya", + "vat_registered", + "vat_not_registered", + "overseas", +]; + +export const PRINT_OPTIONS = [ + "true", + "false", + "on", + "off", +]; + +export const STATUS_OPTIONS = [ + "unbilled", + "invoiced", + "reimbursed", + "non-billable", + "billable", +]; + +export const SORT_COLUMN_OPTIONS = [ + "date", + "account_name", + "total", + "bcy_total", + "reference_number", + "customer_name", + "created_time", +]; + +export const FILTER_BY_OPTIONS = [ + "Status.All", + "Status.Billable", + "Status.Nonbillable", + "Status.Reimbursed", + "Status.Invoiced", + "Status.Unbilled", +]; + +export const INVOICE_STATUS_OPTIONS = [ + "sent", + "draft", + "overdue", + "paid", + "void", + "unpaid", + "partially_paid", + "viewed", +]; + +export const INVOICE_FILTER_BY_OPTIONS = [ + "Status.All", + "Status.Sent", + "Status.Draft", + "Status.OverDue", + "Status.Paid", + "Status.Void", + "Status.Unpaid", + "Status.PartiallyPaid", + "Status.Viewed", + "Date.PaymentExpectedDate", +]; + +export const INVOICE_SORT_COLUMN_OPTIONS = [ + "customer_name", + "invoice_number", + "date", + "due_date", + "total", + "balance", + "created_time", +]; + +export const LANGUAGE_CODE_OPTIONS = [ + "de", + "en", + "es", + "fr", + "it", + "ja", + "nl", + "pt", + "pt_br", + "sv", + "zh", + "en_gb", +]; + +export const CUSTOMER_SUB_TYPE_OPTIONS = [ + "business", + "individual", +]; diff --git a/components/zoho_books/common/utils.mjs b/components/zoho_books/common/utils.mjs new file mode 100644 index 0000000000000..20c672867d52d --- /dev/null +++ b/components/zoho_books/common/utils.mjs @@ -0,0 +1,41 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; + +export const clearObj = (obj) => { + return Object.entries(obj) + .filter(([ + , + v, + ]) => (v != null && v != "" && JSON.stringify(v) != "{}")) + .reduce((acc, [ + k, + v, + ]) => ({ + ...acc, + [k]: (!Array.isArray(v) && v === Object(v)) + ? clearObj(v) + : v, + }), {}); +}; diff --git a/components/zoho_books/package.json b/components/zoho_books/package.json new file mode 100644 index 0000000000000..6c5d0cca37ec9 --- /dev/null +++ b/components/zoho_books/package.json @@ -0,0 +1,18 @@ +{ + "name": "@pipedream/zoho_books", + "version": "0.2.0", + "description": "Pipedream Zoho Books Components", + "main": "zoho_books.app.mjs", + "keywords": [ + "pipedream", + "zoho_books" + ], + "homepage": "https://pipedream.com/apps/zoho_books", + "author": "Pipedream (https://pipedream.com/)", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" + } +} diff --git a/components/zoho_books/sources/common/base.mjs b/components/zoho_books/sources/common/base.mjs new file mode 100644 index 0000000000000..11929a8bb4406 --- /dev/null +++ b/components/zoho_books/sources/common/base.mjs @@ -0,0 +1,60 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import zohoBooks from "../../zoho_books.app.mjs"; + +export default { + props: { + zohoBooks, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastDate() { + return this.db.get("lastDate") || 0; + }, + _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), + }); + } + }, + }, + hooks: { + async deploy() { + await this.emitEvent(25); + }, + }, + async run() { + await this.emitEvent(); + }, +}; diff --git a/components/zoho_books/sources/new-customer/new-customer.mjs b/components/zoho_books/sources/new-customer/new-customer.mjs new file mode 100644 index 0000000000000..42e7b48b08a30 --- /dev/null +++ b/components/zoho_books/sources/new-customer/new-customer.mjs @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000000000..2f6b157db1e12 --- /dev/null +++ b/components/zoho_books/sources/new-customer/test-event.mjs @@ -0,0 +1,20 @@ +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/new-expense.mjs new file mode 100644 index 0000000000000..f579e8e24d4b9 --- /dev/null +++ b/components/zoho_books/sources/new-expense/new-expense.mjs @@ -0,0 +1,28 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "zoho_books-new-expense", + name: "New Expense", + 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; + }, + getFieldName() { + return "expenses"; + }, + getFieldId() { + return "expense_id"; + }, + getSummary(item) { + return `New Expense: ${item.description}`; + }, + }, + sampleEmit, +}; diff --git a/components/zoho_books/sources/new-expense/test-event.mjs b/components/zoho_books/sources/new-expense/test-event.mjs new file mode 100644 index 0000000000000..75a5cccedbbdd --- /dev/null +++ b/components/zoho_books/sources/new-expense/test-event.mjs @@ -0,0 +1,25 @@ +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/new-sales-order.mjs b/components/zoho_books/sources/new-sales-order/new-sales-order.mjs new file mode 100644 index 0000000000000..5078c8b6074be --- /dev/null +++ b/components/zoho_books/sources/new-sales-order/new-sales-order.mjs @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000000000..4386460147a04 --- /dev/null +++ b/components/zoho_books/sources/new-sales-order/test-event.mjs @@ -0,0 +1,30 @@ +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 3ae9249b20ece..09c5f6ec1cb58 100644 --- a/components/zoho_books/zoho_books.app.mjs +++ b/components/zoho_books/zoho_books.app.mjs @@ -1,11 +1,747 @@ +import { axios } from "@pipedream/platform"; +import { + DISCOUNT_TYPE_OPTIONS, + GST_TREATMENT_OPTIONS, + PLACE_OF_SUPPLY_OPTIONS, + TAX_TREATMENT_OPTIONS, +} from "./common/constants.mjs"; + export default { type: "app", app: "zoho_books", - propDefinitions: {}, + propDefinitions: { + accountId: { + type: "string", + label: "Account Id", + description: "ID of the cash/bank account the payment has to be deposited.", + async options({ page }) { + const { bankaccounts } = await this.listBankAccounts({ + params: { + page: page + 1, + }, + }); + + return bankaccounts.map(({ + account_id: value, account_name: label, + }) => ({ + label, + value, + })); + }, + }, + contactPersons: { + type: "string[]", + label: "Contact Persons", + description: "IDs of the contact persons the thank you mail has to be triggered.", + async options({ + page, customerId, + }) { + const { contact_persons: data } = await this.listContactPersons({ + customerId, + params: { + page: page + 1, + }, + }); + + return data.map(({ + contact_person_id: value, first_name: fName, last_name: lName, email, + }) => ({ + label: `${fName} ${lName} ${email}`, + value, + })); + }, + }, + currencyId: { + type: "string", + label: "Currency Id", + description: "The id of the customer.", + async options({ page }) { + const { currencies } = await this.listCurrencies({ + params: { + page: page + 1, + }, + }); + return currencies.map(({ + currency_id: value, currency_name: label, + }) => ({ + label, + value, + })); + }, + }, + customerId: { + type: "string", + label: "Customer Id", + description: "Customer ID of the customer involved in the payment.", + async options({ page }) { + const { contacts } = await this.listContacts({ + params: { + page: page + 1, + }, + }); + return contacts.map(({ + contact_id: value, contact_name: label, + }) => ({ + label, + value, + })); + }, + }, + expenseId: { + type: "string", + label: "Expense Id", + async options({ page }) { + const { expenses } = await this.listExpenses({ + params: { + page: page + 1, + }, + }); + return expenses.map(({ + expense_id: value, description: label, + }) => ({ + label, + value, + })); + }, + }, + invoiceId: { + type: "string", + label: "Invoice Id", + description: "ID of the invoice to get payments of.", + async options({ + page, customerId, + }) { + const { invoices } = await this.listInvoices({ + params: { + page: page + 1, + customer_id: customerId, + }, + }); + + return invoices.map(({ + invoice_id: value, invoice_number: inv, customer_name: name, + }) => ({ + label: `${inv} - ${name}`, + value, + })); + }, + }, + itemId: { + type: "string", + label: "Item Id", + description: "ID of the item to get details.", + async options({ page }) { + const { items } = await this.listItems({ + params: { + page: page + 1, + }, + }); + + return items.map(({ + item_id: value, name: label, + }) => ({ + label, + value, + })); + }, + }, + recurringInvoiceId: { + type: "string", + label: "Recurring Invoice Id", + description: "ID of the recurring invoice from which the invoice is created.", + async options({ + page, customerId, + }) { + const { recurring_invoices: data } = await this.listRecurringInvoices({ + params: { + page: page + 1, + customerId, + }, + }); + + return data.map(({ + recurring_invoice_id: value, recurrence_name: label, + }) => ({ + label, + value, + })); + }, + }, + salesorderId: { + type: "string", + label: "Salesorder Id", + description: "ID of the sales order to update.", + async options({ page }) { + const { salesorders } = await this.listSalesorders({ + params: { + page: page + 1, + }, + }); + + return salesorders.map(({ + salesorder_id: value, salesorder_number: label, + }) => ({ + label, + value, + })); + }, + }, + taxAuthorityId: { + type: "string", + label: "Tax Authority Id", + description: "ID of the tax authority. Tax authority depends on the location of the customer. For example, if the customer is located in NY, then the tax authority is NY tax authority.", + async options({ page }) { + const { tax_authorities: data } = await this.listTaxAuthorities({ + params: { + page: page + 1, + }, + }); + + return data.map(({ + tax_authority_id: value, tax_authority_name: label, + }) => ({ + label, + value, + })); + }, + }, + taxExemptionId: { + type: "string", + label: "Tax Exemption Id", + description: "ID of the tax exemption.", + async options({ page }) { + const { tax_exemptions: data } = await this.listTaxExemptions({ + params: { + page: page + 1, + }, + }); + + return data.map(({ + tax_exemption_id: value, tax_exemption_code: label, + }) => ({ + label, + value, + })); + }, + }, + taxId: { + type: "string", + label: "Tax Id", + description: "ID of the tax.", + async options({ page }) { + const { taxes } = await this.listTaxes({ + params: { + page: page + 1, + }, + }); + + return taxes.map(({ + tax_id: value, tax_name: label, + }) => ({ + label, + value, + })); + }, + }, + templateId: { + type: "string", + label: "Template Id", + description: "ID of the pdf template associated with the invoice.", + async options({ page }) { + const { templates } = await this.listTemplates({ + params: { + page: page + 1, + }, + }); + + return templates.map(({ + template_id: value, template_name: label, + }) => ({ + label, + value, + })); + }, + }, + timeEntryIds: { + type: "string[]", + label: "Time Entry Ids", + description: "IDs of the time entries associated with the project.", + async options({ page }) { + const { time_entries: data } = await this.listTimeEntries({ + params: { + page: page + 1, + }, + }); + + return data.map(({ + time_entry_id: value, task_name: tName, user_name: uName, + }) => ({ + label: `${tName} - ${uName}`, + value, + })); + }, + }, + date: { + type: "string", + label: "date", + description: "The date, the sales order is created.", + }, + shipmentDate: { + type: "string", + label: "Shipment Date", + description: "Shipping date of sales order.", + }, + customFields: { + type: "string[]", + label: "Custom Fields", + description: "A list of custom field objects for a sales order. **Example: {\"customfield_id\": \"1352827000000156060\", \"value\": \"value\" }** [See the documentation](https://www.zoho.com/books/api/v3/sales-order/#create-a-sales-order) for further details.", + }, + placeOfSupply: { + type: "string", + label: "Place Of Supply", + description: "Place where the goods/services are supplied to. (If not given, `place of contact` given for the contact will be taken).", + options: PLACE_OF_SUPPLY_OPTIONS, + }, + salespersonId: { + type: "string", + label: "Salesperson Id", + description: "ID of the salesperson.", + }, + merchantId: { + type: "string", + label: "Merchant Id", + description: "ID of the merchant.", + }, + gstTreatment: { + type: "string", + label: "GST Treatment", + description: "Choose whether the contact is GST registered/unregistered/consumer/overseas.", + options: GST_TREATMENT_OPTIONS, + }, + gstNo: { + type: "string", + label: "GST No", + description: "15 digit GST identification number of the customer.", + }, + isInclusiveTax: { + type: "boolean", + label: "Is Inclusive Tax", + description: "Used to specify whether the line item rates are inclusive or exclusive of tax.", + }, + lineItems: { + type: "string[]", + label: "Line Items", + description: "A list of line items objects of a sales order. **Example: {\"item_order\": \"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.", + }, + notes: { + type: "string", + label: "Notes", + description: "Notes for this Sales Order.", + }, + terms: { + type: "string", + label: "Terms", + description: "The terms added below expressing gratitude or for conveying some information.", + }, + billingAddressId: { + type: "string", + label: "Billing Address Id", + description: "ID of the Billing Address", + }, + shippingAddressId: { + type: "string", + label: "Shipping Address Id", + description: "ID of the Shipping Address.", + }, + crmOwnerId: { + type: "string", + label: "CRM Owner Id", + }, + crmCustomReferenceId: { + type: "string", + label: "CRM Custom Reference Id", + }, + vatTreatment: { + type: "string", + label: "VAT Treatment", + description: "Enter vat treatment.", + }, + taxTreatment: { + type: "string", + label: "Tax Treatment", + description: "VAT treatment for the invoice.", + options: TAX_TREATMENT_OPTIONS, + }, + salesorderNumber: { + type: "string", + label: "Salesorder Number", + description: "Mandatory if auto number generation is disabled.", + }, + referenceNumber: { + type: "string", + label: "Reference Number", + description: "**For Customer Only** : If a contact is assigned to any particular user, that user can manage transactions for the contact", + }, + isUpdateCustomer: { + type: "boolean", + label: "Is Update Customer", + description: "Boolean to update billing address of customer.", + }, + discount: { + type: "string", + label: "Discount", + description: "Discount applied to the sales order. It can be either in % or in amount. e.g. 12.5% or 190.", + }, + exchangeRate: { + type: "string", + label: "Exchange Rate", + description: "Exchange rate of the currency.", + }, + salespersonName: { + type: "string", + label: "Salesperson Name", + description: "Name of the sales person.", + }, + notesDefault: { + type: "string", + label: "Notes Default", + description: "Default Notes for the Sales Order", + }, + termsDefault: { + type: "string", + label: "Terms Default", + description: "Default Terms of the Sales Order.", + }, + taxAuthorityName: { + type: "string", + label: "Tax Authority Name", + description: "Tax Authority's name.", + }, + taxExemptionCode: { + type: "string", + label: "Tax Exemption Code", + description: "Code of Tax Exemption that is applied.", + }, + avataxExemptNo: { + type: "string", + label: "Avatax Exempt No", + description: "Exemption certificate number of the customer.", + }, + avataxUseCode: { + type: "string", + label: "Avatax Use Code", + description: "Used to group like customers for exemption purposes. It is a custom value that links customers to a tax rule.", + }, + shippingCharge: { + type: "string", + label: "Shipping Charge", + description: "Shipping charges applied to the invoice.", + }, + adjustment: { + type: "string", + label: "Adjustment", + }, + deliveryMethod: { + type: "string", + label: "Delivery Method", + }, + isDiscountBeforeTax: { + type: "boolean", + label: "Is Discount Before Tax", + description: "Used to specify how the discount has to applied. Either before or after the calculation of tax.", + }, + discountType: { + type: "string", + label: "Discount Type", + description: "How the discount is specified. Allowed values are entity_level or item_level.", + options: DISCOUNT_TYPE_OPTIONS, + }, + adjustmentDescription: { + type: "string", + label: "Adjustment Description", + }, + pricebookId: { + type: "string", + label: "Pricebook Id", + }, + pdfTemplateId: { + type: "string", + label: "Template Id", + description: "ID of the PDF template.", + }, + documents: { + type: "string[]", + label: "Documents", + description: "A list of documents.", + }, + zcrmPotentialId: { + type: "string", + label: "ZCRM Potential Id", + }, + zcrmPotentialName: { + type: "string", + label: "ZCRM Potential Name", + }, + ignoreAutoNumberGeneration: { + type: "boolean", + label: "Ignore Auto Number Generation", + description: "Ignore auto sales order number generation for this sales order. This mandates the sales order number.", + default: false, + }, + canSendInMail: { + type: "string", + label: "Can Send In Mail", + description: "Can the file be sent in mail.", + }, + totalFiles: { + type: "string", + label: "Total Files", + description: "Total number of files.", + }, + doc: { + type: "string", + label: "doc", + description: "Document that is to be attached", + }, + customBody: { + type: "string", + label: "Custom Body", + }, + customSubject: { + type: "string", + label: "Custom Subject", + optional: true, + }, + send: { + type: "boolean", + label: "Send", + description: "Send the estimate to the contact person(s) associated with the estimate.", + }, + paymentTerms: { + type: "integer", + label: "Payment Terms", + description: "Payment terms in days e.g. 15, 30, 60. Invoice due date will be calculated based on this. Max-length [100]", + }, + paymentTermsLabel: { + type: "string", + label: "Payment Terms Label", + description: "Used to override the default payment terms label. Default value for 15 days is \"Net 15 Days\". Max-length [100]", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return `${this.$auth.api_domain}/books/v3`; + }, + _headers(headers = {}) { + return { + ...headers, + Authorization: `Zoho-oauthtoken ${this.$auth.oauth_access_token}`, + }; + }, + _params(params = {}) { + return { + ...params, + organization_id: `${this.$auth.organization_id}`, + }; + }, + _makeRequest({ + $ = this, path, headers, params, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(headers), + params: this._params(params), + ...opts, + }); + }, + createContact(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/contacts", + ...opts, + }); + }, + createCustomerPayment(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/customerpayments", + ...opts, + }); + }, + createEmployee(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/employees", + ...opts, + }); + }, + createEstimate(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/estimates", + ...opts, + }); + }, + createInvoice(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/invoices", + ...opts, + }); + }, + createItem(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/items", + ...opts, + }); + }, + createSalesorder(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/salesorders", + ...opts, + }); + }, + deleteContact({ + customerId, ...opts + }) { + return this._makeRequest({ + method: "DELETE", + path: `/contacts/${customerId}`, + ...opts, + }); + }, + getInvoice({ + invoiceId, ...opts + }) { + return this._makeRequest({ + path: `/invoices/${invoiceId}`, + ...opts, + }); + }, + getItem({ + itemId, ...opts + }) { + return this._makeRequest({ + path: `/items/${itemId}`, + ...opts, + }); + }, + listBankAccounts(opts = {}) { + return this._makeRequest({ + path: "/bankaccounts", + ...opts, + }); + }, + listContactPersons({ + customerId, ...opts + }) { + return this._makeRequest({ + path: `/contacts/${customerId}/contactpersons`, + ...opts, + }); + }, + listContacts(opts = {}) { + return this._makeRequest({ + path: "/contacts", + ...opts, + }); + }, + listCurrencies(opts = {}) { + return this._makeRequest({ + path: "/settings/currencies", + ...opts, + }); + }, + listExpenses(opts = {}) { + return this._makeRequest({ + path: "/expenses", + ...opts, + }); + }, + listInvoices(opts = {}) { + return this._makeRequest({ + path: "/invoices", + ...opts, + }); + }, + listItems(opts = {}) { + return this._makeRequest({ + path: "/items", + ...opts, + }); + }, + listRecurringInvoices(opts = {}) { + return this._makeRequest({ + path: "/recurringinvoices", + ...opts, + }); + }, + listSalesorders(opts = {}) { + return this._makeRequest({ + path: "/salesorders", + ...opts, + }); + }, + listTaxAuthorities(opts = {}) { + return this._makeRequest({ + path: "/settings/taxauthorities", + ...opts, + }); + }, + listTaxes(opts = {}) { + return this._makeRequest({ + path: "/settings/taxes", + ...opts, + }); + }, + listTaxExemptions(opts = {}) { + return this._makeRequest({ + path: "/settings/taxexemptions", + ...opts, + }); + }, + listTemplates(opts = {}) { + return this._makeRequest({ + path: "/invoices/templates", + ...opts, + }); + }, + listTimeEntries(opts = {}) { + return this._makeRequest({ + path: "/projects/timeentries", + ...opts, + }); + }, + updateSalesorder({ + salesorderId, ...opts + }) { + return this._makeRequest({ + method: "PUT", + path: `/salesorders/${salesorderId}`, + ...opts, + }); + }, + async *paginate({ + fn, params = {}, fieldName, ...opts + }) { + let hasMore = false; + let page = 0; + + do { + params.page = ++page; + const data = await fn({ + params, + ...opts, + }); + for (const d of data[fieldName]) { + yield d; + } + + hasMore = data[fieldName].length; + + } while (hasMore); }, }, }; From ebe7054f9e5589fdf8fdbb8ce08666e599a59f30 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 28 Nov 2024 14:05:32 -0300 Subject: [PATCH 2/9] pnpm update --- pnpm-lock.yaml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83170227058b7..1f23cdf34c484 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11807,6 +11807,12 @@ importers: specifier: ^4.0.0 version: 4.0.1 + components/zoho_books: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 + components/zoho_bugtracker: dependencies: '@pipedream/platform': @@ -13390,12 +13396,12 @@ packages: '@dabh/diagnostics@2.0.3': resolution: {integrity: sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==} - '@definitelytyped/header-parser@0.2.15': - resolution: {integrity: sha512-SRUpmhQ7QZpsjLiA9SlwaD2Ct1xOc5Vt8cpZAqQ+P/puu4nNIsibCW87NKkyjCXG+MCUVFWEK7rVCTd12m2hTw==} + '@definitelytyped/header-parser@0.2.16': + resolution: {integrity: sha512-UFsgPft5bhZn07UNGz/9ck4AhdKgLFEOmi2DNr7gXcGL89zbe3u5oVafKUT8j1HOtSBjT8ZEQsXHKlbq+wwF/Q==} engines: {node: '>=18.18.0'} - '@definitelytyped/typescript-versions@0.1.5': - resolution: {integrity: sha512-XdLx3+S6zZCcG4jnG6Kqv/PlKBRTkz5M/xZUEEN9R2g6BlzbxyE+z5EzlezJqkUls53zjuOzgbkNNP4HQIfbJQ==} + '@definitelytyped/typescript-versions@0.1.6': + resolution: {integrity: sha512-gQpXFteIKrOw4ldmBZQfBrD3WobaIG1SwOr/3alXWkcYbkOWa2NRxQbiaYQ2IvYTGaZK26miJw0UOAFiuIs4gA==} engines: {node: '>=18.18.0'} '@definitelytyped/utils@0.1.8': @@ -26712,13 +26718,13 @@ snapshots: enabled: 2.0.0 kuler: 2.0.0 - '@definitelytyped/header-parser@0.2.15': + '@definitelytyped/header-parser@0.2.16': dependencies: - '@definitelytyped/typescript-versions': 0.1.5 + '@definitelytyped/typescript-versions': 0.1.6 '@definitelytyped/utils': 0.1.8 semver: 7.6.3 - '@definitelytyped/typescript-versions@0.1.5': {} + '@definitelytyped/typescript-versions@0.1.6': {} '@definitelytyped/utils@0.1.8': dependencies: @@ -32216,7 +32222,7 @@ snapshots: dts-critic@3.3.11(typescript@5.7.2): dependencies: - '@definitelytyped/header-parser': 0.2.15 + '@definitelytyped/header-parser': 0.2.16 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -32226,8 +32232,8 @@ snapshots: dtslint@4.2.1(typescript@5.7.2): dependencies: - '@definitelytyped/header-parser': 0.2.15 - '@definitelytyped/typescript-versions': 0.1.5 + '@definitelytyped/header-parser': 0.2.16 + '@definitelytyped/typescript-versions': 0.1.6 '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11(typescript@5.7.2) fs-extra: 6.0.1 From 0629d53b83b7d34f7dd35e2e557690b54df6eaa7 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 3 Dec 2024 15:56:34 -0300 Subject: [PATCH 3/9] some adjusts --- .../zoho_books/actions/create-estimate/create-estimate.mjs | 2 +- .../zoho_books/actions/create-invoice/create-invoice.mjs | 4 ++-- components/zoho_books/actions/create-item/create-item.mjs | 2 +- .../zoho_books/actions/make-api-call/make-api-call.mjs | 3 ++- components/zoho_books/common/utils.mjs | 7 +++++++ components/zoho_books/sources/new-expense/new-expense.mjs | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/zoho_books/actions/create-estimate/create-estimate.mjs b/components/zoho_books/actions/create-estimate/create-estimate.mjs index dfdafe1f36010..2e137819a4d85 100644 --- a/components/zoho_books/actions/create-estimate/create-estimate.mjs +++ b/components/zoho_books/actions/create-estimate/create-estimate.mjs @@ -5,7 +5,7 @@ import zohoBooks from "../../zoho_books.app.mjs"; 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/items/#create-an-item)", + description: "Creates a new estimate. [See the documentation](https://www.zoho.com/books/api/v3/estimates/#create-an-estimate)", version: "0.0.1", type: "action", props: { diff --git a/components/zoho_books/actions/create-invoice/create-invoice.mjs b/components/zoho_books/actions/create-invoice/create-invoice.mjs index d8a75f975223b..bcfe3c3f3f043 100644 --- a/components/zoho_books/actions/create-invoice/create-invoice.mjs +++ b/components/zoho_books/actions/create-invoice/create-invoice.mjs @@ -20,7 +20,7 @@ export default { invoiceNumber: { type: "string", label: "Invoice Number", - description: "Search invoices by invoice number.Variants: `invoice_number_startswith` and `invoice_number_contains`. Max-length [100]", + description: "Search invoices by invoice number. Max-length [100]", optional: true, }, placeOfSupply: { @@ -53,7 +53,7 @@ export default { date: { type: "string", label: "Date", - description: "Search invoices by invoice date. Default date format is yyyy-mm-dd. `Variants: due_date_start, due_date_end, due_date_before and due_date_after.`", + description: "Search invoices by invoice date. Default date format is yyyy-mm-dd.", optional: true, }, paymentTerms: { diff --git a/components/zoho_books/actions/create-item/create-item.mjs b/components/zoho_books/actions/create-item/create-item.mjs index 6f7d737e94ba4..85f792da09a8e 100644 --- a/components/zoho_books/actions/create-item/create-item.mjs +++ b/components/zoho_books/actions/create-item/create-item.mjs @@ -140,7 +140,7 @@ export default { itemTaxPreferences: { type: "string[]", label: "Item Tax Preferences", - desctiption: "A list of item tax objects. **Format: {\"tax_id\":\"12312312031200\",\"tax_specification\":\"intra\"}**", + description: "A list of item tax objects. **Format: {\"tax_id\":\"12312312031200\",\"tax_specification\":\"intra\"}**", optional: true, }, }, 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 cac6e8601f1fc..cdddee7f342c6 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 @@ -1,4 +1,5 @@ // legacy_hash_id: a_PNinw1 +import { checkUrl } from "../../common/utils.mjs"; import zohoBooks from "../../zoho_books.app.mjs"; export default { @@ -48,7 +49,7 @@ export default { async run({ $ }) { const response = await this.zohoBooks._makeRequest({ $, - path: this.relativeUrl, + path: checkUrl(this.relativeUrl), params: this.queryString, method: this.requestMethod, headers: this.headers, diff --git a/components/zoho_books/common/utils.mjs b/components/zoho_books/common/utils.mjs index 20c672867d52d..4d696fb8fb2c0 100644 --- a/components/zoho_books/common/utils.mjs +++ b/components/zoho_books/common/utils.mjs @@ -39,3 +39,10 @@ export const clearObj = (obj) => { : v, }), {}); }; + +export const checkUrl = (url) => { + if (url.startsWith("/books/v3")) { + return url.substring(9); + } + return url; +}; diff --git a/components/zoho_books/sources/new-expense/new-expense.mjs b/components/zoho_books/sources/new-expense/new-expense.mjs index f579e8e24d4b9..799e4cf4b6cd4 100644 --- a/components/zoho_books/sources/new-expense/new-expense.mjs +++ b/components/zoho_books/sources/new-expense/new-expense.mjs @@ -21,7 +21,7 @@ export default { return "expense_id"; }, getSummary(item) { - return `New Expense: ${item.description}`; + return `New Expense: ${item.expense_id}`; }, }, sampleEmit, From 74c0ff0ece0f480920b2f61cbe95edfa8b0f0864 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 4 Dec 2024 14:20:32 -0300 Subject: [PATCH 4/9] some adjusts --- components/zoho_books/actions/make-api-call/make-api-call.mjs | 2 +- components/zoho_books/common/utils.mjs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 cdddee7f342c6..33e5e0f44a313 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 @@ -56,7 +56,7 @@ export default { data: this.requestBody, }); - $.export("$summary", `Successfully called the path: ${this.path}`); + $.export("$summary", `Successfully called the path: ${this.relativeUrl}`); return response; }, }; diff --git a/components/zoho_books/common/utils.mjs b/components/zoho_books/common/utils.mjs index 4d696fb8fb2c0..e03aac64cb2e5 100644 --- a/components/zoho_books/common/utils.mjs +++ b/components/zoho_books/common/utils.mjs @@ -44,5 +44,8 @@ export const checkUrl = (url) => { if (url.startsWith("/books/v3")) { return url.substring(9); } + if (url.startsWith("/v3")) { + return url.substring(3); + } return url; }; From 21b5042315df02b411f4b99a388645352bf3706e Mon Sep 17 00:00:00 2001 From: Leo Vu Date: Thu, 5 Dec 2024 08:45:38 +0700 Subject: [PATCH 5/9] Improve description --- components/zoho_books/actions/make-api-call/make-api-call.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 33e5e0f44a313..7c1d0c4d5c928 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 @@ -31,7 +31,7 @@ export default { relativeUrl: { type: "string", label: "Relative Url", - description: "A path relative to Zoho Books to send the request against.", + description: "A path relative to Zoho Books to send the request against. For example, use `/expenses` for [List Expenses API](https://www.zoho.com/books/api/v3/expenses/#list-expenses). [See the documentation](https://www.zoho.com/books/api/v3/introduction/)", }, headers: { type: "object", From 424a86c447a0103287b6a63761d18b1968e7cf7f Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 5 Dec 2024 18:30:58 -0300 Subject: [PATCH 6/9] change polling to webhooks --- components/zoho_books/sources/common/base.mjs | 71 +++++------ .../new-customer-instant.mjs | 26 ++++ .../new-customer-instant/test-event.mjs | 114 ++++++++++++++++++ .../sources/new-customer/new-customer.mjs | 28 ----- .../sources/new-customer/test-event.mjs | 20 --- .../new-expense-instant.mjs} | 22 ++-- .../new-expense-instant/test-event.mjs | 97 +++++++++++++++ .../sources/new-expense/test-event.mjs | 25 ---- .../new-sales-order-instant.mjs | 26 ++++ .../new-sales-order-instant/test-event.mjs | 110 +++++++++++++++++ .../new-sales-order/new-sales-order.mjs | 28 ----- .../sources/new-sales-order/test-event.mjs | 30 ----- components/zoho_books/zoho_books.app.mjs | 13 ++ 13 files changed, 424 insertions(+), 186 deletions(-) create mode 100644 components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs create mode 100644 components/zoho_books/sources/new-customer-instant/test-event.mjs delete mode 100644 components/zoho_books/sources/new-customer/new-customer.mjs delete mode 100644 components/zoho_books/sources/new-customer/test-event.mjs rename components/zoho_books/sources/{new-expense/new-expense.mjs => new-expense-instant/new-expense-instant.mjs} (50%) create mode 100644 components/zoho_books/sources/new-expense-instant/test-event.mjs delete mode 100644 components/zoho_books/sources/new-expense/test-event.mjs create mode 100644 components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs create mode 100644 components/zoho_books/sources/new-sales-order-instant/test-event.mjs delete mode 100644 components/zoho_books/sources/new-sales-order/new-sales-order.mjs delete mode 100644 components/zoho_books/sources/new-sales-order/test-event.mjs 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 }) { From 64da116b1d8a76e111fba84b07ce279089d03481 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 5 Dec 2024 18:41:52 -0300 Subject: [PATCH 7/9] bump versions --- .../create-customer-payment/create-customer-payment.mjs | 2 +- .../zoho_books/actions/create-customer/create-customer.mjs | 2 +- .../zoho_books/actions/create-employee/create-employee.mjs | 2 +- .../zoho_books/actions/create-estimate/create-estimate.mjs | 4 ++-- .../zoho_books/actions/create-invoice/create-invoice.mjs | 2 +- components/zoho_books/actions/create-item/create-item.mjs | 2 +- .../actions/create-salesorder/create-salesorder.mjs | 2 +- .../zoho_books/actions/delete-contact/delete-contact.mjs | 2 +- components/zoho_books/actions/get-invoice/get-invoice.mjs | 2 +- components/zoho_books/actions/get-item/get-item.mjs | 2 +- components/zoho_books/actions/list-contacts/list-contacts.mjs | 2 +- components/zoho_books/actions/list-expenses/list-expenses.mjs | 2 +- components/zoho_books/actions/list-invoices/list-invoices.mjs | 2 +- components/zoho_books/actions/make-api-call/make-api-call.mjs | 2 +- .../actions/update-salesorder/update-salesorder.mjs | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) 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, From 83daab7ce8b613b54f08be71b3837b858896655d Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 5 Dec 2024 18:42:12 -0300 Subject: [PATCH 8/9] bump versions --- components/zoho_books/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": [ From abf5f16e88a0eee820554272c9a639acebf96345 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 5 Dec 2024 18:53:25 -0300 Subject: [PATCH 9/9] fix branch --- .../sources/new-customer/new-customer.mjs | 28 ----------------- .../sources/new-customer/test-event.mjs | 20 ------------- .../sources/new-expense/new-expense.mjs | 28 ----------------- .../sources/new-expense/test-event.mjs | 25 ---------------- .../new-sales-order/new-sales-order.mjs | 28 ----------------- .../sources/new-sales-order/test-event.mjs | 30 ------------------- 6 files changed, 159 deletions(-) delete mode 100644 components/zoho_books/sources/new-customer/new-customer.mjs delete mode 100644 components/zoho_books/sources/new-customer/test-event.mjs delete mode 100644 components/zoho_books/sources/new-expense/new-expense.mjs delete mode 100644 components/zoho_books/sources/new-expense/test-event.mjs delete mode 100644 components/zoho_books/sources/new-sales-order/new-sales-order.mjs delete mode 100644 components/zoho_books/sources/new-sales-order/test-event.mjs 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/new-expense.mjs deleted file mode 100644 index 799e4cf4b6cd4..0000000000000 --- a/components/zoho_books/sources/new-expense/new-expense.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-expense", - name: "New Expense", - 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; - }, - getFieldName() { - return "expenses"; - }, - getFieldId() { - return "expense_id"; - }, - getSummary(item) { - return `New Expense: ${item.expense_id}`; - }, - }, - sampleEmit, -}; 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/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