Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
33 changes: 33 additions & 0 deletions components/sevdesk/actions/get-invoice/get-invoice.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
122 changes: 122 additions & 0 deletions components/sevdesk/actions/get-invoices/get-invoices.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/sevdesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/sevdesk",
"version": "0.2.0",
"version": "0.3.0",
"description": "Pipedream sevDesk Components",
"main": "sevdesk.app.mjs",
"keywords": [
Expand Down
8 changes: 8 additions & 0 deletions components/sevdesk/sevdesk.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ export default {
...opts,
});
},
getInvoice({
invoiceId, ...opts
}) {
return this._makeRequest({
path: `/Invoice/${invoiceId}`,
...opts,
});
},
listOrders(opts = {}) {
return this._makeRequest({
path: "/Order",
Expand Down
2 changes: 1 addition & 1 deletion components/sevdesk/sources/new-contact/new-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion components/sevdesk/sources/new-order/new-order.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion components/sevdesk/sources/new-voucher/new-voucher.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 2 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading