From e79d3e87c94eebded11a7ba7354f7c7a6f08f2ec Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 15 Aug 2025 11:35:51 -0300 Subject: [PATCH 1/9] Update Xero Accounting API components and actions, including version bumps and new features. Key changes include: - Bumped version to 0.4.0 for the Xero Accounting API package. - Added new actions for creating, updating, and deleting tracking categories and options. - Enhanced existing actions with improved error handling and response formatting. - Refactored code for better readability and maintainability, including consistent use of the xeroAccountingApi instance. - Updated utility functions and constants for better modularity. This update improves the overall functionality and usability of the Xero Accounting API integration. --- .../add-line-item-to-invoice.mjs | 23 +- .../create-bank-transaction.mjs | 93 ++-- .../actions/create-bill/create-bill.mjs | 53 +-- .../create-credit-note/create-credit-note.mjs | 97 +++-- .../create-history-note.mjs | 43 +- .../actions/create-item/create-item.mjs | 73 ++-- .../actions/create-payment/create-payment.mjs | 121 +++--- .../create-tracking-category.mjs | 62 +++ .../create-update-contact.mjs | 8 +- .../delete-tracking-category-option.mjs | 55 +++ .../delete-tracking-category.mjs | 42 ++ .../download-invoice/download-invoice.mjs | 42 +- .../email-an-invoice/email-an-invoice.mjs | 42 +- .../actions/find-contact/find-contact.mjs | 18 +- .../actions/find-invoice/find-invoice.mjs | 10 +- .../find-or-create-contact.mjs | 23 +- .../get-bank-statements-report.mjs | 52 +-- .../get-bank-summary/get-bank-summary.mjs | 53 +-- .../actions/get-contact/get-contact.mjs | 41 +- .../get-history-of-changes.mjs | 40 +- .../get-invoice-online-url.mjs | 41 +- .../actions/get-invoice/get-invoice.mjs | 41 +- .../actions/get-item/get-item.mjs | 41 +- .../get-tenant-connections.mjs | 23 +- .../get-tracking-category.mjs | 37 ++ .../actions/list-contacts/list-contacts.mjs | 58 ++- .../list-credit-notes/list-credit-notes.mjs | 55 +-- .../actions/list-invoices/list-invoices.mjs | 72 ++-- .../list-manual-journals.mjs | 55 +-- .../list-tracking-categories.mjs | 27 ++ .../make-an-api-call/make-an-api-call.mjs | 50 ++- .../update-tracking-category-option.mjs | 74 ++++ .../update-tracking-category.mjs | 62 +++ .../actions/upload-file/upload-file.mjs | 22 +- .../xero-accounting-create-employee.mjs | 49 ++- ...ro-accounting-create-or-update-contact.mjs | 113 ++--- .../xero-accounting-update-contact.mjs | 115 +++-- .../xero-create-purchase-bill.mjs | 77 ++-- .../xero-create-sales-invoice.mjs | 49 ++- .../xero_accounting_api/common/constants.mjs | 13 +- .../xero_accounting_api/common/util.mjs | 37 +- components/xero_accounting_api/package.json | 2 +- .../new-updated-contact.mjs | 14 +- .../new-updated-invoice.mjs | 14 +- .../webhook-event-received.mjs | 4 +- .../xero_accounting_api.app.mjs | 400 +++++++++++++++--- 46 files changed, 1630 insertions(+), 906 deletions(-) create mode 100644 components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs create mode 100644 components/xero_accounting_api/actions/delete-tracking-category-option/delete-tracking-category-option.mjs create mode 100644 components/xero_accounting_api/actions/delete-tracking-category/delete-tracking-category.mjs create mode 100644 components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs create mode 100644 components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs create mode 100644 components/xero_accounting_api/actions/update-tracking-category-option/update-tracking-category-option.mjs create mode 100644 components/xero_accounting_api/actions/update-tracking-category/update-tracking-category.mjs diff --git a/components/xero_accounting_api/actions/add-line-item-to-invoice/add-line-item-to-invoice.mjs b/components/xero_accounting_api/actions/add-line-item-to-invoice/add-line-item-to-invoice.mjs index 75c07ef702c54..4fd218b35e693 100644 --- a/components/xero_accounting_api/actions/add-line-item-to-invoice/add-line-item-to-invoice.mjs +++ b/components/xero_accounting_api/actions/add-line-item-to-invoice/add-line-item-to-invoice.mjs @@ -1,14 +1,14 @@ -import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; import { - removeNullEntries, formatLineItems, + removeNullEntries, } from "../../common/util.mjs"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-add-line-item-to-invoice", name: "Add Items to Existing Sales Invoice", description: "Adds line items to an existing sales invoice. [See the docs here](https://developer.xero.com/documentation/api/accounting/invoices#post-invoices)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { xeroAccountingApi, @@ -35,16 +35,15 @@ export default { }, }, async run({ $ }) { - const { - tenantId, - invoiceId, - lineItems, - } = this; - const data = removeNullEntries({ - InvoiceID: invoiceId, - LineItems: formatLineItems(lineItems), + const response = await this.xeroAccountingApi.createInvoice({ + $, + tenantId: this.tenantId, + data: removeNullEntries({ + InvoiceID: this.invoiceId, + LineItems: formatLineItems(this.lineItems), + }), }); - const response = await this.xeroAccountingApi.createInvoice($, tenantId, data); + response && $.export("$summary", "Line item created successfully"); return response; }, diff --git a/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs b/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs index a5fabb42198ca..10eca976a2377 100644 --- a/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs +++ b/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs @@ -1,42 +1,47 @@ -// legacy_hash_id: a_WYiwz2 -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-create-bank-transaction", name: "Create Bank Transaction", - version: "0.1.1", + description: "Create a new bank transaction [See the documentation](https://developer.xero.com/documentation/api/accounting/banktransactions#put-banktransactions)", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - bank_account_code: { + bankAccountCode: { type: "string", + label: "Bank account code", description: "The Account Code of the Bank Account of the transaction. If Code is not included then AccountID is required.", optional: true, }, - bank_account_id: { + bankAccountId: { type: "string", + label: "Bank account ID", description: "The ID of the Bank Account transaction. If AccountID is not included then Code is required.", optional: true, }, - contact_id: { + contactId: { type: "string", + label: "Contact ID", description: "Id of the contact associated to the bank transaction.", optional: true, }, - contact_name: { + contactName: { type: "string", + label: "Contact name", description: "Name of the contact associated to the bank transaction. If there is no contact matching this name, a new contact is created.", optional: true, }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, type: { type: "string", + label: "Type", description: "See [Bank Transaction Types](https://developer.xero.com/documentation/api/types#BankTransactionTypes)", options: [ "RECEIVE", @@ -47,42 +52,50 @@ export default { "SPEND-PREPAYMENT", ], }, - line_items: { + lineItems: { type: "object", + label: "Line items", description: "See [LineItems](https://developer.xero.com/documentation/api/banktransactions#LineItemsPOST). The LineItems element can contain any number of individual LineItem sub-elements. At least **one** is required to create a bank transaction.", }, - is_reonciled: { + isReconciled: { type: "boolean", + label: "Is reconciled", description: "Boolean to show if transaction is reconciled. Conversion related apps can set the IsReconciled flag in scenarios when a matching bank statement line is not available. [Learn more](http://help.xero.com/#Q_BankRecNoImport)", optional: true, }, date: { type: "string", + label: "Date", description: "Date of transaction - YYYY-MM-DD", optional: true, }, reference: { type: "string", + label: "Reference", description: "Reference for the transaction. Only supported for SPEND and RECEIVE transactions.", optional: true, }, - currency_code: { + currencyCode: { type: "string", + label: "Currency code", description: "The currency that bank transaction has been raised in (see [Currencies](https://developer.xero.com/documentation/api/currencies)). Setting currency is only supported on overpayments.", optional: true, }, - currency_rate: { + currencyRate: { type: "string", + label: "Currency rate", description: "Exchange rate to base currency when money is spent or received. e.g. 0.7500 Only used for bank transactions in non base currency. If this isn't specified for non base currency accounts then either the user-defined rate (preference) or the [XE.com day rate](http://help.xero.com/#CurrencySettings$Rates) will be used. Setting currency is only supported on overpayments.", optional: true, }, url: { type: "string", + label: "URL", description: "URL link to a source document - shown as \"Go to App Name\"", optional: true, }, status: { type: "string", + label: "Status", description: "See [Bank Transaction Status Codes](https://developer.xero.com/documentation/api/types#BankTransactionStatuses)", optional: true, options: [ @@ -90,8 +103,9 @@ export default { "DELETED", ], }, - line_amount_types: { + lineAmountTypes: { type: "string", + label: "Line amount types", description: "Line amounts are exclusive of tax by default if you don't specify this element. See [Line Amount Types](https://developer.xero.com/documentation/api/types#LineAmountTypes)", optional: true, options: [ @@ -102,41 +116,38 @@ export default { }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/banktransactions#PUT - - if ((!this.bank_account_code && !this.bank_account_id) - || (!this.contact_id && !this.contact_name) - || !this.tenant_id || !this.type || !this.line_items) { - throw new Error("Must provide one of bank_account_code or bank_account_id, contact_id or contact_name, tenant_id, type, and line_items parameters."); + if ((!this.bankAccountCode && !this.bankAccountId) + || (!this.contactId && !this.contactName) + || !this.tenantId || !this.type || !this.lineItems) { + throw new ConfigurationError("Must provide one of **Bank Account Code** or **Bank Account ID**, **Contact ID** or **Contact Name**, **Tenant ID**, **Type**, and **Line Items** parameters."); } - return await axios($, { - method: "put", - url: "https://api.xero.com/api.xro/2.0/BankTransactions", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createBankTransaction({ + $, + tenantId: this.tenantId, data: { Type: this.type, BankAccount: { - Code: this.bank_account_code, - AccountID: this.bank_account_id, + Code: this.bankAccountCode, + AccountID: this.bankAccountId, }, Contact: { - ContactID: this.contact_id, - Name: this.contact_name, + ContactID: this.contactId, + Name: this.contactName, }, - IsReconciled: this.is_reonciled, + IsReconciled: this.isReconciled, Date: this.date, Reference: this.reference, - CurrencyCode: this.currency_code, - CurrencyRate: this.currency_rate, + CurrencyCode: this.currencyCode, + CurrencyRate: this.currencyRate, Url: this.url, Status: this.status, - Lineitems: this.line_items, - LineAmountTypes: this.line_amount_types, + Lineitems: this.lineItems, + LineAmountTypes: this.lineAmountTypes, }, }); + + $.export("$summary", `Successfully created bank transaction with ID: ${response.BankTransactions[0].BankTransactionID}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/create-bill/create-bill.mjs b/components/xero_accounting_api/actions/create-bill/create-bill.mjs index d53535bf84072..2199f33b23e4b 100644 --- a/components/xero_accounting_api/actions/create-bill/create-bill.mjs +++ b/components/xero_accounting_api/actions/create-bill/create-bill.mjs @@ -1,8 +1,8 @@ import { - removeNullEntries, deleteKeys, - isValidDate, formatLineItems, + isValidDate, + removeNullEntries, } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; @@ -10,7 +10,7 @@ export default { key: "xero_accounting_api-create-bill", name: "Create Bill", description: "Creates a new bill (Accounts Payable)[See the docs here](https://developer.xero.com/documentation/api/accounting/invoices)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { xeroAccountingApi, @@ -73,34 +73,27 @@ export default { }, }, async run({ $ }) { - const { - tenantId, - contact, - invoiceNumber, - reference, - lineItems, - date, - dueDate, - currencyCode, - } = this; - const data = removeNullEntries({ - Type: "ACCPAY", - Contact: contact?.ContactID - ? deleteKeys(contact, [ - "Name", - "FirstName", - "LastName", - "EmailAddress", - ]) - : contact, - LineItems: formatLineItems(lineItems), - Date: isValidDate(date, "Date") && date, - DueDate: isValidDate(dueDate, "DueDate") && dueDate, - CurrencyCode: currencyCode, - InvoiceNumber: invoiceNumber, - Reference: reference, + const response = await this.xeroAccountingApi.createInvoice({ + $, + tenantId: this.tenantId, + data: removeNullEntries({ + Type: "ACCPAY", + Contact: this.contact?.ContactID + ? deleteKeys(this.contact, [ + "Name", + "FirstName", + "LastName", + "EmailAddress", + ]) + : this.contact, + LineItems: formatLineItems(this.lineItems), + Date: isValidDate(this.date, "Date") && this.date, + DueDate: isValidDate(this.dueDate, "DueDate") && this.dueDate, + CurrencyCode: this.currencyCode, + InvoiceNumber: this.invoiceNumber, + Reference: this.reference, + }), }); - const response = await this.xeroAccountingApi.createInvoice($, tenantId, data); response && $.export("$summary", "Bill successfully created"); return response; }, diff --git a/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs b/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs index eccdd0f2522e5..7d9a978b71c8d 100644 --- a/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs +++ b/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs @@ -1,37 +1,40 @@ -// legacy_hash_id: a_3Lieoo -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-create-credit-note", name: "Create Credit Note", description: "Creates a new credit note.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - contact_id: { + contactId: { + label: "Contact ID", type: "string", description: "Id of the contact associated to the credit note.", optional: true, }, - contact_name: { + contactName: { type: "string", + label: "Contact Name", description: "Name of the contact associated to the credit note. If there is no contact matching this name, a new contact is created.", optional: true, }, - contact_number: { + contactNumber: { type: "string", + label: "Contact Number", description: "Number of the contact associated to the credit note. If there is no contact matching this name, a new contact is created.", optional: true, }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, type: { + label: "Type", type: "string", description: "See [Credit Note Types](https://developer.xero.com/documentation/api/types#CreditNoteTypes)", options: [ @@ -41,11 +44,13 @@ export default { }, date: { type: "string", + label: "Date", description: "The date the credit note is issued YYYY-MM-DD. If the Date element is not specified then it will default to the current date based on the timezone setting of the organisation", optional: true, }, status: { type: "string", + label: "Status", description: "See [Credit Note Status Codes](https://developer.xero.com/documentation/api/types#CreditNoteStatuses)", optional: true, options: [ @@ -57,7 +62,8 @@ export default { "VOIDED", ], }, - line_amount_types: { + lineAmountTypes: { + label: "Line amount types", type: "string", description: "See [Invoice Line Amount Types](https://developer.xero.com/documentation/api/Types#LineAmountTypes)", optional: true, @@ -67,74 +73,83 @@ export default { "NoTax", ], }, - line_items: { + lineItems: { + label: "Line items", type: "object", description: "See [Invoice Line Items](https://developer.xero.com/documentation/api/Invoices#LineItems)", optional: true, }, - currency_code: { + currencyCode: { + label: "Currency code", type: "string", description: "Currency used for the Credit Note", optional: true, }, - credit_note_number: { + creditNoteNumber: { + label: "Credit note number", type: "string", description: "[ACCRECCREDIT](https://developer.xero.com/documentation/api/types#CreditNoteTypes) - Unique alpha numeric code identifying credit note ( *when missing will auto-generate from your Organisation Invoice Settings*)\n[ACCPAYCREDIT](https://developer.xero.com/documentation/api/types#CreditNoteTypes) - non-unique alpha numeric code identifying credit note. This value will also display as Reference in the UI.", optional: true, }, reference: { + label: "Reference", type: "string", description: "ACCRECCREDIT only - additional reference number", optional: true, }, - sent_to_contact: { + sentToContact: { + label: "Sent to contact", type: "boolean", description: "Boolean to indicate if a credit note has been sent to a contact via the Xero app (currently read only)", optional: true, }, - currency_rate: { + currencyRate: { + label: "Currency rate", type: "string", description: "The currency rate for a multicurrency invoice. If no rate is specified, the [XE.com day rate](http://help.xero.com/#CurrencySettings$Rates) is used", optional: true, }, - branding_theme_id: { + brandingThemeId: { + label: "Branding theme ID", type: "string", description: "See [BrandingThemes](https://developer.xero.com/documentation/api/branding-themes)", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/credit-notes#POST - - if ((!this.contact_id && !this.contact_name && !this.contact_number) || !this.tenant_id || !this.type) { - throw new Error("Must provide one of contact_id or contact_name or contact_number, and tenant_id, type parameters."); + if (( + !this.contactId && + !this.contactName && + !this.contactNumber) || + !this.tenantId || + !this.type) { + throw new ConfigurationError("Must provide one of **Contact ID** or **Contact Name** or **Contact Number**, **Tenant ID**, and **Type** parameters."); } - return await axios($, { - method: "post", - url: "https://api.xero.com/api.xro/2.0/CreditNotes", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createCreditNote({ + $, + tenantId: this.tenantId, data: { Type: this.type, Contact: { - ContactID: this.contact_id, - ContactNumber: this.contact_number, - Name: this.contact_name, + ContactID: this.contactId, + ContactNumber: this.contactNumber, + Name: this.contactName, }, Date: this.date, Status: this.status, - LineAmountTypes: this.line_amount_types, - LineItems: this.line_items, - CurrencyCode: this.currency_code, - CreditNoteNumber: this.credit_note_number, + LineAmountTypes: this.lineAmountTypes, + LineItems: this.lineItems, + CurrencyCode: this.currencyCode, + CreditNoteNumber: this.creditNoteNumber, Reference: this.reference, - SentToContact: this.sent_to_contact, - CurrencyRate: this.currency_rate, - BrandingThemeID: this.branding_theme_id, + SentToContact: this.sentToContact, + CurrencyRate: this.currencyRate, + BrandingThemeID: this.brandingThemeId, }, }); + + $.export("$summary", `Successfully created credit note with ID: ${response.CreditNotes[0].CreditNoteID}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/create-history-note/create-history-note.mjs b/components/xero_accounting_api/actions/create-history-note/create-history-note.mjs index 66ec427f37505..1de0b9fc29653 100644 --- a/components/xero_accounting_api/actions/create-history-note/create-history-note.mjs +++ b/components/xero_accounting_api/actions/create-history-note/create-history-note.mjs @@ -1,22 +1,22 @@ -// legacy_hash_id: a_eliYe6 -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-create-history-note", name: "Create History Note", description: "Creates a new note adding it to a document.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, endpoint: { + label: "Endpoint", type: "string", description: "The URL component, endpoint of the document type to add the history note. See [supported document types](https://developer.xero.com/documentation/api/history-and-notes#SupportedDocs)", options: [ @@ -36,28 +36,26 @@ export default { ], }, guid: { + label: "GUID", type: "string", description: "Xero identifier of the document to add a history note to.", }, details: { type: "string", + label: "Details", description: "The note to be recorded against a single document. Max Length 250 characters.", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/history-and-notes#PUT - - if (!this.tenant_id || !this.endpoint || !this.guid || !this.details) { - throw new Error("Must provide tenant_id, endpoint, guid, and details parameters."); + if (!this.tenantId || !this.endpoint || !this.guid || !this.details) { + throw new ConfigurationError("Must provide **Tenant ID**, **Endpoint**, **GUID**, and **Details** parameters."); } - return await axios($, { - method: "put", - url: `https://api.xero.com/api.xro/2.0/${this.endpoint}/${this.guid}/history`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createHistoryNote({ + $, + tenantId: this.tenantId, + endpoint: this.endpoint, + guid: this.guid, data: { HistoryRecords: [ { @@ -66,5 +64,8 @@ export default { ], }, }); + + $.export("$summary", `Successfully created history note for ${this.endpoint} with ID: ${this.guid}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/create-item/create-item.mjs b/components/xero_accounting_api/actions/create-item/create-item.mjs index 172300de29524..ad431e58e32be 100644 --- a/components/xero_accounting_api/actions/create-item/create-item.mjs +++ b/components/xero_accounting_api/actions/create-item/create-item.mjs @@ -1,67 +1,76 @@ -// legacy_hash_id: a_a4ivOG -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-create-item", name: "Create Item", description: "Creates a new item.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, code: { type: "string", + label: "Code", description: "User defined item code (max length = 30)", }, - inventory_asset_account_code: { + inventoryAssetAccountCode: { type: "string", + label: "Inventory Asset Account Code", description: "The inventory asset [account](https://developer.xero.com/documentation/api/accounts/) for the item. The account must be of type INVENTORY. The COGSAccountCode in PurchaseDetails is also required to create a tracked item", optional: true, }, name: { type: "string", + label: "Name", description: "The name of the item (max length = 50)", optional: true, }, - is_sold: { + isSold: { type: "boolean", + label: "Is Sold", description: "Boolean value, defaults to true. When IsSold is true the item will be available on sales transactions in the Xero UI. If IsSold is updated to false then Description and SalesDetails values will be nulled.", optional: true, }, - is_purchased: { + isPurchased: { type: "boolean", + label: "Is Purchased", description: "Boolean value, defaults to true. When IsPurchased is true the item is available for purchase transactions in the Xero UI. If IsPurchased is updated to false then PurchaseDescription and PurchaseDetails values will be nulled.", optional: true, }, description: { type: "string", + label: "Description", description: "The sales description of the item (max length = 4000)", optional: true, }, - purchase_description: { + purchaseDescription: { type: "string", + label: "Purchase Description", description: "The purchase description of the item (max length = 4000)", optional: true, }, - purchase_details: { + purchaseDetails: { type: "string", + label: "Purchase Details", description: "See Purchases & Sales. The [PurchaseDetails](https://developer.xero.com/documentation/api/items#PurchasesSales) element can contain a number of individual sub-elements.", optional: true, }, - sales_details: { + salesDetails: { type: "string", + label: "Sales Details", description: "See Purchases & Sales. The [SalesDetails](https://developer.xero.com/documentation/api/items#PurchasesSales) element can contain a number of individual sub-elements.", optional: true, }, unitdp: { type: "string", + label: "Unitdp", description: "By default UnitPrice is returned to two decimal places.", optional: true, options: [ @@ -71,34 +80,30 @@ export default { }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/items#POST - - if (!this.tenant_id || !this.code) { - throw new Error("Must provide tenant_id, and code parameters."); + if (!this.tenantId || !this.code) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Code** parameters."); } - return await axios($, { - method: "put", - url: "https://api.xero.com/api.xro/2.0/Items", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "Accept": "application/json", - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createItem({ + $, + tenantId: this.tenantId, data: { Code: this.code, - InventoryAssetAccountCode: this.inventory_asset_account_code, + InventoryAssetAccountCode: this.inventoryAssetAccountCode, Name: this.name, - IsSold: this.is_sold, - IsPurchased: this.is_purchased, + IsSold: this.isSold, + IsPurchased: this.isPurchased, Description: this.description, - PurchaseDescription: this.purchase_description, - PurchaseDetails: this.purchase_details, - SalesDetails: this.sales_details, + PurchaseDescription: this.purchaseDescription, + PurchaseDetails: this.purchaseDetails, + SalesDetails: this.salesDetails, }, params: { unitdp: this.unitdp, }, }); + + $.export("$summary", `Successfully created item with code: ${this.code}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/create-payment/create-payment.mjs b/components/xero_accounting_api/actions/create-payment/create-payment.mjs index 347ce3e33a5b3..7e63a0e2ed331 100644 --- a/components/xero_accounting_api/actions/create-payment/create-payment.mjs +++ b/components/xero_accounting_api/actions/create-payment/create-payment.mjs @@ -1,115 +1,129 @@ -// legacy_hash_id: a_k6irV0 -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-create-payment", name: "Create Payment", description: "Creates a new payment", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - account_id: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + accountId: { + label: "Account ID", type: "string", description: "ID of account you are using to make the payment e.g. 294b1dc5-cc47-2afc-7ec8-64990b8761b8. This account needs to be either an account of type BANK or have enable payments to this accounts switched on (see [GET Accounts](https://developer.xero.com/documentation/api/Accounts)) . See the edit account screen of your Chart of Accounts in Xero if you wish to enable payments for an account other than a bank account", optional: true, }, - account_code: { + accountCode: { + label: "Account Code", type: "string", description: "Code of account you are using to make the payment e.g. 001 ( note: *not all accounts have a code value*)", optional: true, }, - invoice_id: { + invoiceId: { + label: "Invoice ID", type: "string", description: "ID of the invoice you are applying payment to e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9", optional: true, }, - credit_note_id: { + creditNoteId: { + label: "Credit Note ID", type: "string", description: "ID of the credit note you are applying payment to e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9", optional: true, }, - prepayment_id: { + prepaymentId: { + label: "Prepayment ID", type: "string", description: "ID of the prepayment you are applying payment to e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9", optional: true, }, - overpayment_id: { + overpaymentId: { + label: "Overpayment ID", type: "string", description: "ID of the overpayment you are applying payment to e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9", optional: true, }, - invoice_number: { + invoiceNumber: { + label: "Invoice Number", type: "string", description: "Number of invoice you are applying payment to e.g. INV-4003", optional: true, }, - credit_note_number: { + creditNoteNumber: { + label: "Credit Note Number", type: "string", description: "Number of credit note you are applying payment to e.g. INV-4003", optional: true, }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, date: { + label: "Date", type: "string", description: "Date the payment is being made (YYYY-MM-DD) e.g. 2009-09-06", optional: true, }, - currency_rate: { + currencyRate: { + label: "Currency Rate", type: "string", description: "Exchange rate when payment is received. Only used for non base currency invoices and credit notes e.g. 0.7500", optional: true, }, amount: { + label: "Amount", type: "string", description: "The amount of the payment. Must be less than or equal to the outstanding amount owing on the invoice e.g. 200.00", optional: true, }, reference: { + label: "Reference", type: "string", description: "An optional description for the payment e.g. Direct Debit", optional: true, }, - is_reconciled: { + isReconciled: { + label: "Is Reconciled", type: "boolean", description: "A boolean indicating whether the payment has been reconciled.", optional: true, }, status: { + label: "Status", type: "string", description: "The [status](https://developer.xero.com/documentation/api/types#PaymentStatusCodes) of the payment.", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/payments#PUT - - if ((!this.account_id && !this.account_code) - || (!this.invoice_id && !this.credit_note_id && !this.prepayment_id && !this.overpayment_id && !this.invoice_number && !this.credit_note_number) - || !this.tenant_id) { - throw new Error("Must provide account_id or account_code, and", "\n", "invoice_id or credit_note_id or prepayment_id or overpayment_id or invoice_number or credit_note_number,\nand tenant_id parameters."); + if ((!this.accountId && !this.accountCode) || + (!this.invoiceId && + !this.creditNoteId && + !this.prepaymentId && + !this.overpaymentId && + !this.invoiceNumber && + !this.creditNoteNumber) || + !this.tenantId) { + throw new ConfigurationError("Must provide **Account ID** or **Account Code**, and", "\n", "**Invoice ID** or **Credit Note ID** or **Prepayment ID** or **Overpayment ID** or **Invoice Number** or **Credit Note Number**,\nand **Tenant ID** parameters."); } - //Adds parameters to the requests body - var data = { + const data = { Date: this.date, - CurrencyRate: this.currency_rate, + CurrencyRate: this.currencyRate, Amount: this.amount, Reference: this.reference, - IsReconciled: this.is_reconciled, + IsReconciled: this.isReconciled, Status: this.status, }; - //Adds the account paramter to the request body - if (this.account_id) { + if (this.accountId) { data["Account"] = { - AccountID: this.account_id, + AccountID: this.accountId, }; } else { data["Account"] = { @@ -117,42 +131,39 @@ export default { }; } - //Adds the related document object where payment is applied to the request body - if (this.invoice_id) { + if (this.invoiceId) { data["Invoice"] = { - InvoiceID: this.invoice_id, + InvoiceID: this.invoiceId, }; - } else if (this.credit_note_id) { + } else if (this.creditNoteId) { data["CreditNote"] = { - CreditNoteID: this.credit_note_id, + CreditNoteID: this.creditNoteId, }; - } else if (this.prepayment_id) { + } else if (this.prepaymentId) { data["Prepayment"] = { - PrepaymentID: this.prepayment_id, + PrepaymentID: this.prepaymentId, }; - } else if (this.overpayment_id) { + } else if (this.overpaymentId) { data["Overpayment"] = { - OverpaymentID: this.overpayment_id, + OverpaymentID: this.overpaymentId, }; - } else if (this.invoice_number) { + } else if (this.invoiceNumber) { data["Invoice"] = { - InvoiceNumber: this.invoice_number, + InvoiceNumber: this.invoiceNumber, }; - } else if (this.credit_note_number) { + } else if (this.creditNoteNumber) { data["CreditNote"] = { - CreditNoteNumber: this.credit_note_number, + CreditNoteNumber: this.creditNoteNumber, }; } - //Sends the request against Xero Accounting API - return await axios($, { - method: "put", - url: "https://api.xero.com/api.xro/2.0/Payments", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createPayment({ + $, + tenantId: this.tenantId, data, }); + + $.export("$summary", `Successfully created payment with reference: ${this.reference}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs b/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs new file mode 100644 index 0000000000000..847c92d0edcac --- /dev/null +++ b/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs @@ -0,0 +1,62 @@ +import { ConfigurationError } from "@pipedream/platform"; +import { parseObject } from "../../common/util.mjs"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-create-tracking-category", + name: "Create tracking category", + description: "Create a new tracking category [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories#put-trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + name: { + type: "string", + label: "Name", + description: "The name of the tracking category", + }, + options: { + type: "string[]", + label: "Options", + description: "Options for the tracking category", + optional: true, + }, + }, + async run({ $ }) { + try { + const response = await this.xeroAccountingApi.createTrackingCategory({ + $, + tenantId: this.tenantId, + data: { + Name: this.name, + }, + }); + + const parsedOptions = parseObject(this.options); + + for (const option of parsedOptions) { + const optionResponse = await this.xeroAccountingApi.createTrackingOption({ + $, + tenantId: this.tenantId, + trackingCategoryId: response.TrackingCategories[0].TrackingCategoryID, + data: { + Name: option, + }, + }); + response.TrackingCategories[0].Options.push(optionResponse.Options[0]); + } + + $.export("$summary", `Successfully created tracking category with ID: ${response.TrackingCategories[0].TrackingCategoryID}`); + return response; + } catch (err) { + console.log(err); + throw new ConfigurationError(err.response.data.Elements[0].ValidationErrors[0].Message); + } + }, +}; diff --git a/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs b/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs index 4e54fa75486a4..a63a52b8e90f7 100644 --- a/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs +++ b/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs @@ -5,7 +5,7 @@ export default { key: "xero_accounting_api-create-update-contact", name: "Create or update contact ", description: "Creates a new contact or updates a contact if a contact already exists. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { xeroAccountingApi, @@ -99,7 +99,11 @@ export default { ContactStatus: contactStatus, }); contactID && (data.ContactID = contactID); - const response = await this.xeroAccountingApi.createContact($, tenantId, data); + const response = await this.xeroAccountingApi.createContact({ + $, + tenantId, + data, + }); response && $.export("$summary", "Contact created successfully"); return response; }, diff --git a/components/xero_accounting_api/actions/delete-tracking-category-option/delete-tracking-category-option.mjs b/components/xero_accounting_api/actions/delete-tracking-category-option/delete-tracking-category-option.mjs new file mode 100644 index 0000000000000..8c9b6e260b3e1 --- /dev/null +++ b/components/xero_accounting_api/actions/delete-tracking-category-option/delete-tracking-category-option.mjs @@ -0,0 +1,55 @@ +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-delete-tracking-category-option", + name: "Delete tracking category option", + description: "Delete a tracking category option by ID [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories#delete-trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + trackingCategoryId: { + propDefinition: [ + xeroAccountingApi, + "trackingCategoryId", + ({ tenantId }) => ({ + tenantId, + }), + ], + }, + trackingOptionId: { + propDefinition: [ + xeroAccountingApi, + "trackingOptionId", + ({ + tenantId, trackingCategoryId, + }) => ({ + tenantId, + trackingCategoryId, + }), + ], + }, + }, + async run({ $ }) { + try { + const response = await this.xeroAccountingApi.deleteTrackingOption({ + $, + tenantId: this.tenantId, + trackingCategoryId: this.trackingCategoryId, + trackingOptionId: this.trackingOptionId, + }); + + $.export("$summary", `Successfully deleted tracking category option with ID: ${this.trackingOptionId}`); + return response; + } catch ({ response: { data } }) { + throw new ConfigurationError(data.Elements[0].ValidationErrors[0].Message); + } + }, +}; diff --git a/components/xero_accounting_api/actions/delete-tracking-category/delete-tracking-category.mjs b/components/xero_accounting_api/actions/delete-tracking-category/delete-tracking-category.mjs new file mode 100644 index 0000000000000..df2610632fb71 --- /dev/null +++ b/components/xero_accounting_api/actions/delete-tracking-category/delete-tracking-category.mjs @@ -0,0 +1,42 @@ +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-delete-tracking-category", + name: "Delete tracking category", + description: "Delete a tracking category by ID [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories#delete-trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + trackingCategoryId: { + propDefinition: [ + xeroAccountingApi, + "trackingCategoryId", + ({ tenantId }) => ({ + tenantId, + }), + ], + }, + }, + async run({ $ }) { + try { + const response = await this.xeroAccountingApi.deleteTrackingCategory({ + $, + tenantId: this.tenantId, + trackingCategoryId: this.trackingCategoryId, + }); + + $.export("$summary", `Successfully deleted tracking category with ID: ${this.trackingCategoryId}`); + return response; + } catch ({ response: { data } }) { + throw new ConfigurationError(data.Elements?.[0]?.ValidationErrors?.[0]?.Message || data); + } + }, +}; diff --git a/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs b/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs index c8557cfc127c9..99180fc89f91a 100644 --- a/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs +++ b/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs @@ -1,23 +1,23 @@ -// legacy_hash_id: a_k6irBN +import { ConfigurationError } from "@pipedream/platform"; import fs from "fs"; -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-download-invoice", name: "Download Invoice", description: "Downloads an invoice as pdf file. File will be placed at the action's associated workflow temporary folder.", - version: "0.2.1", + version: "0.2.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - invoice_id: { + invoiceId: { + label: "Invoice ID", type: "string", description: "Xero generated unique identifier for the invoice to download.", }, @@ -28,27 +28,21 @@ export default { }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/invoices#get and https://developer.xero.com/documentation/api/requests-and-responses#get-individual - //For an example of this action in an workflow, see: https://pipedream.com/@sergio/xero-accounting-api-download-invoice-p_vQCgy3o/edit - - if (!this.tenant_id || !this.invoice_id) { - throw new Error("Must provide tenant_id, invoice_id parameters."); + if (!this.tenantId || !this.invoiceId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Invoice ID** parameters."); } - const data = await axios($, { - url: `https://api.xero.com/api.xro/2.0/Invoices/${this.invoice_id}`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "Accept": "application/pdf", - "xero-tenant-id": this.tenant_id, - }, + const data = await this.xeroAccountingApi.downloadInvoice({ + $, + tenantId: this.tenantId, + invoiceId: this.invoiceId, responseType: "arraybuffer", }); const invoicePdf = data.toString("base64"); const buffer = Buffer.from(invoicePdf, "base64"); const tmpDir = "/tmp"; - const invoicePath = `${tmpDir}/${this.invoice_id}.pdf`; + const invoicePath = `${tmpDir}/${this.invoiceId}.pdf`; $.export("invoice_path", invoicePath); //This is where the invoice is saved at the workflow's temporary files. fs.writeFileSync(invoicePath, buffer); console.log(`Invoice saved at: ${invoicePath}`); diff --git a/components/xero_accounting_api/actions/email-an-invoice/email-an-invoice.mjs b/components/xero_accounting_api/actions/email-an-invoice/email-an-invoice.mjs index de26d7f9cbe9c..0afd0a93457cd 100644 --- a/components/xero_accounting_api/actions/email-an-invoice/email-an-invoice.mjs +++ b/components/xero_accounting_api/actions/email-an-invoice/email-an-invoice.mjs @@ -1,40 +1,38 @@ -// legacy_hash_id: a_q1i3Aj -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-email-an-invoice", name: "Email an Invoice", description: "Triggers the email of a sales invoice out of Xero.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - invoice_id: { + invoiceId: { + label: "Invoice ID", type: "string", description: "Xero generated unique identifier for the invoice to send by email out of Xero. The invoice must be of Type ACCREC and a valid Status for sending (SUMBITTED,AUTHORISED or PAID).", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/invoices#email - - if (!this.tenant_id || !this.invoice_id) { - throw new Error("Must provide tenant_id, invoice_id parameters."); + if (!this.tenantId || !this.invoiceId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Invoice ID** parameters."); } - return await axios($, { - method: "post", - url: `https://api.xero.com/api.xro/2.0/Invoices/${this.invoice_id}/Email`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.emailInvoice({ + $, + tenantId: this.tenantId, + invoiceId: this.invoiceId, }); + + $.export("$summary", `Invoice emailed successfully: ${this.invoiceId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/find-contact/find-contact.mjs b/components/xero_accounting_api/actions/find-contact/find-contact.mjs index ed9f749a2f132..8c908b1b415e2 100644 --- a/components/xero_accounting_api/actions/find-contact/find-contact.mjs +++ b/components/xero_accounting_api/actions/find-contact/find-contact.mjs @@ -1,6 +1,7 @@ import { ConfigurationError } from "@pipedream/platform"; import { - removeNullEntries, formatQueryString, + formatQueryString, + removeNullEntries, } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; @@ -8,7 +9,7 @@ export default { key: "xero_accounting_api-find-contact", name: "Find contact. Optionally, create one if none are found", description: "Finds a contact by name or account number. Optionally, create one if none are found. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { xeroAccountingApi, @@ -112,13 +113,12 @@ export default { AccountNumber: accountNumber, ContactStatus: contactStatus, }); - const queryString = formatQueryString(findPayload, true); try { - contactDetail = await this.xeroAccountingApi.getContact( + contactDetail = await this.xeroAccountingApi.getContact({ $, tenantId, - queryString, - ); + queryParam: formatQueryString(findPayload, true), + }); } catch (error) { if (createContactIfNotFound === "Yes") { $.export("$summary", "Contact not found. Creating new contact"); @@ -131,11 +131,11 @@ export default { (!contactDetail || !contactDetail?.Contacts?.length) && createContactIfNotFound === "Yes" ) { - return await this.xeroAccountingApi.createContact( + return await this.xeroAccountingApi.createContact({ $, tenantId, - createPayload, - ); + data: createPayload, + }); } return contactDetail; }, diff --git a/components/xero_accounting_api/actions/find-invoice/find-invoice.mjs b/components/xero_accounting_api/actions/find-invoice/find-invoice.mjs index 6b68bfa07808a..84fc8619e42bd 100644 --- a/components/xero_accounting_api/actions/find-invoice/find-invoice.mjs +++ b/components/xero_accounting_api/actions/find-invoice/find-invoice.mjs @@ -8,7 +8,7 @@ export default { key: "xero_accounting_api-find-invoice", name: "Find Invoice", description: "Finds an invoice by number or reference.[See the docs here](https://developer.xero.com/documentation/api/accounting/invoices/#get-invoices)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { xeroAccountingApi, @@ -38,14 +38,18 @@ export default { tenantId, } = this; if ((invoiceNumber && reference) || (!invoiceNumber && !reference)) { - throw new ConfigurationError("Choose exclusively between Invoice Number or Reference to find an invoice."); + throw new ConfigurationError("Choose exclusively between **Invoice Number** or **Reference** to find an invoice."); } const payload = removeNullEntries({ InvoiceNumber: invoiceNumber, Reference: reference, }); const queryString = formatQueryString(payload, true); - const response = await this.xeroAccountingApi.getInvoice($, tenantId, queryString); + const response = await this.xeroAccountingApi.getInvoice({ + $, + tenantId, + queryParam: queryString, + }); response && $.export("$summary", "Invoice loaded successfully"); return response; }, diff --git a/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs b/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs index 74410ee1134f5..bf49af0a109b6 100644 --- a/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs +++ b/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs @@ -1,14 +1,15 @@ -import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; import { ConfigurationError } from "@pipedream/platform"; import { - removeNullEntries, formatQueryString, + formatQueryString, + removeNullEntries, } from "../../common/util.mjs"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-find-or-create-contact", name: "Find or Create Contact", description: "Finds a contact by email address. Optionally, create one if none are found. [See the documentation](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { xeroAccountingApi, @@ -128,7 +129,11 @@ export default { const queryString = formatQueryString({ EmailAddress: this.emailAddress, }, true); - const contactDetail = await this.xeroAccountingApi.getContact($, this.tenantId, queryString); + const contactDetail = await this.xeroAccountingApi.getContact({ + $, + tenantId: this.tenantId, + queryParam: queryString, + }); const found = contactDetail?.Contacts?.length; if (!this.createContactIfNotFound && !found) { @@ -147,9 +152,9 @@ export default { || this.postalCode || this.country; if (addressEntered && !this.addressType) { - throw new ConfigurationError("Address Type is required when entering address information."); + throw new ConfigurationError("**Address Type** is required when entering address information."); } else if (!addressEntered && this.addressType) { - throw new ConfigurationError("Must enter address information along with Address Type."); + throw new ConfigurationError("Must enter address information along with **Address Type**."); } const createPayload = removeNullEntries({ @@ -182,7 +187,11 @@ export default { : undefined, }); - const response = await this.xeroAccountingApi.createContact($, this.tenantId, createPayload); + const response = await this.xeroAccountingApi.createContact({ + $, + tenantId: this.tenantId, + data: createPayload, + }); if (response?.Contacts?.length) { $.export("$summary", `Successfully created new contact with ID ${response.Contacts[0].ContactID}.`); } diff --git a/components/xero_accounting_api/actions/get-bank-statements-report/get-bank-statements-report.mjs b/components/xero_accounting_api/actions/get-bank-statements-report/get-bank-statements-report.mjs index 7e8a0f66b85d1..ab541d6a3ccf7 100644 --- a/components/xero_accounting_api/actions/get-bank-statements-report/get-bank-statements-report.mjs +++ b/components/xero_accounting_api/actions/get-bank-statements-report/get-bank-statements-report.mjs @@ -1,54 +1,54 @@ -// legacy_hash_id: a_zNiJzL -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-bank-statements-report", name: "Bank Statements Report", description: "Gets bank statements for the specified bank account.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - bank_account_id: { + bankAccountId: { + label: "Bank Account ID", type: "string", description: "Xero identifier of the bank account to get bank statements of", }, - from_date: { + fromDate: { + label: "From Date", type: "string", description: "Get the bank statements of the specified bank account from this date", optional: true, }, - to_date: { + toDate: { + label: "To Date", type: "string", description: "Get the bank statements of the specified bank account to this date", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/api-overview - - if (!this.tenant_id || !this.bank_account_id) { - throw new Error("Must provide tenant_id, bank_account_id parameters."); + if (!this.tenantId || !this.bankAccountId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Bank Account ID** parameters."); } - return await axios($, { - url: "https://api.xero.com/api.xro/2.0/Reports/BankStatement", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getBankStatementsReport({ + $, + tenantId: this.tenantId, params: { - fromDate: this.from_date, - toDate: this.to_date, - bankAccountID: this.bank_account_id, + bankAccountId: this.bankAccountId, + fromDate: this.fromDate, + toDate: this.toDate, }, }); + + $.export("$summary", `Bank statements report retrieved successfully: ${this.bankAccountId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-bank-summary/get-bank-summary.mjs b/components/xero_accounting_api/actions/get-bank-summary/get-bank-summary.mjs index ec77bc96ebd03..11480eb69e9d6 100644 --- a/components/xero_accounting_api/actions/get-bank-summary/get-bank-summary.mjs +++ b/components/xero_accounting_api/actions/get-bank-summary/get-bank-summary.mjs @@ -1,49 +1,54 @@ -// legacy_hash_id: a_K5i5rd -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-bank-summary", name: "Get Bank Summary", description: "Gets the balances and cash movements for each bank account.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { + bankAccountId: { + label: "Bank Account ID", type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + description: "Id of the bank account to get the summary for.", }, - form_date: { + fromDate: { + label: "From Date", type: "string", - description: "Get the balances and cash movements for each bank account from this date", + description: "Get the balances and cash movements for the specified bank account from this date", optional: true, }, - to_date: { + toDate: { + label: "To Date", type: "string", - description: "Get the balances and cash movements for each bank account to this date", + description: "Get the balances and cash movements for the specified bank account to this date", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/reports#BankSummary - - if (!this.tenant_id) { - throw new Error("Must provide tenant_id parameter."); + if (!this.tenantId || !this.bankAccountId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Bank Account ID** parameters."); } - return await axios($, { - url: "https://api.xero.com/api.xro/2.0/Reports/BankSummary", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getBankSummary({ + $, + tenantId: this.tenantId, + bankAccountId: this.bankAccountId, params: { - fromDate: this.form_date, - toDate: this.to_date, + fromDate: this.fromDate, + toDate: this.toDate, }, }); + + $.export("$summary", `Bank summary retrieved successfully: ${this.bankAccountId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-contact/get-contact.mjs b/components/xero_accounting_api/actions/get-contact/get-contact.mjs index 92c3e12de689a..eea73f3be1bc5 100644 --- a/components/xero_accounting_api/actions/get-contact/get-contact.mjs +++ b/components/xero_accounting_api/actions/get-contact/get-contact.mjs @@ -1,39 +1,38 @@ -// legacy_hash_id: a_67iL6R -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-contact", name: "Get Contact", description: "Gets details of a contact.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - contact_identifier: { + contactIdentifier: { type: "string", description: "Xero identifier of the contact to get. Possible values: \n* **ContactID** - The Xero identifier for a contact e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **ContactNumber** - A custom identifier specified from another system e.g. a CRM system has a contact number of CUST100", + label: "Contact Identifier", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/contacts - - if (!this.tenant_id || !this.contact_identifier) { - throw new Error("Must provide tenant_id, contact_identifier parameters."); + if (!this.tenantId || !this.contactIdentifier) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Contact Identifier** parameters."); } - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/Contacts/${this.contact_identifier}`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getContactById({ + $, + tenantId: this.tenantId, + contactIdentifier: this.contactIdentifier, }); + + $.export("$summary", `Contact retrieved successfully: ${this.contactIdentifier}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-history-of-changes/get-history-of-changes.mjs b/components/xero_accounting_api/actions/get-history-of-changes/get-history-of-changes.mjs index 4a037d7e379b0..74038cf9da424 100644 --- a/components/xero_accounting_api/actions/get-history-of-changes/get-history-of-changes.mjs +++ b/components/xero_accounting_api/actions/get-history-of-changes/get-history-of-changes.mjs @@ -1,22 +1,22 @@ -// legacy_hash_id: a_a4ivAG -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-history-of-changes", name: "Get History of Changes", description: "Gets the history of changes to a single existing document.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, endpoint: { + label: "Endpoint", type: "string", description: "The URL component, endpoint of the document type to get history changes. See [supported document types](https://developer.xero.com/documentation/api/history-and-notes#SupportedDocs)", options: [ @@ -36,23 +36,23 @@ export default { ], }, guid: { + label: "GUID", type: "string", description: "Xero identifier of the document to get history changes of.", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/history-and-notes#GET - - if (!this.tenant_id || !this.endpoint || !this.guid) { - throw new Error("Must provide tenant_id, endpoint, and guid parameters."); + if (!this.tenantId || !this.endpoint || !this.guid) { + throw new ConfigurationError("Must provide **Tenant ID**, **Endpoint**, and **GUID** parameters."); } - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/${this.endpoint}/${this.guid}/history`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getHistoryOfChanges({ + $, + endpoint: this.endpoint, + guid: this.guid, }); + + $.export("$summary", `History of changes retrieved successfully: ${this.guid}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs b/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs index 3a430d75b5735..d3cf1e7111878 100644 --- a/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs +++ b/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs @@ -1,39 +1,38 @@ -// legacy_hash_id: a_gniWnr -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-invoice-online-url", name: "Get Sales Invoice Online URL", description: "Retrieves the online sales invoice URL.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - invoice_id: { + invoiceId: { + label: "Invoice ID", type: "string", description: "Xero generated unique identifier for the invoice to retrieve its online url.", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/invoices#onlineinvoice - - if (!this.tenant_id || !this.invoice_id) { - throw new Error("Must provide tenant_id, invoice_id parameters."); + if (!this.tenantId || !this.invoiceId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Invoice ID** parameters."); } - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/Invoices/${this.invoice_id}/OnlineInvoice`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getInvoiceOnlineUrl({ + $, + tenantId: this.tenantId, + invoiceId: this.invoiceId, }); + + $.export("$summary", `Invoice online URL retrieved successfully: ${this.invoiceId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs b/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs index 1df0d55be1405..b980e3810b1bc 100644 --- a/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs +++ b/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs @@ -1,37 +1,38 @@ -// legacy_hash_id: a_52ieOd -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-invoice", name: "Get Invoice", description: "Gets details of an invoice.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - }, - invoice_id: { + invoiceId: { + label: "Invoice ID", + description: "The ID of the invoice to get.", type: "string", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/invoices#get - - if (!this.tenant_id || !this.invoice_id) { - throw new Error("Must provide tenant_id, invoice_id parameters."); + if (!this.tenantId || !this.invoiceId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Invoice ID** parameters."); } - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/Invoices/${this.invoice_id}`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getInvoiceById({ + $, + tenantId: this.tenantId, + invoiceId: this.invoiceId, }); + + $.export("$summary", `Invoice retrieved successfully: ${this.invoiceId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-item/get-item.mjs b/components/xero_accounting_api/actions/get-item/get-item.mjs index b6e307af0d742..980efc3f7a0e2 100644 --- a/components/xero_accounting_api/actions/get-item/get-item.mjs +++ b/components/xero_accounting_api/actions/get-item/get-item.mjs @@ -1,39 +1,38 @@ -// legacy_hash_id: a_8Ki04R -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-item", name: "Get Item", description: "Gets details of an item.", - version: "0.2.1", + version: "0.2.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - item_id: { + itemId: { + label: "Item ID", type: "string", description: "You can specify an individual record by appending the value to the endpoint, i.e.\n**GET https://.../Items/{identifier}**. Possible values:\n* **ItemID** - The Xero identifier for an Item e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **Code**- The user defined code of an item e.g. ITEM-001", }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/items#GET - - if (!this.tenant_id || !this.item_id) { - throw new Error("Must provide tenant_id, item_id parameters."); + if (!this.tenantId || !this.itemId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Item ID** parameters."); } - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/Items/${this.item_id}`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.getItemById({ + $, + tenantId: this.tenantId, + itemId: this.itemId, }); + + $.export("$summary", `Item retrieved successfully: ${this.itemId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-tenant-connections/get-tenant-connections.mjs b/components/xero_accounting_api/actions/get-tenant-connections/get-tenant-connections.mjs index c2f7699fab83c..1e81d3993c7b2 100644 --- a/components/xero_accounting_api/actions/get-tenant-connections/get-tenant-connections.mjs +++ b/components/xero_accounting_api/actions/get-tenant-connections/get-tenant-connections.mjs @@ -1,27 +1,20 @@ -// legacy_hash_id: a_vgidpp -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-get-tenant-connections", name: "Get Tenant Connections", description: "Gets the tenants connections the user is authorized to access", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, + xeroAccountingApi, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/oauth2/auth-flow - //Step 5. Check the tenants you're authorized to access - - return await axios($, { - url: "https://api.xero.com/connections", - headers: { - Authorization: `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - }, + const response = await this.xeroAccountingApi.getTenantConnections({ + $, }); + + $.export("$summary", "Successfully fetched tenant connections"); + return response; }, }; diff --git a/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs b/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs new file mode 100644 index 0000000000000..7872164bd4220 --- /dev/null +++ b/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs @@ -0,0 +1,37 @@ +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-get-tracking-category", + name: "Get tracking category", + description: "Get information from a tracking category by ID [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories#get-trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + trackingCategoryId: { + propDefinition: [ + xeroAccountingApi, + "trackingCategoryId", + ({ tenantId }) => ({ + tenantId, + }), + ], + }, + }, + async run({ $ }) { + const response = await this.xeroAccountingApi.getTrackingCategory({ + $, + tenantId: this.tenantId, + trackingCategoryId: this.trackingCategoryId, + }); + + $.export("$summary", `Successfully fetched tracking category with ID: ${this.trackingCategoryId}`); + return response; + }, +}; diff --git a/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs b/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs index 0246a8471c6e1..e918e1786d2be 100644 --- a/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs +++ b/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs @@ -1,77 +1,68 @@ -// legacy_hash_id: a_Q3ixRN -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-list-contacts", name: "List Contacts", description: "Lists information from contacts in the given tenant id as per filter parameters.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - contact_identifier: { + contactIdentifier: { + label: "Contact Identifier", type: "string", description: "A contact identifier. Possible values: \n* **ContactID** - The Xero identifier for a contact e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **ContactNumber** - A custom identifier specified from another system e.g. a CRM system has a contact number of CUST100", optional: true, }, - modified_after: { + modifiedAfter: { + label: "Modified After", + description: "Filter by a date. Only contacts modified since this date will be returned. Format: YYYY-MM-DD", type: "string", optional: true, }, ids: { + label: "IDs", type: "string", description: "Filter by a comma-separated list of ContactIDs. Allows you to retrieve a specific set of contacts in a single call. See [details.](https://developer.xero.com/documentation/api/contacts#optimised-queryparameters)", optional: true, }, where: { + label: "Where", type: "string", description: "Filter using the where parameter. We recommend you limit filtering to the [optimised elements](https://developer.xero.com/documentation/api/contacts#optimised-parameters) only.", optional: true, }, order: { + label: "Order", type: "string", description: "Order by any element returned ([*see Order By.*](https://developer.xero.com/documentation/api/requests-and-responses#ordering))", optional: true, }, page: { + label: "Page", type: "string", description: "Up to 100 contacts will be returned per call when the page parameter is used e.g. page=1.", optional: true, }, includeArchived: { + label: "Include Archived", type: "boolean", description: "e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included in the response.", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/contacts - - if (!this.tenant_id) { - throw new Error("Must provide tenant_id parameter."); - } - - const contactIdentifier = this.contact_identifier || ""; - - var headers = { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }; - - if (this.modified_after) { - headers["If-Modified-Since"] = this.modified_after; - } - - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/Contacts/${contactIdentifier}`, - headers, + const response = await this.xeroAccountingApi.listContacts({ + $, + tenantId: this.tenantId, + contactIdentifier: this.contactIdentifier, + modifiedAfter: this.modifiedAfter, params: { IDs: this.ids, Where: this.where, @@ -80,5 +71,8 @@ export default { includeArchived: this.includeArchived, }, }); + + $.export("$summary", `Successfully fetched contacts with ID: ${this.contactIdentifier}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs b/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs index 33e4b692bd119..0c67dc38a65c0 100644 --- a/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs +++ b/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs @@ -1,73 +1,64 @@ -// legacy_hash_id: a_a4ivba -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-list-credit-notes", name: "List Credit Notes", description: "Lists information from credit notes in the given tenant id as per filter parameters.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - credit_note_identifier: { + creditNoteIdentifier: { + label: "Credit Note Identifier", type: "string", description: "Credit note identifier of the contact to get. Possible values: \n* **CreditNoteID** - The Xero identifier for a contact note e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **CreditNoteNumber** - Identifier for Credit Note CN-8743802", optional: true, }, - modified_after: { + modifiedAfter: { + label: "Modified After", type: "string", description: "The ModifiedAfter filter is actually an HTTP header: **'If-Modified-Since'.**\nA UTC timestamp (yyyy-mm-ddThh:mm:ss). Only credit notes or modified since this timestamp will be returned e.g. 2009-11-12T00:00:00", optional: true, }, where: { + label: "Where", type: "string", description: "Filter by an any element ( see [Filters](https://developer.xero.com/documentation/api/requests-and-responses#get-modified) )", optional: true, }, order: { + label: "Order", type: "string", description: "Order by any element returned ( see [Order By](https://developer.xero.com/documentation/api/requests-and-responses#ordering) )", optional: true, }, page: { + label: "Page", type: "string", description: "Up to 100 credit notes will be returned per call, with line items shown for each, when the page parameter is used e.g. page=1", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/credit-notes#GET - - if (!this.tenant_id) { - throw new Error("Must provide tenant_id parameter."); - } - - const creditNoteIdentifier = this.credit_note_identifier || ""; - - var headers = { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }; - - if (this.modified_after) { - headers["If-Modified-Since"] = this.modified_after; - } - - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/CreditNotes/${creditNoteIdentifier}`, - headers, + const response = await this.xeroAccountingApi.listCreditNotes({ + $, + tenantId: this.tenantId, + creditNoteIdentifier: this.creditNoteIdentifier, + modifiedAfter: this.modifiedAfter, params: { Where: this.where, order: this.order, page: this.page, }, }); + + $.export("$summary", `Successfully fetched credit notes with ID: ${this.creditNoteIdentifier}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs index 55c1928e24d5a..ab293a0ca11db 100644 --- a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs +++ b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs @@ -1,103 +1,99 @@ -// legacy_hash_id: a_3Liezo -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-list-invoices", name: "List Invoices", description: "Lists information from invoices in the given tenant id as per filter parameters.", - version: "0.2.1", + version: "0.2.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - invoice_identifier: { + invoiceIdentifier: { + label: "Invoice Identifier", type: "string", description: "An invoice identifier. Possible values:\n\n* **InvoiceID** - The Xero identifier for an Invoice e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **InvoiceNumber** - The InvoiceNumber e.g. INV-01514", optional: true, }, - modified_after: { + modifiedAfter: { + label: "Modified After", type: "string", description: "The ModifiedAfter filter is actually an HTTP header: **'If-Modified-Since'.**\nA UTC timestamp (yyyy-mm-ddThh:mm:ss). Only invoices created or modified since this timestamp will be returned e.g. 2009-11-12T00:00:00", optional: true, }, ids: { + label: "IDs", type: "string", description: "Filter by a comma-separated list of InvoicesIDs. See [details](https://developer.xero.com/documentation/api/invoices#optimised-queryparameters).", optional: true, }, - invoice_numbers: { + invoiceNumbers: { + label: "Invoice Numbers", type: "string", description: "Filter by a comma-separated list of InvoiceNumbers. See [details](https://developer.xero.com/documentation/api/invoices#optimised-queryparameters).", optional: true, }, - contact_ids: { + contactIds: { + label: "Contact IDs", type: "string", description: "Filter by a comma-separated list of ContactIDs. See [details](https://developer.xero.com/documentation/api/invoices#optimised-queryparameters).", optional: true, }, statuses: { + label: "Statuses", type: "string", description: "Filter by a comma-separated list of Statuses. See [details](https://developer.xero.com/documentation/api/invoices#optimised-queryparameters).", optional: true, }, where: { + label: "Where", type: "string", description: "Filter using the *where* parameter. We recommend you limit filtering to the [optimised elements](https://developer.xero.com/documentation/api/invoices#optimised-parameters) only.", optional: true, }, - created_by_my_app: { + createdByMyApp: { + label: "Created By My App", type: "boolean", description: "When set to true you'll only retrieve Invoices created by your app.", optional: true, }, order: { + label: "Order", type: "string", description: "Order by any element returned ( see [Order By](https://developer.xero.com/documentation/api/requests-and-responses#ordering) ).", optional: true, }, page: { + label: "Page", type: "string", description: "Up to 100 invoices will be returned per call, with line items shown for each, when the page parameter is used e.g. page=1", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/invoices#get - - if (!this.tenant_id) { - throw new Error("Must provide tenant_id parameter."); - } - - const invoiceIdentifier = this.invoice_identifier || ""; - - var headers = { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }; - - if (this.modified_after) { - headers["If-Modified-Since"] = this.modified_after; - } - - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/Invoices/${invoiceIdentifier}`, - headers, + const response = await this.xeroAccountingApi.listInvoices({ + $, + tenantId: this.tenantId, + invoiceIdentifier: this.invoiceIdentifier, + modifiedAfter: this.modifiedAfter, params: { IDs: this.ids, - InvoiceNumbers: this.invoice_numbers, - ContactIDs: this.contact_ids, + InvoiceNumbers: this.invoiceNumbers, + ContactIDs: this.contactIds, Statuses: this.statuses, Where: this.where, - createdByMyApp: this.created_by_my_app, + createdByMyApp: this.createdByMyApp, order: this.order, page: this.page, }, }); + + $.export("$summary", `Successfully fetched invoices with ID: ${this.invoiceIdentifier}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs b/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs index 75190cb8efde4..d3cc725370a76 100644 --- a/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs +++ b/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs @@ -1,73 +1,64 @@ -// legacy_hash_id: a_rJid1r -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-list-manual-journals", name: "List Manual Journals", description: "Lists information from manual journals in the given tenant id as per filter parameters.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - manual_journal_id: { + manualJournalId: { + label: "Manual Journal ID", type: "string", description: "You can specify an individual record by appending the ManualJournalID to the endpoint, i.e. **GET https://.../ManualJournals/{identifier}**", optional: true, }, - modified_after: { + modifiedAfter: { + label: "Modified After", type: "string", description: "The ModifiedAfter filter is actually an HTTP header: **'If-Modified-Since'**. A UTC timestamp (yyyy-mm-ddThh:mm:ss) . Only manual journals created or modified since this timestamp will be returned e.g. 2009-11-12T00:00:00", optional: true, }, where: { + label: "Where", type: "string", description: "Filter by an any element (*see [Filters](https://developer.xero.com/documentation/api/requests-and-responses#get-modified)*)", optional: true, }, order: { + label: "Order", type: "string", description: "Order by any element returned (*see [Order By](https://developer.xero.com/documentation/api/requests-and-responses#ordering)*)", optional: true, }, page: { + label: "Page", type: "string", description: "Up to 100 manual journals will be returned per call, with journal lines shown for each, when the page parameter is used e.g. page=1", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/manual-journals#GET - - if (!this.tenant_id) { - throw new Error("Must provide tenant_id parameter."); - } - - const manualJournalId = this.manual_journal_id || ""; - - var headers = { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }; - - if (this.modified_after) { - headers["If-Modified-Since"] = this.modified_after; - } - - return await axios($, { - url: `https://api.xero.com/api.xro/2.0/ManualJournals/${manualJournalId}`, - headers, + const response = await this.xeroAccountingApi.listManualJournals({ + $, + tenantId: this.tenantId, + manualJournalId: this.manualJournalId, + modifiedAfter: this.modifiedAfter, params: { Where: this.where, order: this.order, page: this.page, }, }); + + $.export("$summary", `Successfully fetched manual journals with ID: ${this.manualJournalId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs b/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs new file mode 100644 index 0000000000000..86c7547025743 --- /dev/null +++ b/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs @@ -0,0 +1,27 @@ +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-list-tracking-categories", + name: "List tracking categories", + description: "Lists information from tracking categories [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + }, + async run({ $ }) { + const response = await this.xeroAccountingApi.getTrackingCategories({ + $, + tenantId: this.tenantId, + }); + + $.export("$summary", `Successfully listed ${response.TrackingCategories.length} tracking categories`); + return response; + }, +}; diff --git a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs index a9bb90271ccf7..e4cffa1d7d352 100644 --- a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs +++ b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs @@ -1,18 +1,22 @@ -// legacy_hash_id: a_YEi2rp -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-make-an-api-call", name: "Make API Call", description: "Makes an aribitrary call to Xero Accounting API.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - request_method: { + requestMethod: { + label: "Request Method", type: "string", description: "Http method to use in the request.", options: [ @@ -23,39 +27,43 @@ export default { "delete", ], }, - relative_url: { + relativeUrl: { + label: "Relative URL", type: "string", description: "A path relative to Xero Accounting API to send the request against.", }, - query_string: { + queryString: { + label: "Query String", type: "string", description: "Query string of the request.", optional: true, }, headers: { + label: "Headers", type: "object", description: "Headers to send in the request. Must include header `xero-tenant-id` with Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", }, - request_body: { + requestBody: { + label: "Request Body", type: "object", description: "Body of the request.", optional: true, }, }, async run({ $ }) { - // See Xero's Rest Accounting API docs at: https://developer.xero.com/documentation/api/api-overview - - if (!this.request_method || !this.relative_url) { - throw new Error("Must provide request_method, and relative_url parameters."); + if (!this.tenantId || !this.requestMethod || !this.relativeUrl) { + throw new ConfigurationError("Must provide **Tenant ID**, **Request Method**, and **Relative URL** parameters."); } - this.query_string = this.query_string || ""; - - return await axios($, { - method: this.request_method, - url: `https://api.xero.com/${this.relative_url}${this.query_string}`, - headers: this.headers, - data: this.request_body, + const response = await this.xeroAccountingApi._makeRequest({ + $, + method: this.requestMethod, + path: this.relativeUrl, + params: this.queryString, + data: this.requestBody, }); + + $.export("$summary", `Successfully made API call to ${this.relativeUrl}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/update-tracking-category-option/update-tracking-category-option.mjs b/components/xero_accounting_api/actions/update-tracking-category-option/update-tracking-category-option.mjs new file mode 100644 index 0000000000000..7697e80404f52 --- /dev/null +++ b/components/xero_accounting_api/actions/update-tracking-category-option/update-tracking-category-option.mjs @@ -0,0 +1,74 @@ +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-update-tracking-category-option", + name: "Update tracking category option", + description: "Update a tracking category by ID [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories#post-trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + trackingCategoryId: { + propDefinition: [ + xeroAccountingApi, + "trackingCategoryId", + ({ tenantId }) => ({ + tenantId, + }), + ], + }, + trackingOptionId: { + propDefinition: [ + xeroAccountingApi, + "trackingOptionId", + ({ + tenantId, trackingCategoryId, + }) => ({ + tenantId, + trackingCategoryId, + }), + ], + }, + optionName: { + type: "string", + label: "Option name", + description: "The name of the tracking category option", + }, + status: { + type: "string", + label: "Status", + description: "The status of the tracking category option", + options: [ + "ACTIVE", + "ARCHIVED", + ], + optional: true, + }, + }, + async run({ $ }) { + try { + const response = await this.xeroAccountingApi.updateTrackingOption({ + $, + tenantId: this.tenantId, + trackingCategoryId: this.trackingCategoryId, + trackingOptionId: this.trackingOptionId, + data: { + Name: this.optionName, + Status: this.status, + }, + }); + + $.export("$summary", `Successfully updated tracking category option with ID: ${this.trackingOptionId}`); + return response; + } catch ({ response: { data } }) { + throw new ConfigurationError(data.Elements[0].ValidationErrors[0].Message); + } + }, +}; diff --git a/components/xero_accounting_api/actions/update-tracking-category/update-tracking-category.mjs b/components/xero_accounting_api/actions/update-tracking-category/update-tracking-category.mjs new file mode 100644 index 0000000000000..4032663751ec1 --- /dev/null +++ b/components/xero_accounting_api/actions/update-tracking-category/update-tracking-category.mjs @@ -0,0 +1,62 @@ +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; + +export default { + key: "xero_accounting_api-update-tracking-category", + name: "Update tracking category", + description: "Update a tracking category by ID [See the documentation](https://developer.xero.com/documentation/api/accounting/trackingcategories#post-trackingcategories).", + version: "0.0.1", + type: "action", + props: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + trackingCategoryId: { + propDefinition: [ + xeroAccountingApi, + "trackingCategoryId", + ({ tenantId }) => ({ + tenantId, + }), + ], + }, + name: { + type: "string", + label: "Name", + description: "The name of the tracking category", + optional: true, + }, + status: { + type: "string", + label: "Status", + description: "The status of the tracking category", + options: [ + "ACTIVE", + "ARCHIVED", + ], + optional: true, + }, + }, + async run({ $ }) { + try { + const response = await this.xeroAccountingApi.updateTrackingCategory({ + $, + tenantId: this.tenantId, + trackingCategoryId: this.trackingCategoryId, + data: { + Name: this.name, + Status: this.status, + }, + }); + + $.export("$summary", `Successfully updated tracking category with ID: ${this.trackingCategoryId}`); + return response; + } catch ({ response: { data } }) { + throw new ConfigurationError(data.Elements[0].ValidationErrors[0].Message); + } + }, +}; diff --git a/components/xero_accounting_api/actions/upload-file/upload-file.mjs b/components/xero_accounting_api/actions/upload-file/upload-file.mjs index aec51dc7b0b54..47c9e1068ef1b 100644 --- a/components/xero_accounting_api/actions/upload-file/upload-file.mjs +++ b/components/xero_accounting_api/actions/upload-file/upload-file.mjs @@ -1,15 +1,12 @@ -// legacy_hash_id: a_B0i8rE +import { getFileStreamAndMetadata } from "@pipedream/platform"; import FormData from "form-data"; -import { - axios, getFileStreamAndMetadata, -} from "@pipedream/platform"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-upload-file", name: "Upload File", description: "Uploads a file to the specified document. [See the documentation](https://developer.xero.com/documentation/api/accounting/invoices#upload-attachment)", - version: "1.0.1", + version: "1.0.2", type: "action", props: { xeroAccountingApi, @@ -63,16 +60,19 @@ export default { filename: metadata.name, }); - //Sends the request against Xero Accounting API - return await axios($, { - method: "post", - url: `https://api.xero.com/api.xro/2.0/${this.documentType}/${this.documentId}/Attachments/${metadata.name}`, + const response = await this.xeroAccountingApi.uploadFile({ + $, + tenantId: this.tenantId, + documentType: this.documentType, + documentId: this.documentId, + fileName: metadata.name, headers: { - "Authorization": `Bearer ${this.xeroAccountingApi.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenantId, ...data.getHeaders(), }, data, }); + + $.export("$summary", `Successfully uploaded file to ${this.documentType} with ID: ${this.documentId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs b/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs index a633fa6264d42..e72d0d29f8b88 100644 --- a/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs @@ -1,30 +1,32 @@ -// legacy_hash_id: a_q1i3W6 -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-xero-accounting-create-employee", name: "Create Employee", description: "Creates a new employee.", - version: "0.3.1", + version: "0.3.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - first_name: { + firstName: { + label: "First Name", type: "string", description: "First name of an employee (max length = 255). If an existing employee matches your `FirstName` and `LastName` then you will receive an error.", }, - last_name: { + lastName: { + label: "Last Name", type: "string", description: "Last name of an employee (max length = 255). If an existing employee matches your `FirstName` and `LastName` then you will receive an error.", }, status: { + label: "Status", type: "string", description: "Current status of an employee - see contact status [types](https://developer.xero.com/documentation/api/types#ContactStatuses)", optional: true, @@ -34,27 +36,21 @@ export default { "GDPRREQUEST", ], }, - external_link: { + externalLink: { + label: "External Link", type: "object", description: "Link to an external resource, for example, an employee record in an external system. You can specify the URL element.\nThe description of the link is auto-generated in the form \"Go to \". refers to the [Xero application](https://api.xero.com/Application) name that is making the API call.", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/employees - //on section PUT Employees - - if (!this.tenant_id || !this.first_name || !this.last_name) { - throw new Error("Must provide tenant_id, first_name, and last_name parameters."); + if (!this.tenantId || !this.firstName || !this.lastName) { + throw new ConfigurationError("Must provide **Tenant ID**, **First Name**, and **Last Name** parameters."); } - return await axios($, { - method: "put", - url: "https://api.xero.com/api.xro/2.0/Employees", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createEmployee({ + $, + tenantId: this.tenantId, data: { Status: this.status, FirstName: this.first_name, @@ -62,5 +58,8 @@ export default { ExternalLink: this.external_link, }, }); + + $.export("$summary", `Successfully created employee with ID: ${response.EmployeeID}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs b/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs index 39775484f972e..c55a43e389b10 100644 --- a/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs @@ -1,42 +1,45 @@ -// legacy_hash_id: a_0Mi723 -import { axios } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-xero-accounting-create-or-update-contact", name: "Create or Update Contact", description: "Creates a new contact or updates if the contact exists.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, name: { + label: "Name", type: "string", description: "Full name of contact/organisation (max length = 255). The following is required to create a contact.", optional: true, }, - contact_id: { + contactId: { + label: "Contact ID", type: "string", description: "Xero identifier.", optional: true, }, - contact_number: { + contactNumber: { + label: "Contact Number", type: "string", description: "This can be updated via the API only i.e. This field is read only on the Xero contact screen, used to identify contacts in external systems (max length = 50). If the Contact Number is used, this is displayed as Contact Code in the Contacts UI in Xero.", optional: true, }, - account_number: { + accountNumber: { + label: "Account Number", type: "string", description: "A user defined account number. This can be updated via the API and the [Xero UI](https://help.xero.com/ContactsAccountNumber) (max length = 50).", optional: true, }, - contact_status: { + contactStatus: { + label: "Contact Status", type: "string", description: "Current status of a contact - see contact status [types](https://developer.xero.com/documentation/api/types#ContactStatuses)", optional: true, @@ -46,112 +49,134 @@ export default { "GDPRREQUEST", ], }, - first_name: { + firstName: { + label: "First Name", type: "string", description: "First name of contact person (max length = 255).", optional: true, }, - last_name: { + lastName: { + label: "Last Name", type: "string", description: "Last name of contact person (max length = 255)", optional: true, }, - email_address: { + emailAddress: { + label: "Email Address", type: "string", description: "Email address of contact person (umlauts not supported) (max length = 255)", optional: true, }, - skype_user_name: { + skypeUserName: { + label: "Skype User Name", type: "string", description: "Skype user name of contact.", optional: true, }, - contact_persons: { + contactPersons: { + label: "Contact Persons", type: "any", description: "See [contact persons](https://developer.xero.com/documentation/api/contacts#contact-persons).", optional: true, }, - bank_account_details: { + bankAccountDetails: { + label: "Bank Account Details", type: "string", description: "Bank account number of contact", optional: true, }, - tax_number: { + taxNumber: { + label: "Tax Number", type: "string", description: "Tax number of contact - this is also known as the ABN (Australia), GST Number (New Zealand), VAT Number (UK) or Tax ID Number (US and global) in the Xero UI depending on which regionalized version of Xero you are using (max length = 50)", optional: true, }, - account_receivable_tax_type: { + accountReceivableTaxType: { + label: "Account Receivable Tax Type", type: "string", description: "Default tax type used for contact on AP invoices", optional: true, }, - account_payable_type: { + accountPayableType: { + label: "Account Payable Type", type: "string", description: "Store certain address types for a contact - see address types", optional: true, }, addresses: { + label: "Addresses", type: "any", description: "Store certain address types for a contact - see address types", optional: true, }, phones: { + label: "Phones", type: "any", description: "Store certain phone types for a contact - see phone types.", optional: true, }, - is_supplier: { + isSupplier: { + label: "Is Supplier", type: "boolean", description: "true or false – Boolean that describes if a contact that has any AP invoices entered against them. Cannot be set via PUT or POST - it is automatically set when an accounts payable invoice is generated against this contact.", optional: true, }, - is_customer: { + isCustomer: { + label: "Is Customer", type: "boolean", description: "true or false – Boolean that describes if a contact has any AR invoices entered against them. Cannot be set via PUT or POST - it is automatically set when an accounts receivable invoice is generated against this contact.", optional: true, }, - default_currency: { + defaultCurrency: { + label: "Default Currency", type: "string", description: "Default currency for raising invoices against contact", optional: true, }, - xero_network_key: { + xeroNetworkKey: { + label: "Xero Network Key", type: "string", description: "Store XeroNetworkKey for contacts.", optional: true, }, - sales_default_account_code: { + salesDefaultAccountCode: { + label: "Sales Default Account Code", type: "string", description: "The default sales [account code](https://developer.xero.com/documentation/api/accounts) for contacts", optional: true, }, - puchases_default_account_code: { + puchasesDefaultAccountCode: { + label: "Purchases Default Account Code", type: "string", description: "The default purchases [account code](https://developer.xero.com/documentation/api/accounts) for contacts", optional: true, }, - sales_tracking_categories: { + salesTrackingCategories: { + label: "Sales Tracking Categories", type: "string", description: "The default sales [tracking categories](https://developer.xero.com/documentation/api/tracking-categories/) for contacts", optional: true, }, - puechases_tracking_categories: { + puechasesTrackingCategories: { + label: "Purchases Tracking Categories", type: "string", description: "The default purchases [tracking categories](https://developer.xero.com/documentation/api/tracking-categories/) for contacts", optional: true, }, - tracking_category_name: { + trackingCategoryName: { + label: "Tracking Category Name", type: "string", description: "The name of the Tracking Category assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories", optional: true, }, - tracking_option_name: { + trackingOptionName: { + label: "Tracking Option Name", type: "string", description: "The name of the Tracking Option assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories", optional: true, }, - payment_terms: { + paymentTerms: { + label: "Payment Terms", type: "string", description: "The default payment terms for the contact - see Payment Terms", optional: true, @@ -164,20 +189,9 @@ export default { }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/contacts - //on section POST Contacts - - if (!this.tenant_id) { - throw new Error("Must provide tenant_id parameter."); - } - - return await axios($, { - method: "post", - url: "https://api.xero.com/api.xro/2.0/Contacts", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createOrUpdateContact({ + $, + tenantId: this.tenantId, data: { Name: this.name, ContactID: this.contact_id, @@ -208,5 +222,8 @@ export default { PaymentTerms: this.payment_terms, }, }); + + $.export("$summary", `Successfully created or updated contact with ID: ${this.contactId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs b/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs index d1292b37081cc..5263f5de5e162 100644 --- a/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs @@ -1,41 +1,45 @@ -// legacy_hash_id: a_dvinrY -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-xero-accounting-update-contact", name: "Update Contact", description: "Updates a contact given its identifier.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], }, - contact_id: { + contactId: { + label: "Contact ID", type: "string", description: "Contact identifier of the contact to update.", }, name: { + label: "Name", type: "string", description: "Full name of contact/organisation (max length = 255). The following is required to create a contact.", optional: true, }, - contact_number: { + contactNumber: { + label: "Contact Number", type: "string", description: "This can be updated via the API only i.e. This field is read only on the Xero contact screen, used to identify contacts in external systems (max length = 50). If the Contact Number is used, this is displayed as Contact Code in the Contacts UI in Xero.", optional: true, }, - account_number: { + accountNumber: { + label: "Account Number", type: "string", description: "A user defined account number. This can be updated via the API and the [Xero UI](https://help.xero.com/ContactsAccountNumber) (max length = 50).", optional: true, }, - contact_status: { + contactStatus: { + label: "Contact Status", type: "string", description: "Current status of a contact - see contact status [types](https://developer.xero.com/documentation/api/types#ContactStatuses)", optional: true, @@ -45,112 +49,134 @@ export default { "GDPRREQUEST", ], }, - first_name: { + firstName: { + label: "First Name", type: "string", description: "First name of contact person (max length = 255).", optional: true, }, - last_name: { + lastName: { + label: "Last Name", type: "string", description: "Last name of contact person (max length = 255)", optional: true, }, - email_address: { + emailAddress: { + label: "Email Address", type: "string", description: "Email address of contact person (umlauts not supported) (max length = 255)", optional: true, }, - skype_user_name: { + skypeUserName: { + label: "Skype User Name", type: "string", description: "Skype user name of contact.", optional: true, }, - contact_persons: { + contactPersons: { + label: "Contact Persons", type: "any", description: "See [contact persons](https://developer.xero.com/documentation/api/contacts#contact-persons).", optional: true, }, - bank_account_details: { + bankAccountDetails: { + label: "Bank Account Details", type: "string", description: "Bank account number of contact", optional: true, }, - tax_number: { + taxNumber: { + label: "Tax Number", type: "string", description: "Tax number of contact - this is also known as the ABN (Australia), GST Number (New Zealand), VAT Number (UK) or Tax ID Number (US and global) in the Xero UI depending on which regionalized version of Xero you are using (max length = 50)", optional: true, }, - account_receivable_tax_type: { + accountReceivableTaxType: { + label: "Account Receivable Tax Type", type: "string", description: "Default tax type used for contact on AP invoices", optional: true, }, - account_payable_type: { + accountPayableType: { + label: "Account Payable Type", type: "string", description: "Store certain address types for a contact - see address types", optional: true, }, addresses: { + label: "Addresses", type: "any", description: "Store certain address types for a contact - see address types", optional: true, }, phones: { + label: "Phones", type: "any", description: "Store certain phone types for a contact - see phone types.", optional: true, }, - is_supplier: { + isSupplier: { + label: "Is Supplier", type: "boolean", description: "true or false – Boolean that describes if a contact that has any AP invoices entered against them. Cannot be set via PUT or POST - it is automatically set when an accounts payable invoice is generated against this contact.", optional: true, }, - is_customer: { + isCustomer: { + label: "Is Customer", type: "boolean", description: "true or false – Boolean that describes if a contact has any AR invoices entered against them. Cannot be set via PUT or POST - it is automatically set when an accounts receivable invoice is generated against this contact.", optional: true, }, - default_currency: { + defaultCurrency: { + label: "Default Currency", type: "string", description: "Default currency for raising invoices against contact", optional: true, }, - xero_network_key: { + xeroNetworkKey: { + label: "Xero Network Key", type: "string", description: "Store XeroNetworkKey for contacts.", optional: true, }, - sales_default_account_code: { + salesDefaultAccountCode: { + label: "Sales Default Account Code", type: "string", description: "The default sales [account code](https://developer.xero.com/documentation/api/accounts) for contacts", optional: true, }, - puchases_default_account_code: { + puchasesDefaultAccountCode: { + label: "Purchases Default Account Code", type: "string", description: "The default purchases [account code](https://developer.xero.com/documentation/api/accounts) for contacts", optional: true, }, - sales_tracking_categories: { + salesTrackingCategories: { + label: "Sales Tracking Categories", type: "string", description: "The default sales [tracking categories](https://developer.xero.com/documentation/api/tracking-categories/) for contacts", optional: true, }, - puechases_tracking_categories: { + puechasesTrackingCategories: { + label: "Purchases Tracking Categories", type: "string", description: "The default purchases [tracking categories](https://developer.xero.com/documentation/api/tracking-categories/) for contacts", optional: true, }, - tracking_category_name: { + trackingCategoryName: { + label: "Tracking Category Name", type: "string", description: "The name of the Tracking Category assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories", optional: true, }, - tracking_option_name: { + trackingOptionName: { + label: "Tracking Option Name", type: "string", description: "The name of the Tracking Option assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories", optional: true, }, - payment_terms: { + paymentTerms: { + label: "Payment Terms", type: "string", description: "The default payment terms for the contact - see Payment Terms", optional: true, @@ -163,20 +189,14 @@ export default { }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/contacts - //on section POST Contacts - - if (!this.tenant_id || !this.contact_id) { - throw new Error("Must provide tenant_id, and contact_id parameters."); + if (!this.tenantId || !this.contactId) { + throw new ConfigurationError("Must provide **Tenant ID**, and **Contact ID** parameters."); } - return await axios($, { - method: "post", - url: `https://api.xero.com/api.xro/2.0/Contacts/${this.contact_id}`, - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.updateContact({ + $, + tenantId: this.tenantId, + contactId: this.contactId, data: { Name: this.name, ContactID: this.contact_id, @@ -207,5 +227,8 @@ export default { PaymentTerms: this.payment_terms, }, }); + + $.export("$summary", `Successfully updated contact with ID: ${this.contactId}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs b/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs index fccb79ca85895..9ea12d1ce533b 100644 --- a/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs +++ b/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs @@ -1,110 +1,118 @@ -// legacy_hash_id: a_xqigGY -import { axios } from "@pipedream/platform"; +import { ConfigurationError } from "@pipedream/platform"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-xero-create-purchase-bill", name: "Create Purchase Bill", description: "Creates a new purchase bill.", - version: "0.1.1", + version: "0.1.2", type: "action", props: { - xero_accounting_api: { - type: "app", - app: "xero_accounting_api", - }, - contact_id: { + xeroAccountingApi, + tenantId: { + propDefinition: [ + xeroAccountingApi, + "tenantId", + ], + }, + contactId: { + label: "Contact ID", type: "string", description: "Id of the contact associated to the invoice.", optional: true, }, - contact_name: { + contactName: { + label: "Contact Name", type: "string", description: "Name of the contact associated to the invoice. If there is no contact matching this name, a new contact is created.", optional: true, }, - tenant_id: { - type: "string", - description: "Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, - line_items: { + lineItems: { + label: "Line Items", type: "any", description: "See [LineItems](https://developer.xero.com/documentation/api/invoices#LineItemsPOST). The LineItems collection can contain any number of individual LineItem sub-elements. At least * **one** * is required to create a complete Invoice.", }, date: { + label: "Date", type: "string", description: "Date invoice was issued - YYYY-MM-DD. If the Date element is not specified it will default to the current date based on the timezone setting of the organisation.", optional: true, }, - due_date: { + dueDate: { + label: "Due Date", type: "string", description: "Date invoice is due - YYYY-MM-DD.", optional: true, }, - line_amount_type: { + lineAmountType: { + label: "Line Amount Type", type: "string", description: "Line amounts are exclusive of tax by default if you don't specify this element. See [Line Amount Types](https://developer.xero.com/documentation/api/types#LineAmountTypes)", optional: true, }, - purchase_bill_number: { + purchaseBillNumber: { + label: "Purchase Bill Number", type: "string", description: "Non-unique alpha numeric code identifying purchase bill (printable ASCII characters only). This value will also display as Reference in the UI.", optional: true, }, reference: { + label: "Reference", type: "string", description: "Additional reference number (max length = 255)", optional: true, }, - branding_theme_id: { + brandingThemeId: { + label: "Branding Theme ID", type: "string", description: "See [BrandingThemes](https://developer.xero.com/documentation/api/branding-themes)", optional: true, }, url: { + label: "URL", type: "string", description: "URL link to a source document - shown as \"Go to [appName]\" in the Xero app", optional: true, }, - currency_code: { + currencyCode: { + label: "Currency Code", type: "string", description: "The currency that invoice has been raised in (see [Currencies](https://developer.xero.com/documentation/api/currencies))", optional: true, }, - currency_rate: { + currencyRate: { + label: "Currency Rate", type: "string", description: "The currency rate for a multicurrency invoice. If no rate is specified, the [XE.com day rate](http://help.xero.com/#CurrencySettings$Rates) is used. (max length = [18].[6])", optional: true, }, status: { + label: "Status", type: "string", description: "See [Invoice Status Codes](https://developer.xero.com/documentation/api/invoices#status-codes)", optional: true, }, - sent_to_contact: { + sentToContact: { + label: "Sent to Contact", type: "string", description: "Boolean to set whether the invoice in the Xero app should be marked as \"sent\". This can be set only on invoices that have been approved", optional: true, }, - planned_payment_date: { + plannedPaymentDate: { + label: "Planned Payment Date", type: "string", description: "Shown on purchase bills (Accounts Payable) when this has been set", optional: true, }, }, async run({ $ }) { - //See the API docs: https://developer.xero.com/documentation/api/invoices#post - - if ((!this.contact_id && !this.contact_name) || !this.tenant_id || !this.line_items) { - throw new Error("Must provide one of contact_id or contact_name, and tenant_id, type, line_items parameters."); + if ((!this.contactId && !this.contactName) || !this.tenantId || !this.lineItems) { + throw new ConfigurationError("Must provide one of **Contact ID** or **Contact Name**, **Tenant ID**, **Type**, and **Line Items** parameters."); } - return await axios($, { - method: "post", - url: "https://api.xero.com/api.xro/2.0/Invoices", - headers: { - "Authorization": `Bearer ${this.xero_accounting_api.$auth.oauth_access_token}`, - "xero-tenant-id": this.tenant_id, - }, + const response = await this.xeroAccountingApi.createInvoice({ + $, + tenantId: this.tenantId, data: { Type: "ACCPAY", //ACCPAY = Purchase Bill Contact: { @@ -126,5 +134,8 @@ export default { PlannedPaymentDate: this.planned_payment_date, }, }); + + $.export("$summary", `Successfully created purchase bill with ID: ${response.PurchaseBillID}`); + return response; }, }; diff --git a/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs b/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs index dbcfd1809b05c..25d3bdce8850e 100644 --- a/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs +++ b/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs @@ -1,5 +1,6 @@ -import xero from "../../xero_accounting_api.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; import { formatLineItems } from "../../common/util.mjs"; +import xero from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-xero-create-sales-invoice", @@ -23,7 +24,9 @@ export default { if (!this.tenantId) { return []; } - const { Contacts: contacts } = await this.xero.getContact(null, this.tenantId); + const { Contacts: contacts } = await this.xero.getContact({ + tenantId: this.tenantId, + }); return contacts?.map(({ ContactID: value, Name: label, }) => ({ @@ -120,28 +123,32 @@ export default { }, async run({ $ }) { if ((!this.contactId && !this.contactName) || !this.tenantId || !this.lineItems) { - throw new Error("Must provide one of `contactId` or `contactName`, and `tenantId`, `type`, `lineItems` parameters."); + throw new ConfigurationError("Must provide one of **Contact ID** or **Contact Name**, **Tenant ID**, **Type**, and **Line Items** parameters."); } - const response = await this.xero.createInvoice($, this.tenantId, { - Type: "ACCREC", //ACCREC = Sales Invoice - Contact: { - ContactID: this.contactId, - Name: this.contactName, + const response = await this.xero.createInvoice({ + $, + tenantId: this.tenantId, + data: { + Type: "ACCREC", //ACCREC = Sales Invoice + Contact: { + ContactID: this.contactId, + Name: this.contactName, + }, + LineItems: formatLineItems(this.lineItems), + Date: this.date, + DueDate: this.dueDate, + LineAmountTypes: this.lineAmountType, + InvoiceNumber: this.invoiceNumber, + Reference: this.reference, + BrandingThemeID: this.brandingThemeId, + Url: this.url, + CurrencyCode: this.currencyCode, + CurrencyRate: this.currencyRate, + Status: this.status, + SentToContact: this.sentToContact, + ExpectedPaymentDate: this.expectedPaymentData, }, - LineItems: formatLineItems(this.lineItems), - Date: this.date, - DueDate: this.dueDate, - LineAmountTypes: this.lineAmountType, - InvoiceNumber: this.invoiceNumber, - Reference: this.reference, - BrandingThemeID: this.brandingThemeId, - Url: this.url, - CurrencyCode: this.currencyCode, - CurrencyRate: this.currencyRate, - Status: this.status, - SentToContact: this.sentToContact, - ExpectedPaymentDate: this.expectedPaymentData, }); return response; diff --git a/components/xero_accounting_api/common/constants.mjs b/components/xero_accounting_api/common/constants.mjs index 15b181ab273b8..d675c75d887e7 100644 --- a/components/xero_accounting_api/common/constants.mjs +++ b/components/xero_accounting_api/common/constants.mjs @@ -1,11 +1,2 @@ -const BASE_URL = "https://api.xero.com"; -const VERSION_PATH = "/2.0"; -const DEFAULT_API_PATH = "/api.xro"; -const DB_LAST_DATE_CHECK = "DB_LAST_DATE_CHECK"; - -export default { - BASE_URL, - VERSION_PATH, - DEFAULT_API_PATH, - DB_LAST_DATE_CHECK, -}; +export const DB_LAST_DATE_CHECK = "DB_LAST_DATE_CHECK"; +export const BASE_URL = "https://api.xero.com"; diff --git a/components/xero_accounting_api/common/util.mjs b/components/xero_accounting_api/common/util.mjs index f7db6b265b378..5e261f7cb9ca5 100644 --- a/components/xero_accounting_api/common/util.mjs +++ b/components/xero_accounting_api/common/util.mjs @@ -108,12 +108,39 @@ const formatJsonDate = (date) => { const chainQueryString = (queryString) => queryString && queryString.split("&").join(" AND "); +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 { - removeNullEntries, - formatLineItems, - deleteKeys, - isValidDate, - formatQueryString, chainQueryString, + deleteKeys, formatJsonDate, + formatLineItems, + formatQueryString, + isValidDate, + parseObject, + removeNullEntries, }; + diff --git a/components/xero_accounting_api/package.json b/components/xero_accounting_api/package.json index b07ae90495dec..0e2b3bffebb7c 100644 --- a/components/xero_accounting_api/package.json +++ b/components/xero_accounting_api/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/xero_accounting_api", - "version": "0.3.1", + "version": "0.4.0", "description": "Pipedream Xero Components", "main": "xero_accounting_api.app.mjs", "keywords": [ diff --git a/components/xero_accounting_api/sources/new-updated-contact/new-updated-contact.mjs b/components/xero_accounting_api/sources/new-updated-contact/new-updated-contact.mjs index bdf9373217dbc..8df1eb1677c6d 100644 --- a/components/xero_accounting_api/sources/new-updated-contact/new-updated-contact.mjs +++ b/components/xero_accounting_api/sources/new-updated-contact/new-updated-contact.mjs @@ -1,12 +1,12 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; import { formatJsonDate } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; export default { key: "xero_accounting_api-new-updated-contact", name: "New or updated contact", description: "Emit new notifications when you create a new or update existing contact", - version: "0.0.3", + version: "0.0.4", type: "source", props: { xeroAccountingApi, @@ -35,12 +35,10 @@ export default { this.xeroAccountingApi.setLastDateChecked(this.db, lastDateChecked); } const contacts = ( - await this.xeroAccountingApi.getContact( - null, - this.tenantId, - null, - lastDateChecked, - ) + await this.xeroAccountingApi.getContact({ + tenantId: this.tenantId, + modifiedSince: lastDateChecked, + }) )?.Contacts; contacts && contacts.reverse().forEach((contact) => { const formattedDate = formatJsonDate(contact.UpdatedDateUTC); diff --git a/components/xero_accounting_api/sources/new-updated-invoice/new-updated-invoice.mjs b/components/xero_accounting_api/sources/new-updated-invoice/new-updated-invoice.mjs index 9d81dfce12066..6352c5ff0ff11 100644 --- a/components/xero_accounting_api/sources/new-updated-invoice/new-updated-invoice.mjs +++ b/components/xero_accounting_api/sources/new-updated-invoice/new-updated-invoice.mjs @@ -1,12 +1,12 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; import { formatJsonDate } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; export default { key: "xero_accounting_api-new-updated-invoice", name: "New or updated invoice", description: "Emit new notifications when you create a new or update existing invoice", - version: "0.0.3", + version: "0.0.4", type: "source", props: { xeroAccountingApi, @@ -36,12 +36,10 @@ export default { } const invoices = ( - await this.xeroAccountingApi.getInvoice( - null, - this.tenantId, - null, - lastDateChecked, - ) + await this.xeroAccountingApi.getInvoice({ + tenantId: this.tenantId, + modifiedSince: lastDateChecked, + }) )?.Invoices; invoices && invoices.reverse().forEach((invoice) => { diff --git a/components/xero_accounting_api/sources/webhook-event-received/webhook-event-received.mjs b/components/xero_accounting_api/sources/webhook-event-received/webhook-event-received.mjs index 9110f3de83d2d..17975dd13471e 100644 --- a/components/xero_accounting_api/sources/webhook-event-received/webhook-event-received.mjs +++ b/components/xero_accounting_api/sources/webhook-event-received/webhook-event-received.mjs @@ -1,11 +1,11 @@ -import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; import crypto from "crypto"; +import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-webhook-event-received", name: "Webhook Event Received (Instant)", description: "Emit new event for each incoming webhook notification. To create a Xero Webhook, please follow [the instructions here](https://developer.xero.com/documentation/guides/webhooks/creating-webhooks/).", - version: "0.0.1", + version: "0.0.2", type: "source", props: { xeroAccountingApi, diff --git a/components/xero_accounting_api/xero_accounting_api.app.mjs b/components/xero_accounting_api/xero_accounting_api.app.mjs index 075e897b86eba..687b2fc7221ac 100644 --- a/components/xero_accounting_api/xero_accounting_api.app.mjs +++ b/components/xero_accounting_api/xero_accounting_api.app.mjs @@ -1,5 +1,7 @@ import { axios } from "@pipedream/platform"; -import constants from "./common/constants.mjs"; +import { + BASE_URL, DB_LAST_DATE_CHECK, +} from "./common/constants.mjs"; import { chainQueryString } from "./common/util.mjs"; export default { @@ -12,7 +14,52 @@ export default { description: "Select an organization tenant to use, or provide a tenant ID", async options() { - return this.getTenantsOpts(); + const tenants = await this.getTenantConnections(); + + return tenants.map(({ + tenantName: label, tenantId: value, + }) => ({ + label, + value, + })); + }, + }, + trackingCategoryId: { + type: "string", + label: "Tracking category ID", + description: "Unique identification of the tracking category", + async options({ tenantId }) { + const { TrackingCategories: trackingCategories } = await this.getTrackingCategories({ + tenantId, + }); + + return trackingCategories.map(({ + TrackingCategoryID: value, + Name: label, + }) => ({ + label, + value, + })); + }, + }, + trackingOptionId: { + type: "string", + label: "Tracking option ID", + description: "Unique identification of the tracking option", + async options({ + tenantId, trackingCategoryId, + }) { + const { TrackingCategories: trackingCategories } = await this.getTrackingCategory({ + tenantId, + trackingCategoryId, + }); + + return trackingCategories[0].Options.map(({ + TrackingOptionID, Name, + }) => ({ + label: Name, + value: TrackingOptionID, + })); }, }, invoiceId: { @@ -20,7 +67,9 @@ export default { label: "Invoice ID", description: "Unique identification of the invoice", async options({ tenantId }) { - return this.getInvoiceOpts(tenantId); + return this.getInvoiceOpts({ + tenantId, + }); }, }, lineItems: { @@ -31,106 +80,331 @@ export default { }, methods: { setLastDateChecked(db, value) { - db && db.set(constants.DB_LAST_DATE_CHECK, value); + db && db.set(DB_LAST_DATE_CHECK, value); }, getLastDateChecked(db) { - return db && db.get(constants.DB_LAST_DATE_CHECK); + return db && db.get(DB_LAST_DATE_CHECK); }, - getHeader(tenantId, modifiedSince = null) { + getHeader({ + tenantId, modifiedSince = null, headers = {}, + }) { const header = { "Authorization": `Bearer ${this.$auth.oauth_access_token}`, + ...headers, }; tenantId && (header["xero-tenant-id"] = tenantId); modifiedSince && (header["If-Modified-Since"] = modifiedSince); return header; }, - getUrl(path) { - const { - BASE_URL, - DEFAULT_API_PATH, - VERSION_PATH, - } = constants; - return `${BASE_URL}${DEFAULT_API_PATH}${VERSION_PATH}${path}`; - }, - async makeRequest(args = {}) { - const { - $, - tenantId, - modifiedSince, - method = "get", - path, - params, - data, - } = args; + _makeRequest({ + $ = this, + tenantId, + modifiedSince, + path, + headers, + ...opts + }) { const config = { - method, - url: this.getUrl(path), - headers: this.getHeader(tenantId, modifiedSince), - params, - data, + url: `${BASE_URL}/api.xro/2.0${path}`, + headers: this.getHeader({ + tenantId, + modifiedSince, + headers, + }), + ...opts, }; - return axios($ ?? this, config); + console.log("config: ", config); + return axios($, config); }, - async getTenantsOpts() { - const { BASE_URL } = constants; - const tenants = await axios(this, { - url: `${BASE_URL}/connections`, - headers: this.getHeader(), + getTenantConnections() { + return this._makeRequest({ + url: BASE_URL + "/connections", }); - return tenants.map((tenant) => ({ - label: tenant.tenantName, - value: tenant.tenantId, - })); }, - async getInvoiceOpts(tenantId) { - const invoices = await this.getInvoice(this, tenantId); + async getInvoiceOpts({ tenantId }) { + const invoices = await this.getInvoice({ + tenantId, + }); console.log(invoices); return invoices?.Invoices?.map((invoice) => ({ label: invoice.InvoiceNumber, value: invoice.InvoiceID, })) || []; }, - async createContact($, tenantId, data) { - return this.makeRequest({ - $, - tenantId, + createBankTransaction(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/BankTransactions", + ...opts, + }); + }, + createCreditNote(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/CreditNotes", + ...opts, + }); + }, + createHistoryNote({ + endpoint, guid, ...opts + }) { + return this._makeRequest({ + method: "PUT", + path: `/${endpoint}/${guid}/history`, + ...opts, + }); + }, + createItem(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/Items", + ...opts, + }); + }, + createPayment(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/Payments", + ...opts, + }); + }, + createContact(opts = {}) { + return this._makeRequest({ method: "post", path: "/contacts", - data, + ...opts, }); }, - async getContact($, tenantId, queryParam, modifiedSince = null) { + getContact({ + queryParam, ...opts + }) { const where = chainQueryString(queryParam); - return this.makeRequest({ - $, - tenantId, - modifiedSince, + return this._makeRequest({ path: "/contacts", params: where && { Where: where, }, + ...opts, }); }, - async createInvoice($, tenantId, data) { - return this.makeRequest({ - $, - tenantId, + createInvoice(opts = {}) { + return this._makeRequest({ + method: "post", + path: "/Invoices", + ...opts, + }); + }, + downloadInvoice({ + invoiceId, ...opts + }) { + return this._makeRequest({ + method: "GET", + path: `/Invoices/${invoiceId}`, + ...opts, + }); + }, + emailInvoice({ + invoiceId, ...opts + }) { + return this._makeRequest({ method: "post", - path: "/invoices", - data, + path: `/Invoices/${invoiceId}/Email`, + ...opts, }); }, - async getInvoice($, tenantId, queryParam, modifiedSince = null) { + getInvoice({ + queryParam, ...opts + }) { const where = chainQueryString(queryParam); - return this.makeRequest({ - $, - tenantId, - modifiedSince, - path: "/invoices", + return this._makeRequest({ + path: "/Invoices", + ...opts, params: where && { Where: where, }, }); }, + getInvoiceById({ + invoiceId, ...opts + }) { + return this._makeRequest({ + path: `/Invoices/${invoiceId}`, + ...opts, + }); + }, + getInvoiceOnlineUrl({ + invoiceId, ...opts + }) { + return this._makeRequest({ + path: `/Invoices/${invoiceId}/OnlineInvoice`, + ...opts, + }); + }, + getItemById({ + itemId, ...opts + }) { + return this._makeRequest({ + path: `/Items/${itemId}`, + ...opts, + }); + }, + getBankStatementsReport(opts = {}) { + return this._makeRequest({ + path: "/Reports/BankStatement", + ...opts, + }); + }, + getBankSummary(opts = {}) { + return this._makeRequest({ + path: "/Reports/BankSummary", + ...opts, + }); + }, + getContactById({ + contactIdentifier, ...opts + }) { + return this._makeRequest({ + path: `/Contacts/${contactIdentifier}`, + ...opts, + }); + }, + getHistoryOfChanges({ + endpoint, guid, ...opts + }) { + return this._makeRequest({ + path: `/${endpoint}/${guid}/history`, + ...opts, + }); + }, + getTrackingCategories(opts = {}) { + return this._makeRequest({ + path: "/TrackingCategories", + ...opts, + }); + }, + getTrackingCategory({ + trackingCategoryId, ...opts + }) { + return this._makeRequest({ + path: `/TrackingCategories/${trackingCategoryId}`, + ...opts, + }); + }, + createTrackingCategory(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/TrackingCategories", + ...opts, + }); + }, + updateTrackingCategory({ + trackingCategoryId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/TrackingCategories/${trackingCategoryId}`, + ...opts, + }); + }, + deleteTrackingCategory({ + trackingCategoryId, ...opts + }) { + return this._makeRequest({ + method: "DELETE", + path: `/TrackingCategories/${trackingCategoryId}`, + ...opts, + }); + }, + createTrackingOption({ + trackingCategoryId, ...opts + }) { + return this._makeRequest({ + method: "PUT", + path: `/TrackingCategories/${trackingCategoryId}/Options`, + ...opts, + }); + }, + updateTrackingOption({ + trackingCategoryId, trackingOptionId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/TrackingCategories/${trackingCategoryId}/Options/${trackingOptionId}`, + ...opts, + }); + }, + deleteTrackingOption({ + trackingCategoryId, trackingOptionId, ...opts + }) { + return this._makeRequest({ + method: "DELETE", + path: `/TrackingCategories/${trackingCategoryId}/Options/${trackingOptionId}`, + ...opts, + }); + }, + listContacts({ + contactIdentifier, ...opts + }) { + return this._makeRequest({ + path: `/Contacts/${contactIdentifier}`, + ...opts, + }); + }, + listCreditNotes({ + creditNoteIdentifier, ...opts + }) { + return this._makeRequest({ + path: `/CreditNotes/${creditNoteIdentifier}`, + ...opts, + }); + }, + listInvoices({ + invoiceIdentifier, ...opts + }) { + return this._makeRequest({ + path: `/Invoices/${invoiceIdentifier}`, + ...opts, + }); + }, + listManualJournals({ + manualJournalId, ...opts + }) { + return this._makeRequest({ + path: `/ManualJournals/${manualJournalId}`, + ...opts, + }); + }, + uploadFile({ + documentType, documentId, fileName, ...opts + }) { + return this._makeRequest({ + method: "post", + path: `/${documentType}/${documentId}/Attachments/${fileName}`, + ...opts, + }); + }, + createEmployee(opts = {}) { + return this._makeRequest({ + method: "PUT", + path: "/Employees", + ...opts, + }); + }, + createOrUpdateContact(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/Contacts", + ...opts, + }); + }, + updateContact({ + contactId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/Contacts/${contactId}`, + ...opts, + }); + }, }, }; From 29cf78a21e80f2c55ea61b13f9575030aa7b98e2 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 15 Aug 2025 11:41:52 -0300 Subject: [PATCH 2/9] pnpm update --- pnpm-lock.yaml | 138 +++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 85 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8b60f277e5f90..8abcf4ab320ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15842,8 +15842,7 @@ importers: specifier: ^1.2.0 version: 1.6.6 - components/yourls: - specifiers: {} + components/yourls: {} components/youtube_analytics_api: dependencies: @@ -16588,7 +16587,7 @@ importers: version: 3.1.7 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2) + version: 29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2) tsup: specifier: ^8.3.6 version: 8.3.6(@microsoft/api-extractor@7.47.12(@types/node@20.17.30))(jiti@2.4.2)(postcss@8.5.6)(tsx@4.19.4)(typescript@5.7.2)(yaml@2.8.0) @@ -16631,7 +16630,7 @@ importers: version: 3.1.0 jest: specifier: ^29.1.2 - version: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + version: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) type-fest: specifier: ^4.15.0 version: 4.27.0 @@ -38268,7 +38267,7 @@ snapshots: - supports-color - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2))': + '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -38282,7 +38281,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -38303,7 +38302,7 @@ snapshots: - supports-color - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3))': + '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -38317,7 +38316,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -38338,7 +38337,7 @@ snapshots: - supports-color - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10))': + '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -38352,7 +38351,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -44691,13 +44690,13 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + create-jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -44706,13 +44705,13 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + create-jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -44721,13 +44720,13 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): + create-jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -48816,16 +48815,16 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + jest-cli@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + create-jest: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -48835,16 +48834,16 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + jest-cli@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + create-jest: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -48854,16 +48853,16 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): + jest-cli@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + create-jest: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -48935,7 +48934,7 @@ snapshots: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -48961,12 +48960,12 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.17.30 - ts-node: 10.9.2(@types/node@20.17.30)(typescript@5.7.2) + ts-node: 10.9.2(@types/node@20.17.30)(typescript@3.9.10) transitivePeerDependencies: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -48992,12 +48991,12 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.17.30 - ts-node: 10.9.2(@types/node@20.17.6)(typescript@5.6.3) + ts-node: 10.9.2(@types/node@20.17.30)(typescript@5.7.2) transitivePeerDependencies: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): + jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -49023,7 +49022,7 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.17.30 - ts-node: 10.9.2(@types/node@24.0.10)(typescript@3.9.10) + ts-node: 10.9.2(@types/node@20.17.6)(typescript@5.6.3) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -49059,37 +49058,6 @@ snapshots: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): - dependencies: - '@babel/core': 7.26.0 - '@jest/test-sequencer': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.26.0) - chalk: 4.1.2 - ci-info: 3.9.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.7.0(babel-plugin-macros@3.1.0) - jest-environment-node: 29.7.0 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-runner: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - micromatch: 4.0.8 - parse-json: 5.2.0 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - optionalDependencies: - '@types/node': 24.0.10 - ts-node: 10.9.2(@types/node@24.0.10)(typescript@3.9.10) - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - jest-diff@27.5.1: dependencies: chalk: 4.1.2 @@ -49333,36 +49301,36 @@ snapshots: - supports-color - ts-node - jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-cli: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros - supports-color - ts-node - jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-cli: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros - supports-color - ts-node - jest@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): + jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) + jest-cli: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -55587,7 +55555,7 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2): + ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 @@ -55601,10 +55569,10 @@ snapshots: typescript: 5.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@babel/core': 7.26.0 + '@babel/core': 8.0.0-alpha.13 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.26.0) + babel-jest: 29.7.0(@babel/core@8.0.0-alpha.13) ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)))(typescript@5.6.3): dependencies: @@ -55644,7 +55612,7 @@ snapshots: yn: 3.1.1 optional: true - ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2): + ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 @@ -55658,45 +55626,45 @@ snapshots: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.7.2 + typescript: 3.9.10 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optional: true - ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3): + ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.17.6 + '@types/node': 20.17.30 acorn: 8.14.0 acorn-walk: 8.3.4 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.6.3 + typescript: 5.7.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optional: true - ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10): + ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 24.0.10 + '@types/node': 20.17.6 acorn: 8.14.0 acorn-walk: 8.3.4 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 3.9.10 + typescript: 5.6.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optional: true From 906b647c25bea40c6c227e1408f1702fa5ad69d9 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 15 Aug 2025 12:00:49 -0300 Subject: [PATCH 3/9] pnpm update --- pnpm-lock.yaml | 135 ++++++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 52 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8abcf4ab320ee..a752f1de0f037 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16587,7 +16587,7 @@ importers: version: 3.1.7 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2) + version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2) tsup: specifier: ^8.3.6 version: 8.3.6(@microsoft/api-extractor@7.47.12(@types/node@20.17.30))(jiti@2.4.2)(postcss@8.5.6)(tsx@4.19.4)(typescript@5.7.2)(yaml@2.8.0) @@ -16630,7 +16630,7 @@ importers: version: 3.1.0 jest: specifier: ^29.1.2 - version: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + version: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) type-fest: specifier: ^4.15.0 version: 4.27.0 @@ -38267,7 +38267,7 @@ snapshots: - supports-color - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10))': + '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -38281,7 +38281,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -38302,7 +38302,7 @@ snapshots: - supports-color - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2))': + '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -38316,7 +38316,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -38337,7 +38337,7 @@ snapshots: - supports-color - ts-node - '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3))': + '@jest/core@29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -38351,7 +38351,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -44690,13 +44690,13 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): + create-jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -44705,13 +44705,13 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + create-jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -44720,13 +44720,13 @@ snapshots: - supports-color - ts-node - create-jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + create-jest@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -48815,16 +48815,16 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): + jest-cli@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + create-jest: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -48834,16 +48834,16 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + jest-cli@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + create-jest: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -48853,16 +48853,16 @@ snapshots: - supports-color - ts-node - jest-cli@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + jest-cli@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + create-jest: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -48934,7 +48934,7 @@ snapshots: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): + jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -48960,12 +48960,12 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.17.30 - ts-node: 10.9.2(@types/node@20.17.30)(typescript@3.9.10) + ts-node: 10.9.2(@types/node@20.17.30)(typescript@5.7.2) transitivePeerDependencies: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -48991,12 +48991,12 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.17.30 - ts-node: 10.9.2(@types/node@20.17.30)(typescript@5.7.2) + ts-node: 10.9.2(@types/node@20.17.6)(typescript@5.6.3) transitivePeerDependencies: - babel-plugin-macros - supports-color - jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + jest-config@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -49022,7 +49022,7 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 20.17.30 - ts-node: 10.9.2(@types/node@20.17.6)(typescript@5.6.3) + ts-node: 10.9.2(@types/node@24.0.10)(typescript@3.9.10) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -49058,6 +49058,37 @@ snapshots: - babel-plugin-macros - supports-color + jest-config@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): + dependencies: + '@babel/core': 7.26.0 + '@jest/test-sequencer': 29.7.0 + '@jest/types': 29.6.3 + babel-jest: 29.7.0(@babel/core@7.26.0) + chalk: 4.1.2 + ci-info: 3.9.0 + deepmerge: 4.3.1 + glob: 7.2.3 + graceful-fs: 4.2.11 + jest-circus: 29.7.0(babel-plugin-macros@3.1.0) + jest-environment-node: 29.7.0 + jest-get-type: 29.6.3 + jest-regex-util: 29.6.3 + jest-resolve: 29.7.0 + jest-runner: 29.7.0 + jest-util: 29.7.0 + jest-validate: 29.7.0 + micromatch: 4.0.8 + parse-json: 5.2.0 + pretty-format: 29.7.0 + slash: 3.0.0 + strip-json-comments: 3.1.1 + optionalDependencies: + '@types/node': 24.0.10 + ts-node: 10.9.2(@types/node@24.0.10)(typescript@3.9.10) + transitivePeerDependencies: + - babel-plugin-macros + - supports-color + jest-diff@27.5.1: dependencies: chalk: 4.1.2 @@ -49301,36 +49332,36 @@ snapshots: - supports-color - ts-node - jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)): + jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10)) + jest-cli: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros - supports-color - ts-node - jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)): + jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)) + jest-cli: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros - supports-color - ts-node - jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)): + jest@29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)): dependencies: - '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + '@jest/core': 29.7.0(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)) + jest-cli: 29.7.0(@types/node@24.0.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -55555,7 +55586,7 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2): + ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2)))(typescript@5.7.2): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 @@ -55569,10 +55600,10 @@ snapshots: typescript: 5.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@babel/core': 8.0.0-alpha.13 + '@babel/core': 7.26.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@8.0.0-alpha.13) + babel-jest: 29.7.0(@babel/core@7.26.0) ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3)))(typescript@5.6.3): dependencies: @@ -55612,7 +55643,7 @@ snapshots: yn: 3.1.1 optional: true - ts-node@10.9.2(@types/node@20.17.30)(typescript@3.9.10): + ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 @@ -55626,45 +55657,45 @@ snapshots: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 3.9.10 + typescript: 5.7.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optional: true - ts-node@10.9.2(@types/node@20.17.30)(typescript@5.7.2): + ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.17.30 + '@types/node': 20.17.6 acorn: 8.14.0 acorn-walk: 8.3.4 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.7.2 + typescript: 5.6.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optional: true - ts-node@10.9.2(@types/node@20.17.6)(typescript@5.6.3): + ts-node@10.9.2(@types/node@24.0.10)(typescript@3.9.10): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.17.6 + '@types/node': 24.0.10 acorn: 8.14.0 acorn-walk: 8.3.4 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.6.3 + typescript: 3.9.10 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optional: true From ef36669b02d08417853a8ac794a2133b0405783f Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 15 Aug 2025 13:27:25 -0300 Subject: [PATCH 4/9] Refactor Xero Accounting API actions to utilize utility functions for improved data handling. Key changes include: - Integrated `formatLineItems` in `create-credit-note` and `create-purchase-bill` actions. - Implemented `parseObject` in `make-an-api-call`, `create-employee`, `create-or-update-contact`, and `update-contact` actions for better object parsing. - Updated property names for consistency across actions. These enhancements improve code maintainability and ensure consistent data formatting across API interactions. --- .../create-credit-note/create-credit-note.mjs | 3 +- .../make-an-api-call/make-an-api-call.mjs | 4 +- .../xero-accounting-create-employee.mjs | 7 +-- ...ro-accounting-create-or-update-contact.mjs | 53 ++++++++++--------- .../xero-accounting-update-contact.mjs | 53 ++++++++++--------- .../xero-create-purchase-bill.mjs | 23 ++++---- .../xero-create-sales-invoice.mjs | 2 +- 7 files changed, 76 insertions(+), 69 deletions(-) diff --git a/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs b/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs index 7d9a978b71c8d..a26e8bd2bec40 100644 --- a/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs +++ b/components/xero_accounting_api/actions/create-credit-note/create-credit-note.mjs @@ -1,4 +1,5 @@ import { ConfigurationError } from "@pipedream/platform"; +import { formatLineItems } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -139,7 +140,7 @@ export default { Date: this.date, Status: this.status, LineAmountTypes: this.lineAmountTypes, - LineItems: this.lineItems, + LineItems: formatLineItems(this.lineItems), CurrencyCode: this.currencyCode, CreditNoteNumber: this.creditNoteNumber, Reference: this.reference, diff --git a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs index e4cffa1d7d352..3e96343872ff5 100644 --- a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs +++ b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs @@ -1,4 +1,5 @@ import { ConfigurationError } from "@pipedream/platform"; +import { parseObject } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -60,7 +61,8 @@ export default { method: this.requestMethod, path: this.relativeUrl, params: this.queryString, - data: this.requestBody, + headers: parseObject(this.headers), + data: parseObject(this.requestBody), }); $.export("$summary", `Successfully made API call to ${this.relativeUrl}`); diff --git a/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs b/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs index e72d0d29f8b88..47eaac8ed33c5 100644 --- a/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-create-employee/xero-accounting-create-employee.mjs @@ -1,4 +1,5 @@ import { ConfigurationError } from "@pipedream/platform"; +import { parseObject } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -53,9 +54,9 @@ export default { tenantId: this.tenantId, data: { Status: this.status, - FirstName: this.first_name, - LastName: this.last_name, - ExternalLink: this.external_link, + FirstName: this.firstName, + LastName: this.lastName, + ExternalLink: parseObject(this.externalLink), }, }); diff --git a/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs b/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs index c55a43e389b10..cdc803fa0b10a 100644 --- a/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs @@ -1,3 +1,4 @@ +import { parseObject } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -194,32 +195,32 @@ export default { tenantId: this.tenantId, data: { Name: this.name, - ContactID: this.contact_id, - ContactNumber: this.contact_number, - AccountNumber: this.account_number, - ContactStatus: this.contact_status, - FirstName: this.first_name, - LastName: this.last_name, - EmailAddress: this.email_address, - SkypeUserName: this.skype_user_name, - ContactPersons: this.contact_persons, - BankAccountDetails: this.bank_account_details, - TaxNumber: this.tax_number, - AccountsReceivableTaxType: this.account_receivable_tax_type, - AccountsPayableTaxType: this.account_payable_type, - Addresses: this.addresses, - Phones: this.phones, - IsSupplier: this.is_supplier, - IsCustomer: this.is_customer, - DefaultCurrency: this.default_currency, - XeroNetworkKey: this.xero_network_key, - SalesDefaultAccountCode: this.sales_default_account_code, - PurchasesDefaultAccountCode: this.puchases_default_account_code, - SalesTrackingCategories: this.sales_tracking_categories, - PurchasesTrackingCategories: this.puechases_tracking_categories, - TrackingCategoryName: this.tracking_category_name, - TrackingOptionName: this.tracking_option_name, - PaymentTerms: this.payment_terms, + ContactID: this.contactId, + ContactNumber: this.contactNumber, + AccountNumber: this.accountNumber, + ContactStatus: this.contactStatus, + FirstName: this.firstName, + LastName: this.lastName, + EmailAddress: this.emailAddress, + SkypeUserName: this.skypeUserName, + ContactPersons: parseObject(this.contactPersons), + BankAccountDetails: this.bankAccountDetails, + TaxNumber: this.taxNumber, + AccountsReceivableTaxType: this.accountReceivableTaxType, + AccountsPayableTaxType: this.accountPayableType, + Addresses: parseObject(this.addresses), + Phones: parseObject(this.phones), + IsSupplier: this.isSupplier, + IsCustomer: this.isCustomer, + DefaultCurrency: this.defaultCurrency, + XeroNetworkKey: this.xeroNetworkKey, + SalesDefaultAccountCode: this.salesDefaultAccountCode, + PurchasesDefaultAccountCode: this.puchasesDefaultAccountCode, + SalesTrackingCategories: this.salesTrackingCategories, + PurchasesTrackingCategories: this.puechasesTrackingCategories, + TrackingCategoryName: this.trackingCategoryName, + TrackingOptionName: this.trackingOptionName, + PaymentTerms: this.paymentTerms, }, }); diff --git a/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs b/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs index 5263f5de5e162..22b39d95c0aa0 100644 --- a/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs @@ -1,4 +1,5 @@ import { ConfigurationError } from "@pipedream/platform"; +import { parseObject } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -199,32 +200,32 @@ export default { contactId: this.contactId, data: { Name: this.name, - ContactID: this.contact_id, - ContactNumber: this.contact_number, - AccountNumber: this.account_number, - ContactStatus: this.contact_status, - FirstName: this.first_name, - LastName: this.last_name, - EmailAddress: this.email_address, - SkypeUserName: this.skype_user_name, - ContactPersons: this.contact_persons, - BankAccountDetails: this.bank_account_details, - TaxNumber: this.tax_number, - AccountsReceivableTaxType: this.account_receivable_tax_type, - AccountsPayableTaxType: this.account_payable_type, - Addresses: this.addresses, - Phones: this.phones, - IsSupplier: this.is_supplier, - IsCustomer: this.is_customer, - DefaultCurrency: this.default_currency, - XeroNetworkKey: this.xero_network_key, - SalesDefaultAccountCode: this.sales_default_account_code, - PurchasesDefaultAccountCode: this.puchases_default_account_code, - SalesTrackingCategories: this.sales_tracking_categories, - PurchasesTrackingCategories: this.puechases_tracking_categories, - TrackingCategoryName: this.tracking_category_name, - TrackingOptionName: this.tracking_option_name, - PaymentTerms: this.payment_terms, + ContactID: this.contactId, + ContactNumber: this.contactNumber, + AccountNumber: this.accountNumber, + ContactStatus: this.contactStatus, + FirstName: this.firstName, + LastName: this.lastName, + EmailAddress: this.emailAddress, + SkypeUserName: this.skypeUserName, + ContactPersons: parseObject(this.contactPersons), + BankAccountDetails: this.bankAccountDetails, + TaxNumber: this.taxNumber, + AccountsReceivableTaxType: this.accountReceivableTaxType, + AccountsPayableTaxType: this.accountPayableType, + Addresses: parseObject(this.addresses), + Phones: parseObject(this.phones), + IsSupplier: this.isSupplier, + IsCustomer: this.isCustomer, + DefaultCurrency: this.defaultCurrency, + XeroNetworkKey: this.xeroNetworkKey, + SalesDefaultAccountCode: this.salesDefaultAccountCode, + PurchasesDefaultAccountCode: this.puchasesDefaultAccountCode, + SalesTrackingCategories: this.salesTrackingCategories, + PurchasesTrackingCategories: this.puechasesTrackingCategories, + TrackingCategoryName: this.trackingCategoryName, + TrackingOptionName: this.trackingOptionName, + PaymentTerms: this.paymentTerms, }, }); diff --git a/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs b/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs index 9ea12d1ce533b..b09875f2703d7 100644 --- a/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs +++ b/components/xero_accounting_api/actions/xero-create-purchase-bill/xero-create-purchase-bill.mjs @@ -1,4 +1,5 @@ import { ConfigurationError } from "@pipedream/platform"; +import { formatLineItems } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -116,22 +117,22 @@ export default { data: { Type: "ACCPAY", //ACCPAY = Purchase Bill Contact: { - ContactID: this.contact_id, - Name: this.contact_name, + ContactID: this.contactId, + Name: this.contactName, }, - LineItems: this.line_items, + LineItems: formatLineItems(this.lineItems), Date: this.date, - DueDate: this.due_date, - LineAmountTypes: this.line_amount_type, - InvoiceNumber: this.purchase_bill_number, + DueDate: this.dueDate, + LineAmountTypes: this.lineAmountType, + InvoiceNumber: this.purchaseBillNumber, Reference: this.reference, - BrandingThemeID: this.branding_theme_id, + BrandingThemeID: this.brandingThemeId, Url: this.url, - CurrencyCode: this.currency_code, - CurrencyRate: this.currency_rate, + CurrencyCode: this.currencyCode, + CurrencyRate: this.currencyRate, Status: this.status, - SentToContact: this.sent_to_contact, - PlannedPaymentDate: this.planned_payment_date, + SentToContact: this.sentToContact, + PlannedPaymentDate: this.plannedPaymentDate, }, }); diff --git a/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs b/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs index 25d3bdce8850e..52a39d3425398 100644 --- a/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs +++ b/components/xero_accounting_api/actions/xero-create-sales-invoice/xero-create-sales-invoice.mjs @@ -6,7 +6,7 @@ export default { key: "xero_accounting_api-xero-create-sales-invoice", name: "Create Sales Invoice", description: "Creates a new sales invoice. [See the documentation](https://developer.xero.com/documentation/api/invoices#post)", - version: "0.3.2", + version: "0.3.3", type: "action", props: { xero, From 3f7e74a68bffead792b656ddf14d78a2d88bcc04 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 15 Aug 2025 13:32:15 -0300 Subject: [PATCH 5/9] Refactor API request handling in Xero Accounting API. Changed the `make-an-api-call` method to directly return the axios call, simplifying the code and improving readability by removing unnecessary variable assignments. --- components/xero_accounting_api/xero_accounting_api.app.mjs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/xero_accounting_api/xero_accounting_api.app.mjs b/components/xero_accounting_api/xero_accounting_api.app.mjs index 687b2fc7221ac..02d972611ca59 100644 --- a/components/xero_accounting_api/xero_accounting_api.app.mjs +++ b/components/xero_accounting_api/xero_accounting_api.app.mjs @@ -104,7 +104,7 @@ export default { headers, ...opts }) { - const config = { + return axios($, { url: `${BASE_URL}/api.xro/2.0${path}`, headers: this.getHeader({ tenantId, @@ -112,9 +112,7 @@ export default { headers, }), ...opts, - }; - console.log("config: ", config); - return axios($, config); + }); }, getTenantConnections() { return this._makeRequest({ From 4a2a9a69ecf69e23bda1a5caef067bf0983095c6 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 15 Aug 2025 13:33:50 -0300 Subject: [PATCH 6/9] remove console.log --- components/xero_accounting_api/xero_accounting_api.app.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/xero_accounting_api/xero_accounting_api.app.mjs b/components/xero_accounting_api/xero_accounting_api.app.mjs index 02d972611ca59..942bf3d78da8b 100644 --- a/components/xero_accounting_api/xero_accounting_api.app.mjs +++ b/components/xero_accounting_api/xero_accounting_api.app.mjs @@ -123,7 +123,6 @@ export default { const invoices = await this.getInvoice({ tenantId, }); - console.log(invoices); return invoices?.Invoices?.map((invoice) => ({ label: invoice.InvoiceNumber, value: invoice.InvoiceID, From 398aec85e99f771f4d32ee087e6934fe463cdd68 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 18 Aug 2025 16:51:47 -0300 Subject: [PATCH 7/9] Refactor Xero Accounting API actions for improved error handling and consistency. Key changes include: - Updated API request methods to use consistent casing for paths (e.g., `/Contacts` and `/Invoices`). - Enhanced error handling in actions to provide clearer feedback when no results are found. - Removed deprecated `find-contact` action and streamlined contact-related actions. - Bumped versions for several actions to reflect updates and improvements. These changes enhance the reliability and maintainability of the Xero Accounting API integration. --- .../create-bank-transaction.mjs | 9 +- .../create-tracking-category.mjs | 24 +- .../create-update-contact.mjs | 31 +-- .../download-invoice/download-invoice.mjs | 3 + .../actions/find-contact/find-contact.mjs | 142 ------------ .../find-or-create-contact.mjs | 206 ++++++------------ .../actions/get-contact/get-contact.mjs | 24 +- .../get-invoice-online-url.mjs | 24 +- .../actions/get-invoice/get-invoice.mjs | 24 +- .../actions/get-item/get-item.mjs | 26 +-- .../get-tracking-category.mjs | 19 +- .../actions/list-contacts/list-contacts.mjs | 42 ++-- .../list-credit-notes/list-credit-notes.mjs | 38 ++-- .../actions/list-invoices/list-invoices.mjs | 48 ++-- .../list-manual-journals.mjs | 38 ++-- .../list-tracking-categories.mjs | 17 +- .../make-an-api-call/make-an-api-call.mjs | 6 - .../actions/upload-file/upload-file.mjs | 24 +- ...ro-accounting-create-or-update-contact.mjs | 39 +++- .../xero-accounting-update-contact.mjs | 39 +++- .../xero_accounting_api.app.mjs | 27 +-- 21 files changed, 335 insertions(+), 515 deletions(-) delete mode 100644 components/xero_accounting_api/actions/find-contact/find-contact.mjs diff --git a/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs b/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs index 10eca976a2377..12d8835819b1a 100644 --- a/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs +++ b/components/xero_accounting_api/actions/create-bank-transaction/create-bank-transaction.mjs @@ -116,10 +116,11 @@ export default { }, }, async run({ $ }) { - if ((!this.bankAccountCode && !this.bankAccountId) - || (!this.contactId && !this.contactName) - || !this.tenantId || !this.type || !this.lineItems) { - throw new ConfigurationError("Must provide one of **Bank Account Code** or **Bank Account ID**, **Contact ID** or **Contact Name**, **Tenant ID**, **Type**, and **Line Items** parameters."); + if (!this.bankAccountCode && !this.bankAccountId) { + throw new ConfigurationError("Must provide one of **Bank Account Code** or **Bank Account ID** parameters."); + } + if (!this.contactId && !this.contactName) { + throw new ConfigurationError("Must provide one of **Contact ID** or **Contact Name** parameters."); } const response = await this.xeroAccountingApi.createBankTransaction({ diff --git a/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs b/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs index 847c92d0edcac..720ff6460d2da 100644 --- a/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs +++ b/components/xero_accounting_api/actions/create-tracking-category/create-tracking-category.mjs @@ -38,18 +38,20 @@ export default { }, }); - const parsedOptions = parseObject(this.options); + if (this.options) { + const parsedOptions = parseObject(this.options); - for (const option of parsedOptions) { - const optionResponse = await this.xeroAccountingApi.createTrackingOption({ - $, - tenantId: this.tenantId, - trackingCategoryId: response.TrackingCategories[0].TrackingCategoryID, - data: { - Name: option, - }, - }); - response.TrackingCategories[0].Options.push(optionResponse.Options[0]); + for (const option of parsedOptions) { + const optionResponse = await this.xeroAccountingApi.createTrackingOption({ + $, + tenantId: this.tenantId, + trackingCategoryId: response.TrackingCategories[0].TrackingCategoryID, + data: { + Name: option, + }, + }); + response.TrackingCategories[0].Options.push(optionResponse.Options[0]); + } } $.export("$summary", `Successfully created tracking category with ID: ${response.TrackingCategories[0].TrackingCategoryID}`); diff --git a/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs b/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs index a63a52b8e90f7..f530632203522 100644 --- a/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs +++ b/components/xero_accounting_api/actions/create-update-contact/create-update-contact.mjs @@ -1,3 +1,4 @@ +import { ConfigurationError } from "@pipedream/platform"; import { removeNullEntries } from "../../common/util.mjs"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; @@ -5,7 +6,7 @@ export default { key: "xero_accounting_api-create-update-contact", name: "Create or update contact ", description: "Creates a new contact or updates a contact if a contact already exists. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts)", - version: "0.0.3", + version: "0.1.0", type: "action", props: { xeroAccountingApi, @@ -15,15 +16,11 @@ export default { "tenantId", ], }, - actionType: { - label: "Type of action", - description: "This triggers an update if UPDATE is selected", + contactID: { type: "string", - options: [ - "NEW", - "UPDATE", - ], - reloadProps: true, + label: "Contact ID", + description: "ID of the contact that requires update.", + optional: true, }, name: { type: "string", @@ -68,18 +65,10 @@ export default { default: "ACTIVE", }, }, - async additionalProps() { - const props = {}; - if (this.actionType === "UPDATE") { - props.contactID = { - type: "string", - label: "Contact ID", - description: "ID of the contact that requires update.", - }; - } - return props; - }, async run({ $ }) { + if (!this.contactID && !this.name) { + throw new ConfigurationError("Must provide **Contact ID** or **Contact Name** parameter."); + } const { contactID, tenantId, @@ -99,7 +88,7 @@ export default { ContactStatus: contactStatus, }); contactID && (data.ContactID = contactID); - const response = await this.xeroAccountingApi.createContact({ + const response = await this.xeroAccountingApi.createOrUpdateContact({ $, tenantId, data, diff --git a/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs b/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs index 99180fc89f91a..4d372ad791023 100644 --- a/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs +++ b/components/xero_accounting_api/actions/download-invoice/download-invoice.mjs @@ -37,6 +37,9 @@ export default { tenantId: this.tenantId, invoiceId: this.invoiceId, responseType: "arraybuffer", + headers: { + Accept: "application/pdf", + }, }); const invoicePdf = data.toString("base64"); diff --git a/components/xero_accounting_api/actions/find-contact/find-contact.mjs b/components/xero_accounting_api/actions/find-contact/find-contact.mjs deleted file mode 100644 index 8c908b1b415e2..0000000000000 --- a/components/xero_accounting_api/actions/find-contact/find-contact.mjs +++ /dev/null @@ -1,142 +0,0 @@ -import { ConfigurationError } from "@pipedream/platform"; -import { - formatQueryString, - removeNullEntries, -} from "../../common/util.mjs"; -import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; - -export default { - key: "xero_accounting_api-find-contact", - name: "Find contact. Optionally, create one if none are found", - description: "Finds a contact by name or account number. Optionally, create one if none are found. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)", - version: "0.0.3", - type: "action", - props: { - xeroAccountingApi, - tenantId: { - propDefinition: [ - xeroAccountingApi, - "tenantId", - ], - }, - name: { - type: "string", - label: "Contact name", - description: "Full name of contact/organization ", - optional: true, - }, - accountNumber: { - type: "string", - label: "Account number", - description: "Account number of Contact.", - optional: true, - }, - createContactIfNotFound: { - description: "Create a new contact if not found?.", - label: "Create a new contact if not found", - type: "string", - options: [ - "Yes", - "No", - ], - reloadProps: true, - }, - }, - additionalProps() { - const props = {}; - if (this.createContactIfNotFound === "Yes") { - props.name = { - type: "string", - label: "Contact name", - description: "Full name of contact/organization.", - }; - props.firstName = { - type: "string", - label: "First name", - description: "First name of contact person .", - optional: true, - }; - props.lastName = { - type: "string", - label: "Last name", - description: "Last name of contact person.", - optional: true, - }; - props.emailAddress = { - type: "string", - label: "Email address", - description: "Email address of contact person.", - optional: true, - }; - props.contactStatus = { - type: "string", - label: "Contact status", - description: - "See [contact status reference](https://developer.xero.com/documentation/api/accounting/types#contacts)", - options: [ - "ACTIVE", - "ARCHIVED", - "GDPRREQUEST", - ], - optional: true, - default: "ACTIVE", - }; - } - return props; - }, - async run({ $ }) { - let contactDetail; - const { - tenantId, - name, - firstName, - lastName, - emailAddress, - accountNumber, - contactStatus, - createContactIfNotFound, - } = this; - if (createContactIfNotFound === "No" && accountNumber && name) { - throw new ConfigurationError( - "Choose exclusively between Account Number or Name to find a contact.", - ); - } - const findPayload = removeNullEntries({ - Name: name, - AccountNumber: accountNumber, - }); - const createPayload = removeNullEntries({ - Name: name, - FirstName: firstName, - LastName: lastName, - EmailAddress: emailAddress, - AccountNumber: accountNumber, - ContactStatus: contactStatus, - }); - try { - contactDetail = await this.xeroAccountingApi.getContact({ - $, - tenantId, - queryParam: formatQueryString(findPayload, true), - }); - } catch (error) { - if (createContactIfNotFound === "Yes") { - $.export("$summary", "Contact not found. Creating new contact"); - } else { - throw new ConfigurationError("Contact not found"); - } - } - - if ( - (!contactDetail || !contactDetail?.Contacts?.length) && - createContactIfNotFound === "Yes" - ) { - return await this.xeroAccountingApi.createContact({ - $, - tenantId, - data: createPayload, - }); - } - return contactDetail; - }, -}; diff --git a/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs b/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs index bf49af0a109b6..cd99a60b0cdf0 100644 --- a/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs +++ b/components/xero_accounting_api/actions/find-or-create-contact/find-or-create-contact.mjs @@ -8,8 +8,8 @@ import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { key: "xero_accounting_api-find-or-create-contact", name: "Find or Create Contact", - description: "Finds a contact by email address. Optionally, create one if none are found. [See the documentation](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)", - version: "0.0.2", + description: "Finds a contact by name or email address. Optionally, create one if none are found. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)", + version: "0.1.0", type: "action", props: { xeroAccountingApi, @@ -19,42 +19,49 @@ export default { "tenantId", ], }, + name: { + type: "string", + label: "Contact name", + description: "Full name of contact/organization ", + optional: true, + }, emailAddress: { type: "string", label: "Email address", - description: "Email address of contact.", + description: "Email address of contact/organization.", + optional: true, }, createContactIfNotFound: { - type: "boolean", + description: "Create a new contact if not found?.", label: "Create a new contact if not found", - description: "Set to `true` to create a new contact if not found.", + type: "string", + options: [ + "Yes", + "No", + ], reloadProps: true, }, }, additionalProps() { const props = {}; - if (this.createContactIfNotFound) { - props.name = { - type: "string", - label: "Contact name", - description: "Full name of contact/organization.", - }; + if (this.createContactIfNotFound === "Yes") { props.firstName = { type: "string", label: "First name", - description: "First name of contact.", + description: "First name of contact person .", optional: true, }; props.lastName = { type: "string", label: "Last name", - description: "Last name of contact.", + description: "Last name of contact person.", optional: true, }; props.contactStatus = { type: "string", label: "Contact status", - description: "See [contact status reference](https://developer.xero.com/documentation/api/accounting/types#contacts)", + description: + "See [contact status reference](https://developer.xero.com/documentation/api/accounting/types#contacts)", options: [ "ACTIVE", "ARCHIVED", @@ -63,138 +70,61 @@ export default { optional: true, default: "ACTIVE", }; - props.companyNumber = { - type: "string", - label: "Company Number", - description: "Company registration number. Max 50 char.", - optional: true, - }; - props.addressType = { - type: "string", - label: "Address Type", - description: "The type of mailing address. Required if entering address information", - options: [ - "POBOX", - "STREET", - "DELIVERY", - ], - optional: true, - }; - props.addressLine1 = { - type: "string", - label: "Address Line 1", - description: "Street address of contact", - optional: true, - }; - props.addressLine2 = { - type: "string", - label: "Address Line 2", - description: "Line 2 of the street address of contact", - optional: true, - }; - props.city = { - type: "string", - label: "City", - description: "City address of contact", - optional: true, - }; - props.region = { - type: "string", - label: "Region", - description: "Region/State address of contact", - optional: true, - }; - props.postalCode = { - type: "string", - label: "Postal Code", - description: "Postal Code address of contact", - optional: true, - }; - props.country = { - type: "string", - label: "Country", - description: "Country of contact", - optional: true, - }; - props.phoneNumber = { - type: "string", - label: "Phone Number", - description: "Phone number of contact", - optional: true, - }; } return props; }, async run({ $ }) { - const queryString = formatQueryString({ - EmailAddress: this.emailAddress, - }, true); - const contactDetail = await this.xeroAccountingApi.getContact({ - $, - tenantId: this.tenantId, - queryParam: queryString, - }); - const found = contactDetail?.Contacts?.length; - - if (!this.createContactIfNotFound && !found) { - throw new ConfigurationError("Contact not found"); + let contactDetail; + const { + tenantId, + name, + firstName, + lastName, + emailAddress, + contactStatus, + createContactIfNotFound, + } = this; + if (createContactIfNotFound === "No" && emailAddress && name) { + throw new ConfigurationError( + "Choose exclusively between Email Address or Name to find a contact.", + ); } - - if (found) { - $.export("$summary", `Successfully found contact with email \`${this.emailAddress}\`.`); - return contactDetail; - } - - const addressEntered = this.addressLine1 - || this.addressLine1 - || this.city - || this.region - || this.postalCode - || this.country; - if (addressEntered && !this.addressType) { - throw new ConfigurationError("**Address Type** is required when entering address information."); - } else if (!addressEntered && this.addressType) { - throw new ConfigurationError("Must enter address information along with **Address Type**."); - } - + const findPayload = removeNullEntries({ + Name: name, + EmailAddress: emailAddress, + }); const createPayload = removeNullEntries({ - Name: this.name, - FirstName: this.firstName, - LastName: this.lastName, - EmailAddress: this.emailAddress, - ContactStatus: this.contactStatus, - CompanyNumber: this.companyNumber, - Addresses: addressEntered - ? [ - { - AddressType: this.addressType, - AddressLine1: this.addressLine1, - AddressLine2: this.addressLine1, - City: this.city, - Region: this.region, - PostalCode: this.postalCode, - Country: this.country, - }, - ] - : undefined, - Phones: this.phoneNumber - ? [ - { - PhoneType: "DEFAULT", - PhoneNumber: this.phoneNumber, - }, - ] - : undefined, + Name: name, + FirstName: firstName, + LastName: lastName, + EmailAddress: emailAddress, + ContactStatus: contactStatus, }); + try { + contactDetail = await this.xeroAccountingApi.getContact({ + $, + tenantId, + queryParam: formatQueryString(findPayload, true), + }); + } catch (error) { + if (createContactIfNotFound === "Yes") { + $.export("$summary", "Contact not found. Creating new contact"); + } else { + $.export("$summary", "No contact found."); + return {}; + } + } - const response = await this.xeroAccountingApi.createContact({ - $, - tenantId: this.tenantId, - data: createPayload, - }); - if (response?.Contacts?.length) { - $.export("$summary", `Successfully created new contact with ID ${response.Contacts[0].ContactID}.`); + if ( + (!contactDetail || !contactDetail?.Contacts?.length) && + createContactIfNotFound === "Yes" + ) { + return await this.xeroAccountingApi.createOrUpdateContact({ + $, + tenantId, + data: createPayload, + }); } - return response; + return contactDetail; }, }; diff --git a/components/xero_accounting_api/actions/get-contact/get-contact.mjs b/components/xero_accounting_api/actions/get-contact/get-contact.mjs index eea73f3be1bc5..5eb2032679f15 100644 --- a/components/xero_accounting_api/actions/get-contact/get-contact.mjs +++ b/components/xero_accounting_api/actions/get-contact/get-contact.mjs @@ -1,4 +1,3 @@ -import { ConfigurationError } from "@pipedream/platform"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -22,17 +21,18 @@ export default { }, }, async run({ $ }) { - if (!this.tenantId || !this.contactIdentifier) { - throw new ConfigurationError("Must provide **Tenant ID**, and **Contact Identifier** parameters."); - } - - const response = await this.xeroAccountingApi.getContactById({ - $, - tenantId: this.tenantId, - contactIdentifier: this.contactIdentifier, - }); + try { + const response = await this.xeroAccountingApi.getContactById({ + $, + tenantId: this.tenantId, + contactIdentifier: this.contactIdentifier, + }); - $.export("$summary", `Contact retrieved successfully: ${this.contactIdentifier}`); - return response; + $.export("$summary", `Contact retrieved successfully: ${this.contactIdentifier}`); + return response; + } catch (e) { + $.export("$summary", `No contact found with identifier: ${this.contactIdentifier}`); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs b/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs index d3cf1e7111878..b6805ebfcb0dd 100644 --- a/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs +++ b/components/xero_accounting_api/actions/get-invoice-online-url/get-invoice-online-url.mjs @@ -1,4 +1,3 @@ -import { ConfigurationError } from "@pipedream/platform"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -22,17 +21,18 @@ export default { }, }, async run({ $ }) { - if (!this.tenantId || !this.invoiceId) { - throw new ConfigurationError("Must provide **Tenant ID**, and **Invoice ID** parameters."); - } - - const response = await this.xeroAccountingApi.getInvoiceOnlineUrl({ - $, - tenantId: this.tenantId, - invoiceId: this.invoiceId, - }); + try { + const response = await this.xeroAccountingApi.getInvoiceOnlineUrl({ + $, + tenantId: this.tenantId, + invoiceId: this.invoiceId, + }); - $.export("$summary", `Invoice online URL retrieved successfully: ${this.invoiceId}`); - return response; + $.export("$summary", `Invoice online URL retrieved successfully: ${this.invoiceId}`); + return response; + } catch (e) { + $.export("$summary", `No invoice found with identifier: ${this.invoiceId}`); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs b/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs index b980e3810b1bc..f92a494e589bc 100644 --- a/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs +++ b/components/xero_accounting_api/actions/get-invoice/get-invoice.mjs @@ -1,4 +1,3 @@ -import { ConfigurationError } from "@pipedream/platform"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -22,17 +21,18 @@ export default { }, }, async run({ $ }) { - if (!this.tenantId || !this.invoiceId) { - throw new ConfigurationError("Must provide **Tenant ID**, and **Invoice ID** parameters."); - } - - const response = await this.xeroAccountingApi.getInvoiceById({ - $, - tenantId: this.tenantId, - invoiceId: this.invoiceId, - }); + try { + const response = await this.xeroAccountingApi.getInvoiceById({ + $, + tenantId: this.tenantId, + invoiceId: this.invoiceId, + }); - $.export("$summary", `Invoice retrieved successfully: ${this.invoiceId}`); - return response; + $.export("$summary", `Invoice retrieved successfully: ${this.invoiceId}`); + return response; + } catch (e) { + $.export("$summary", `No invoice found with identifier: ${this.invoiceId}`); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/get-item/get-item.mjs b/components/xero_accounting_api/actions/get-item/get-item.mjs index 980efc3f7a0e2..1269dfc600124 100644 --- a/components/xero_accounting_api/actions/get-item/get-item.mjs +++ b/components/xero_accounting_api/actions/get-item/get-item.mjs @@ -1,4 +1,3 @@ -import { ConfigurationError } from "@pipedream/platform"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -18,21 +17,22 @@ export default { itemId: { label: "Item ID", type: "string", - description: "You can specify an individual record by appending the value to the endpoint, i.e.\n**GET https://.../Items/{identifier}**. Possible values:\n* **ItemID** - The Xero identifier for an Item e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **Code**- The user defined code of an item e.g. ITEM-001", + description: "Possible values:\n* **ItemID** - The Xero identifier for an Item e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **Code**- The user defined code of an item e.g. ITEM-001", }, }, async run({ $ }) { - if (!this.tenantId || !this.itemId) { - throw new ConfigurationError("Must provide **Tenant ID**, and **Item ID** parameters."); - } - - const response = await this.xeroAccountingApi.getItemById({ - $, - tenantId: this.tenantId, - itemId: this.itemId, - }); + try { + const response = await this.xeroAccountingApi.getItemById({ + $, + tenantId: this.tenantId, + itemId: this.itemId, + }); - $.export("$summary", `Item retrieved successfully: ${this.itemId}`); - return response; + $.export("$summary", `Item retrieved successfully: ${this.itemId}`); + return response; + } catch (e) { + $.export("$summary", `No item found with identifier: ${this.itemId}`); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs b/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs index 7872164bd4220..1e7e27860215e 100644 --- a/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs +++ b/components/xero_accounting_api/actions/get-tracking-category/get-tracking-category.mjs @@ -25,13 +25,18 @@ export default { }, }, async run({ $ }) { - const response = await this.xeroAccountingApi.getTrackingCategory({ - $, - tenantId: this.tenantId, - trackingCategoryId: this.trackingCategoryId, - }); + try { + const response = await this.xeroAccountingApi.getTrackingCategory({ + $, + tenantId: this.tenantId, + trackingCategoryId: this.trackingCategoryId, + }); - $.export("$summary", `Successfully fetched tracking category with ID: ${this.trackingCategoryId}`); - return response; + $.export("$summary", `Successfully fetched tracking category with ID: ${this.trackingCategoryId}`); + return response; + } catch (e) { + $.export("$summary", `No tracking category found with identifier: ${this.trackingCategoryId}`); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs b/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs index e918e1786d2be..a181432490e4d 100644 --- a/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs +++ b/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs @@ -4,7 +4,7 @@ export default { key: "xero_accounting_api-list-contacts", name: "List Contacts", description: "Lists information from contacts in the given tenant id as per filter parameters.", - version: "0.1.2", + version: "0.2.0", type: "action", props: { xeroAccountingApi, @@ -14,12 +14,6 @@ export default { "tenantId", ], }, - contactIdentifier: { - label: "Contact Identifier", - type: "string", - description: "A contact identifier. Possible values: \n* **ContactID** - The Xero identifier for a contact e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **ContactNumber** - A custom identifier specified from another system e.g. a CRM system has a contact number of CUST100", - optional: true, - }, modifiedAfter: { label: "Modified After", description: "Filter by a date. Only contacts modified since this date will be returned. Format: YYYY-MM-DD", @@ -58,21 +52,25 @@ export default { }, }, async run({ $ }) { - const response = await this.xeroAccountingApi.listContacts({ - $, - tenantId: this.tenantId, - contactIdentifier: this.contactIdentifier, - modifiedAfter: this.modifiedAfter, - params: { - IDs: this.ids, - Where: this.where, - order: this.order, - page: this.page, - includeArchived: this.includeArchived, - }, - }); + try { + const response = await this.xeroAccountingApi.listContacts({ + $, + tenantId: this.tenantId, + modifiedAfter: this.modifiedAfter, + params: { + IDs: this.ids, + Where: this.where, + order: this.order, + page: this.page, + includeArchived: this.includeArchived, + }, + }); - $.export("$summary", `Successfully fetched contacts with ID: ${this.contactIdentifier}`); - return response; + $.export("$summary", `Successfully fetched ${response.Contacts.length} contacts`); + return response; + } catch (e) { + $.export("$summary", "No contacts found"); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs b/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs index 0c67dc38a65c0..16bcf183f06a0 100644 --- a/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs +++ b/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs @@ -4,7 +4,7 @@ export default { key: "xero_accounting_api-list-credit-notes", name: "List Credit Notes", description: "Lists information from credit notes in the given tenant id as per filter parameters.", - version: "0.1.2", + version: "0.2.0", type: "action", props: { xeroAccountingApi, @@ -14,12 +14,6 @@ export default { "tenantId", ], }, - creditNoteIdentifier: { - label: "Credit Note Identifier", - type: "string", - description: "Credit note identifier of the contact to get. Possible values: \n* **CreditNoteID** - The Xero identifier for a contact note e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **CreditNoteNumber** - Identifier for Credit Note CN-8743802", - optional: true, - }, modifiedAfter: { label: "Modified After", type: "string", @@ -46,19 +40,23 @@ export default { }, }, async run({ $ }) { - const response = await this.xeroAccountingApi.listCreditNotes({ - $, - tenantId: this.tenantId, - creditNoteIdentifier: this.creditNoteIdentifier, - modifiedAfter: this.modifiedAfter, - params: { - Where: this.where, - order: this.order, - page: this.page, - }, - }); + try { + const response = await this.xeroAccountingApi.listCreditNotes({ + $, + tenantId: this.tenantId, + modifiedAfter: this.modifiedAfter, + params: { + Where: this.where, + order: this.order, + page: this.page, + }, + }); - $.export("$summary", `Successfully fetched credit notes with ID: ${this.creditNoteIdentifier}`); - return response; + $.export("$summary", `Successfully fetched ${response.CreditNotes.length} credit notes`); + return response; + } catch (e) { + $.export("$summary", "No credit notes found"); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs index ab293a0ca11db..5505255ff9464 100644 --- a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs +++ b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs @@ -4,7 +4,7 @@ export default { key: "xero_accounting_api-list-invoices", name: "List Invoices", description: "Lists information from invoices in the given tenant id as per filter parameters.", - version: "0.2.2", + version: "0.3.0", type: "action", props: { xeroAccountingApi, @@ -14,12 +14,6 @@ export default { "tenantId", ], }, - invoiceIdentifier: { - label: "Invoice Identifier", - type: "string", - description: "An invoice identifier. Possible values:\n\n* **InvoiceID** - The Xero identifier for an Invoice e.g. 297c2dc5-cc47-4afd-8ec8-74990b8761e9\n* **InvoiceNumber** - The InvoiceNumber e.g. INV-01514", - optional: true, - }, modifiedAfter: { label: "Modified After", type: "string", @@ -76,24 +70,28 @@ export default { }, }, async run({ $ }) { - const response = await this.xeroAccountingApi.listInvoices({ - $, - tenantId: this.tenantId, - invoiceIdentifier: this.invoiceIdentifier, - modifiedAfter: this.modifiedAfter, - params: { - IDs: this.ids, - InvoiceNumbers: this.invoiceNumbers, - ContactIDs: this.contactIds, - Statuses: this.statuses, - Where: this.where, - createdByMyApp: this.createdByMyApp, - order: this.order, - page: this.page, - }, - }); + try { + const response = await this.xeroAccountingApi.listInvoices({ + $, + tenantId: this.tenantId, + modifiedAfter: this.modifiedAfter, + params: { + IDs: this.ids, + InvoiceNumbers: this.invoiceNumbers, + ContactIDs: this.contactIds, + Statuses: this.statuses, + Where: this.where, + createdByMyApp: this.createdByMyApp, + order: this.order, + page: this.page, + }, + }); - $.export("$summary", `Successfully fetched invoices with ID: ${this.invoiceIdentifier}`); - return response; + $.export("$summary", `Successfully fetched ${response.Invoices.length} invoices`); + return response; + } catch (e) { + $.export("$summary", "No invoices found"); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs b/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs index d3cc725370a76..4c8c112abb5c7 100644 --- a/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs +++ b/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs @@ -4,7 +4,7 @@ export default { key: "xero_accounting_api-list-manual-journals", name: "List Manual Journals", description: "Lists information from manual journals in the given tenant id as per filter parameters.", - version: "0.1.2", + version: "0.2.0", type: "action", props: { xeroAccountingApi, @@ -14,12 +14,6 @@ export default { "tenantId", ], }, - manualJournalId: { - label: "Manual Journal ID", - type: "string", - description: "You can specify an individual record by appending the ManualJournalID to the endpoint, i.e. **GET https://.../ManualJournals/{identifier}**", - optional: true, - }, modifiedAfter: { label: "Modified After", type: "string", @@ -46,19 +40,23 @@ export default { }, }, async run({ $ }) { - const response = await this.xeroAccountingApi.listManualJournals({ - $, - tenantId: this.tenantId, - manualJournalId: this.manualJournalId, - modifiedAfter: this.modifiedAfter, - params: { - Where: this.where, - order: this.order, - page: this.page, - }, - }); + try { + const response = await this.xeroAccountingApi.listManualJournals({ + $, + tenantId: this.tenantId, + modifiedAfter: this.modifiedAfter, + params: { + Where: this.where, + order: this.order, + page: this.page, + }, + }); - $.export("$summary", `Successfully fetched manual journals with ID: ${this.manualJournalId}`); - return response; + $.export("$summary", `Successfully fetched ${response.ManualJournals.length} manual journals`); + return response; + } catch (e) { + $.export("$summary", "No manual journals found"); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs b/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs index 86c7547025743..2bcd2e466e76c 100644 --- a/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs +++ b/components/xero_accounting_api/actions/list-tracking-categories/list-tracking-categories.mjs @@ -16,12 +16,17 @@ export default { }, }, async run({ $ }) { - const response = await this.xeroAccountingApi.getTrackingCategories({ - $, - tenantId: this.tenantId, - }); + try { + const response = await this.xeroAccountingApi.getTrackingCategories({ + $, + tenantId: this.tenantId, + }); - $.export("$summary", `Successfully listed ${response.TrackingCategories.length} tracking categories`); - return response; + $.export("$summary", `Successfully fetched ${response.TrackingCategories.length} tracking categories`); + return response; + } catch (e) { + $.export("$summary", "No tracking categories found"); + return {}; + } }, }; diff --git a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs index 3e96343872ff5..4519cd0350d65 100644 --- a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs +++ b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs @@ -39,11 +39,6 @@ export default { description: "Query string of the request.", optional: true, }, - headers: { - label: "Headers", - type: "object", - description: "Headers to send in the request. Must include header `xero-tenant-id` with Id of the organization tenant to use on the Xero Accounting API. See [Get Tenant Connections](https://pipedream.com/@sergio/xero-accounting-api-get-tenant-connections-p_OKCzOgn/edit) for a workflow example on how to pull this data.", - }, requestBody: { label: "Request Body", type: "object", @@ -61,7 +56,6 @@ export default { method: this.requestMethod, path: this.relativeUrl, params: this.queryString, - headers: parseObject(this.headers), data: parseObject(this.requestBody), }); diff --git a/components/xero_accounting_api/actions/upload-file/upload-file.mjs b/components/xero_accounting_api/actions/upload-file/upload-file.mjs index 47c9e1068ef1b..72f53dedd5bcf 100644 --- a/components/xero_accounting_api/actions/upload-file/upload-file.mjs +++ b/components/xero_accounting_api/actions/upload-file/upload-file.mjs @@ -1,5 +1,4 @@ import { getFileStreamAndMetadata } from "@pipedream/platform"; -import FormData from "form-data"; import xeroAccountingApi from "../../xero_accounting_api.app.mjs"; export default { @@ -49,16 +48,21 @@ export default { optional: true, }, }, + methods: { + streamToBuffer(stream) { + return new Promise((resolve, reject) => { + const chunks = []; + stream.on("data", (chunk) => chunks.push(chunk)); + stream.on("end", () => resolve(Buffer.concat(chunks))); + stream.on("error", reject); + }); + }, + }, async run({ $ }) { const { stream, metadata, } = await getFileStreamAndMetadata(this.filePathOrUrl); - const data = new FormData(); - data.append("file", stream, { - contentType: metadata.contentType, - knownLength: metadata.size, - filename: metadata.name, - }); + const fileBinary = await this.streamToBuffer(stream); const response = await this.xeroAccountingApi.uploadFile({ $, @@ -67,9 +71,11 @@ export default { documentId: this.documentId, fileName: metadata.name, headers: { - ...data.getHeaders(), + "Content-Type": metadata.contentType, + "Content-Length": metadata.size, + "Accept": "application/json", }, - data, + data: Buffer.from(fileBinary, "binary"), }); $.export("$summary", `Successfully uploaded file to ${this.documentType} with ID: ${this.documentId}`); diff --git a/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs b/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs index cdc803fa0b10a..0425c3afdc040 100644 --- a/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs @@ -176,16 +176,34 @@ export default { description: "The name of the Tracking Option assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories", optional: true, }, - paymentTerms: { - label: "Payment Terms", + paymentTermsBillDay: { + label: "Payment Terms Bill Day", + type: "integer", + description: "The default payment terms bill day", + optional: true, + }, + paymentTermsBillType: { type: "string", - description: "The default payment terms for the contact - see Payment Terms", + label: "Payment Terms Bill Type", + description: "The default payment terms bill type", optional: true, options: [ - "DAYSAFTERBILLDATE", - "DAYSAFTERBILLMONTH", - "OFCURRENTMONTH", - "OFFOLLOWINGMONTH", + { + "label": "day(s) after bill date", + "value": "DAYSAFTERBILLDATE", + }, + { + "label": "day(s) after bill month", + "value": "DAYSAFTERBILLMONTH", + }, + { + "label": "of the current month", + "value": "OFCURRENTMONTH", + }, + { + "label": "of the following month", + "value": "OFFOLLOWINGMONTH", + }, ], }, }, @@ -220,7 +238,12 @@ export default { PurchasesTrackingCategories: this.puechasesTrackingCategories, TrackingCategoryName: this.trackingCategoryName, TrackingOptionName: this.trackingOptionName, - PaymentTerms: this.paymentTerms, + PaymentTerms: { + Bills: { + Day: this.paymentTermsBillDay, + Type: this.paymentTermsBillType, + }, + }, }, }); diff --git a/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs b/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs index 22b39d95c0aa0..1289775e53273 100644 --- a/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs +++ b/components/xero_accounting_api/actions/xero-accounting-update-contact/xero-accounting-update-contact.mjs @@ -176,16 +176,34 @@ export default { description: "The name of the Tracking Option assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories", optional: true, }, - paymentTerms: { - label: "Payment Terms", + paymentTermsBillDay: { + label: "Payment Terms Bill Day", + type: "integer", + description: "The default payment terms bill day", + optional: true, + }, + paymentTermsBillType: { type: "string", - description: "The default payment terms for the contact - see Payment Terms", + label: "Payment Terms Bill Type", + description: "The default payment terms bill type", optional: true, options: [ - "DAYSAFTERBILLDATE", - "DAYSAFTERBILLMONTH", - "OFCURRENTMONTH", - "OFFOLLOWINGMONTH", + { + "label": "day(s) after bill date", + "value": "DAYSAFTERBILLDATE", + }, + { + "label": "day(s) after bill month", + "value": "DAYSAFTERBILLMONTH", + }, + { + "label": "of the current month", + "value": "OFCURRENTMONTH", + }, + { + "label": "of the following month", + "value": "OFFOLLOWINGMONTH", + }, ], }, }, @@ -225,7 +243,12 @@ export default { PurchasesTrackingCategories: this.puechasesTrackingCategories, TrackingCategoryName: this.trackingCategoryName, TrackingOptionName: this.trackingOptionName, - PaymentTerms: this.paymentTerms, + PaymentTerms: { + Bills: { + Day: this.paymentTermsBillDay, + Type: this.paymentTermsBillType, + }, + }, }, }); diff --git a/components/xero_accounting_api/xero_accounting_api.app.mjs b/components/xero_accounting_api/xero_accounting_api.app.mjs index 942bf3d78da8b..518cead2d0bd4 100644 --- a/components/xero_accounting_api/xero_accounting_api.app.mjs +++ b/components/xero_accounting_api/xero_accounting_api.app.mjs @@ -165,19 +165,12 @@ export default { ...opts, }); }, - createContact(opts = {}) { - return this._makeRequest({ - method: "post", - path: "/contacts", - ...opts, - }); - }, getContact({ queryParam, ...opts }) { const where = chainQueryString(queryParam); return this._makeRequest({ - path: "/contacts", + path: "/Contacts", params: where && { Where: where, }, @@ -186,7 +179,7 @@ export default { }, createInvoice(opts = {}) { return this._makeRequest({ - method: "post", + method: "POST", path: "/Invoices", ...opts, }); @@ -204,7 +197,7 @@ export default { invoiceId, ...opts }) { return this._makeRequest({ - method: "post", + method: "POST", path: `/Invoices/${invoiceId}/Email`, ...opts, }); @@ -339,19 +332,15 @@ export default { ...opts, }); }, - listContacts({ - contactIdentifier, ...opts - }) { + listContacts(opts = {}) { return this._makeRequest({ - path: `/Contacts/${contactIdentifier}`, + path: "/Contacts", ...opts, }); }, - listCreditNotes({ - creditNoteIdentifier, ...opts - }) { + listCreditNotes(opts = {}) { return this._makeRequest({ - path: `/CreditNotes/${creditNoteIdentifier}`, + path: "/CreditNotes", ...opts, }); }, @@ -375,7 +364,7 @@ export default { documentType, documentId, fileName, ...opts }) { return this._makeRequest({ - method: "post", + method: "POST", path: `/${documentType}/${documentId}/Attachments/${fileName}`, ...opts, }); From 8e10f8429745a3ef2b7222e65298a5ce668422d9 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 19 Aug 2025 10:28:41 -0300 Subject: [PATCH 8/9] Refactor Xero Accounting API actions for consistency and clarity. Key changes include: - Updated `listInvoices`, `listManualJournals`, `listCreditNotes`, and `listContacts` methods to use `modifiedSince` instead of `modifiedAfter` for parameter naming consistency. - Simplified API request paths for `listInvoices` and `listManualJournals` by removing unnecessary identifiers. These modifications enhance the clarity and maintainability of the API integration. --- .../actions/list-contacts/list-contacts.mjs | 2 +- .../actions/list-credit-notes/list-credit-notes.mjs | 2 +- .../actions/list-invoices/list-invoices.mjs | 2 +- .../list-manual-journals/list-manual-journals.mjs | 2 +- .../actions/make-an-api-call/make-an-api-call.mjs | 1 + .../xero_accounting_api/xero_accounting_api.app.mjs | 12 ++++-------- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs b/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs index a181432490e4d..e7613163a1210 100644 --- a/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs +++ b/components/xero_accounting_api/actions/list-contacts/list-contacts.mjs @@ -56,7 +56,7 @@ export default { const response = await this.xeroAccountingApi.listContacts({ $, tenantId: this.tenantId, - modifiedAfter: this.modifiedAfter, + modifiedSince: this.modifiedAfter, params: { IDs: this.ids, Where: this.where, diff --git a/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs b/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs index 16bcf183f06a0..5dbb142e520f2 100644 --- a/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs +++ b/components/xero_accounting_api/actions/list-credit-notes/list-credit-notes.mjs @@ -44,7 +44,7 @@ export default { const response = await this.xeroAccountingApi.listCreditNotes({ $, tenantId: this.tenantId, - modifiedAfter: this.modifiedAfter, + modifiedSince: this.modifiedAfter, params: { Where: this.where, order: this.order, diff --git a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs index 5505255ff9464..c6d90cd77f84d 100644 --- a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs +++ b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs @@ -74,7 +74,7 @@ export default { const response = await this.xeroAccountingApi.listInvoices({ $, tenantId: this.tenantId, - modifiedAfter: this.modifiedAfter, + modifiedSince: this.modifiedSince, params: { IDs: this.ids, InvoiceNumbers: this.invoiceNumbers, diff --git a/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs b/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs index 4c8c112abb5c7..3d4e5cca8c493 100644 --- a/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs +++ b/components/xero_accounting_api/actions/list-manual-journals/list-manual-journals.mjs @@ -44,7 +44,7 @@ export default { const response = await this.xeroAccountingApi.listManualJournals({ $, tenantId: this.tenantId, - modifiedAfter: this.modifiedAfter, + modifiedSince: this.modifiedAfter, params: { Where: this.where, order: this.order, diff --git a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs index 4519cd0350d65..03a57899c0768 100644 --- a/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs +++ b/components/xero_accounting_api/actions/make-an-api-call/make-an-api-call.mjs @@ -56,6 +56,7 @@ export default { method: this.requestMethod, path: this.relativeUrl, params: this.queryString, + tenantId: this.tenantId, data: parseObject(this.requestBody), }); diff --git a/components/xero_accounting_api/xero_accounting_api.app.mjs b/components/xero_accounting_api/xero_accounting_api.app.mjs index 518cead2d0bd4..a6e1dc32c1c9f 100644 --- a/components/xero_accounting_api/xero_accounting_api.app.mjs +++ b/components/xero_accounting_api/xero_accounting_api.app.mjs @@ -344,19 +344,15 @@ export default { ...opts, }); }, - listInvoices({ - invoiceIdentifier, ...opts - }) { + listInvoices(opts = {}) { return this._makeRequest({ - path: `/Invoices/${invoiceIdentifier}`, + path: "/Invoices", ...opts, }); }, - listManualJournals({ - manualJournalId, ...opts - }) { + listManualJournals(opts = {}) { return this._makeRequest({ - path: `/ManualJournals/${manualJournalId}`, + path: "/ManualJournals", ...opts, }); }, From cda4b71c3fec39444382117afe10268630fb8ac7 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 20 Aug 2025 10:11:19 -0300 Subject: [PATCH 9/9] Update components/xero_accounting_api/actions/list-invoices/list-invoices.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../xero_accounting_api/actions/list-invoices/list-invoices.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs index c6d90cd77f84d..ba66202347c7b 100644 --- a/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs +++ b/components/xero_accounting_api/actions/list-invoices/list-invoices.mjs @@ -74,7 +74,7 @@ export default { const response = await this.xeroAccountingApi.listInvoices({ $, tenantId: this.tenantId, - modifiedSince: this.modifiedSince, + modifiedSince: this.modifiedAfter, params: { IDs: this.ids, InvoiceNumbers: this.invoiceNumbers,