diff --git a/components/sevdesk/actions/cancel-invoice/cancel-invoice.mjs b/components/sevdesk/actions/cancel-invoice/cancel-invoice.mjs index d3d4274848c44..b6bbd3d04c382 100644 --- a/components/sevdesk/actions/cancel-invoice/cancel-invoice.mjs +++ b/components/sevdesk/actions/cancel-invoice/cancel-invoice.mjs @@ -5,7 +5,7 @@ export default { key: "sevdesk-cancel-invoice", name: "Cancel Invoice", description: "Cancels an existing invoice in sevDesk. [See the documentation](https://api.sevdesk.de/#tag/Invoice/operation/cancelInvoice)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { sevdesk, diff --git a/components/sevdesk/actions/create-contact/create-contact.mjs b/components/sevdesk/actions/create-contact/create-contact.mjs index 4d77364a663de..d940ea5ae962a 100644 --- a/components/sevdesk/actions/create-contact/create-contact.mjs +++ b/components/sevdesk/actions/create-contact/create-contact.mjs @@ -5,7 +5,7 @@ export default { key: "sevdesk-create-contact", name: "Create Contact", description: "Create a new contact. [See the documentation](https://api.sevdesk.de/#tag/Contact/operation/createContact)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { sevdesk, diff --git a/components/sevdesk/actions/create-invoice/create-invoice.mjs b/components/sevdesk/actions/create-invoice/create-invoice.mjs index c99a0aeaf6605..d518b61953971 100644 --- a/components/sevdesk/actions/create-invoice/create-invoice.mjs +++ b/components/sevdesk/actions/create-invoice/create-invoice.mjs @@ -12,7 +12,7 @@ export default { key: "sevdesk-create-invoice", name: "Create Invoice", description: "Creates a new invoice with optional details like invoice date, due date, discount amount, and invoice items. [See the documentation](https://api.sevdesk.de/)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { sevdesk, diff --git a/components/sevdesk/actions/get-invoice/get-invoice.mjs b/components/sevdesk/actions/get-invoice/get-invoice.mjs new file mode 100644 index 0000000000000..c3fef49bf8b2f --- /dev/null +++ b/components/sevdesk/actions/get-invoice/get-invoice.mjs @@ -0,0 +1,33 @@ +import app from "../../sevdesk.app.mjs"; + +export default { + key: "sevdesk-get-invoice", + name: "Get Invoice", + description: "Find and retrieve a single invoice by its ID. [See the documentation](https://api.sevdesk.de/#tag/Invoice/operation/getInvoiceById)", + version: "0.0.1", + type: "action", + props: { + app, + invoiceId: { + propDefinition: [ + app, + "invoiceId", + ], + description: "ID of the invoice to retrieve", + }, + }, + async run({ $ }) { + const { + app, + invoiceId, + } = this; + + const response = await app.getInvoice({ + $, + invoiceId, + }); + + $.export("$summary", `Successfully retrieved invoice with ID ${invoiceId}`); + return response; + }, +}; diff --git a/components/sevdesk/actions/get-invoices/get-invoices.mjs b/components/sevdesk/actions/get-invoices/get-invoices.mjs new file mode 100644 index 0000000000000..3d0c67b220dfe --- /dev/null +++ b/components/sevdesk/actions/get-invoices/get-invoices.mjs @@ -0,0 +1,122 @@ +import app from "../../sevdesk.app.mjs"; + +export default { + key: "sevdesk-get-invoices", + name: "Get Invoices", + description: "Retrieve invoices with optional filtering by status, invoice number, date range, and contact. [See the documentation](https://api.sevdesk.de/#tag/Invoice/operation/getInvoices)", + version: "0.0.1", + type: "action", + props: { + app, + status: { + type: "string", + label: "Status", + description: "Status of the invoices to filter by", + options: [ + { + label: "Draft", + value: "100", + }, + { + label: "Open", + value: "200", + }, + { + label: "Paid", + value: "1000", + }, + ], + optional: true, + }, + invoiceNumber: { + type: "string", + label: "Invoice Number", + description: "Retrieve all invoices with this invoice number", + optional: true, + }, + startDate: { + type: "string", + label: "Start Date", + description: "Retrieve all invoices with a date equal or higher (ISO 8601 format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS)", + optional: true, + }, + endDate: { + type: "string", + label: "End Date", + description: "Retrieve all invoices with a date equal or lower (ISO 8601 format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS)", + optional: true, + }, + contactId: { + propDefinition: [ + app, + "contactId", + ], + optional: true, + }, + limit: { + type: "integer", + label: "Limit", + description: "Maximum number of invoices to retrieve", + optional: true, + min: 1, + max: 999, + }, + }, + methods: { + convertDateToTimestamp(dateString) { + if (!dateString) return undefined; + + const date = new Date(dateString); + if (isNaN(date.getTime())) { + throw new Error(`Invalid date format: ${dateString}. Please use ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS)`); + } + + return Math.floor(date.getTime() / 1000); + }, + }, + async run({ $ }) { + const { + app, + status, + invoiceNumber, + startDate, + endDate, + contactId, + limit, + } = this; + + let startTimestamp, endTimestamp; + + try { + startTimestamp = this.convertDateToTimestamp(startDate); + endTimestamp = this.convertDateToTimestamp(endDate); + } catch (error) { + throw new Error(`Date validation error: ${error.message}`); + } + + if (startTimestamp && endTimestamp && startTimestamp > endTimestamp) { + throw new Error("Start date cannot be later than end date"); + } + + const response = await app.listInvoices({ + $, + params: { + status, + invoiceNumber, + startDate: startTimestamp, + endDate: endTimestamp, + ...(contactId + ? { + "contact[id]": contactId, + "contact[objectName]": "Contact", + } + : {} + ), + limit, + }, + }); + + $.export("$summary", `Successfully retrieved ${response.objects?.length || 0} invoice(s)`); + return response; + }, +}; diff --git a/components/sevdesk/actions/send-invoice-email/send-invoice-email.mjs b/components/sevdesk/actions/send-invoice-email/send-invoice-email.mjs index aac5740699e7b..ea3b05198057b 100644 --- a/components/sevdesk/actions/send-invoice-email/send-invoice-email.mjs +++ b/components/sevdesk/actions/send-invoice-email/send-invoice-email.mjs @@ -5,7 +5,7 @@ export default { key: "sevdesk-send-invoice-email", name: "Send Invoice Email", description: "Sends an invoice via email. [See the documentation](https://api.sevdesk.de/#tag/Invoice/operation/sendInvoiceViaEMail)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { sevdesk, diff --git a/components/sevdesk/package.json b/components/sevdesk/package.json index 212e696c08bd7..a7de594c3d951 100644 --- a/components/sevdesk/package.json +++ b/components/sevdesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/sevdesk", - "version": "0.2.0", + "version": "0.3.0", "description": "Pipedream sevDesk Components", "main": "sevdesk.app.mjs", "keywords": [ diff --git a/components/sevdesk/sevdesk.app.mjs b/components/sevdesk/sevdesk.app.mjs index c9baddfbd81b6..647cd8ea2078f 100644 --- a/components/sevdesk/sevdesk.app.mjs +++ b/components/sevdesk/sevdesk.app.mjs @@ -159,6 +159,14 @@ export default { ...opts, }); }, + getInvoice({ + invoiceId, ...opts + }) { + return this._makeRequest({ + path: `/Invoice/${invoiceId}`, + ...opts, + }); + }, listOrders(opts = {}) { return this._makeRequest({ path: "/Order", diff --git a/components/sevdesk/sources/new-contact/new-contact.mjs b/components/sevdesk/sources/new-contact/new-contact.mjs index 008f096e2182b..cf7f377a84e5f 100644 --- a/components/sevdesk/sources/new-contact/new-contact.mjs +++ b/components/sevdesk/sources/new-contact/new-contact.mjs @@ -6,7 +6,7 @@ export default { key: "sevdesk-new-contact", name: "New Contact Created", description: "Emit new event when a contact is created in SevDesk.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/sevdesk/sources/new-order/new-order.mjs b/components/sevdesk/sources/new-order/new-order.mjs index 807642091a2a9..2e264efc0fdd3 100644 --- a/components/sevdesk/sources/new-order/new-order.mjs +++ b/components/sevdesk/sources/new-order/new-order.mjs @@ -6,7 +6,7 @@ export default { key: "sevdesk-new-order", name: "New Order Created", description: "Emit new event for each new order created in SevDesk.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/sevdesk/sources/new-voucher/new-voucher.mjs b/components/sevdesk/sources/new-voucher/new-voucher.mjs index 7ab25eff809bd..72a9252adf901 100644 --- a/components/sevdesk/sources/new-voucher/new-voucher.mjs +++ b/components/sevdesk/sources/new-voucher/new-voucher.mjs @@ -6,7 +6,7 @@ export default { key: "sevdesk-new-voucher", name: "New Voucher Created", description: "Emit new event when a new voucher is created.", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0fbeef452bcc7..54510d7fd539c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6384,8 +6384,7 @@ importers: specifier: ^1.11.7 version: 1.11.13 - components/hospitable: - specifiers: {} + components/hospitable: {} components/hostaway: dependencies: @@ -6893,8 +6892,7 @@ importers: components/invoicing_plus: {} - components/ionos_hosting_services: - specifiers: {} + components/ionos_hosting_services: {} components/ip2location: dependencies: @@ -37340,8 +37338,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: