From d5b79f17061f9f4f1e326b51b2098a40f11c5414 Mon Sep 17 00:00:00 2001 From: Jorge Cortes Date: Fri, 5 Dec 2025 11:47:29 -0500 Subject: [PATCH] [ACTIONS] picqer - new components --- .../add-order-comment/add-order-comment.mjs | 2 +- .../actions/add-order-tags/add-order-tags.mjs | 41 ++++++ .../add-product-to-order.mjs | 74 +++++++++++ .../add-return-comment/add-return-comment.mjs | 2 +- .../actions/cancel-order/cancel-order.mjs | 48 +++++++ .../change-order-to-concept.mjs | 37 ++++++ .../actions/create-order/create-order.mjs | 2 +- .../actions/get-customer/get-customer.mjs | 2 +- .../get-order-comments/get-order-comments.mjs | 32 +++++ .../actions/get-order-tags/get-order-tags.mjs | 32 +++++ .../picqer/actions/get-order/get-order.mjs | 2 +- .../actions/get-picklist/get-picklist.mjs | 2 +- .../get-status-per-order-line.mjs | 2 +- .../actions/pause-order/pause-order.mjs | 40 ++++++ .../actions/process-order/process-order.mjs | 32 +++++ .../actions/search-orders/search-orders.mjs | 2 +- .../actions/update-order/update-order.mjs | 2 +- components/picqer/package.json | 2 +- components/picqer/picqer.app.mjs | 123 +++++++++++++++++- .../new-event-instant/new-event-instant.mjs | 2 +- 20 files changed, 469 insertions(+), 12 deletions(-) create mode 100644 components/picqer/actions/add-order-tags/add-order-tags.mjs create mode 100644 components/picqer/actions/add-product-to-order/add-product-to-order.mjs create mode 100644 components/picqer/actions/cancel-order/cancel-order.mjs create mode 100644 components/picqer/actions/change-order-to-concept/change-order-to-concept.mjs create mode 100644 components/picqer/actions/get-order-comments/get-order-comments.mjs create mode 100644 components/picqer/actions/get-order-tags/get-order-tags.mjs create mode 100644 components/picqer/actions/pause-order/pause-order.mjs create mode 100644 components/picqer/actions/process-order/process-order.mjs diff --git a/components/picqer/actions/add-order-comment/add-order-comment.mjs b/components/picqer/actions/add-order-comment/add-order-comment.mjs index ad239361092be..2c31c17dba5b7 100644 --- a/components/picqer/actions/add-order-comment/add-order-comment.mjs +++ b/components/picqer/actions/add-order-comment/add-order-comment.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-add-order-comment", name: "Add Comment To Order", description: "Add a comment to an order in Picqer. [See the documentation](https://picqer.com/en/api/comments#adding-comments-to-an-order)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/add-order-tags/add-order-tags.mjs b/components/picqer/actions/add-order-tags/add-order-tags.mjs new file mode 100644 index 0000000000000..320d1b3688c3c --- /dev/null +++ b/components/picqer/actions/add-order-tags/add-order-tags.mjs @@ -0,0 +1,41 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-add-order-tags", + name: "Add Order Tags", + description: "Associates a tag with an order. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + tagId: { + propDefinition: [ + app, + "tagId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.addOrderTags({ + $, + orderId: this.orderId, + data: { + idtag: this.tagId, + }, + }); + + $.export("$summary", `Successfully added tag to order ${this.orderId}`); + return response; + }, +}; diff --git a/components/picqer/actions/add-product-to-order/add-product-to-order.mjs b/components/picqer/actions/add-product-to-order/add-product-to-order.mjs new file mode 100644 index 0000000000000..0dae8f9e0a86a --- /dev/null +++ b/components/picqer/actions/add-product-to-order/add-product-to-order.mjs @@ -0,0 +1,74 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-add-product-to-order", + name: "Add Product To Order", + description: "Adds a single product to concept orders only. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + () => ({ + params: { + status: "concept", + }, + }), + ], + }, + productId: { + propDefinition: [ + app, + "productId", + ], + }, + amount: { + type: "integer", + label: "Amount", + description: "The quantity of the product to add", + default: 1, + }, + price: { + type: "string", + label: "Price", + description: "The price of the product", + optional: true, + }, + name: { + type: "string", + label: "Name", + description: "The name of the product", + optional: true, + }, + remarks: { + type: "string", + label: "Remarks", + description: "Remarks for the product", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.app.addProductToOrder({ + $, + orderId: this.orderId, + data: { + idproduct: this.productId, + amount: this.amount, + price: this.price, + name: this.name, + remarks: this.remarks, + }, + }); + + $.export("$summary", `Successfully added product to order ${this.orderId}`); + return response; + }, +}; diff --git a/components/picqer/actions/add-return-comment/add-return-comment.mjs b/components/picqer/actions/add-return-comment/add-return-comment.mjs index a7bdea45b7cd3..8451af026b089 100644 --- a/components/picqer/actions/add-return-comment/add-return-comment.mjs +++ b/components/picqer/actions/add-return-comment/add-return-comment.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-add-return-comment", name: "Add Comment To Return", description: "Add a comment to a return in Picqer. [See the documentation](https://picqer.com/en/api/comments#add-a-comment-to-an-return)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/cancel-order/cancel-order.mjs b/components/picqer/actions/cancel-order/cancel-order.mjs new file mode 100644 index 0000000000000..b39597bb2a3f0 --- /dev/null +++ b/components/picqer/actions/cancel-order/cancel-order.mjs @@ -0,0 +1,48 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-cancel-order", + name: "Cancel Order", + description: "Removes orders with 'concept' or 'expected' status only. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + force: { + type: "boolean", + label: "Force Cancel", + description: "If enabled, cancels orders regardless of status, removing attached picklists even if picked", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + orderId, + force, + } = this; + + await app.cancelOrder({ + $, + orderId, + params: { + force, + }, + }); + $.export("$summary", "Successfully canceled order"); + return { + success: true, + }; + }, +}; diff --git a/components/picqer/actions/change-order-to-concept/change-order-to-concept.mjs b/components/picqer/actions/change-order-to-concept/change-order-to-concept.mjs new file mode 100644 index 0000000000000..5950f550f5f25 --- /dev/null +++ b/components/picqer/actions/change-order-to-concept/change-order-to-concept.mjs @@ -0,0 +1,37 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-change-order-to-concept", + name: "Change Order To Concept", + description: "Converts expected orders back to concept status for editing. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + () => ({ + params: { + status: "expected", + }, + }), + ], + }, + }, + async run({ $ }) { + const response = await this.app.changeOrderToConcept({ + $, + orderId: this.orderId, + }); + + $.export("$summary", `Successfully changed order ${this.orderId} to concept status`); + return response; + }, +}; diff --git a/components/picqer/actions/create-order/create-order.mjs b/components/picqer/actions/create-order/create-order.mjs index 40a46f90ba442..b5e73debb68d5 100644 --- a/components/picqer/actions/create-order/create-order.mjs +++ b/components/picqer/actions/create-order/create-order.mjs @@ -7,7 +7,7 @@ export default { key: "picqer-create-order", name: "Create Picqer Order", description: "Create a new order in Picqer. [See the documentation](https://picqer.com/en/api/orders)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/get-customer/get-customer.mjs b/components/picqer/actions/get-customer/get-customer.mjs index bc130c5674eea..947a96c2a9b2b 100644 --- a/components/picqer/actions/get-customer/get-customer.mjs +++ b/components/picqer/actions/get-customer/get-customer.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-get-customer", name: "Get Customer", description: "Get a customer in Picqer. [See the documentation](https://picqer.com/en/api/customers#get-single-customer)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/get-order-comments/get-order-comments.mjs b/components/picqer/actions/get-order-comments/get-order-comments.mjs new file mode 100644 index 0000000000000..8fcd921127d00 --- /dev/null +++ b/components/picqer/actions/get-order-comments/get-order-comments.mjs @@ -0,0 +1,32 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-get-order-comments", + name: "Get Order Comments", + description: "Retrieves comments linked to an order. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getOrderComments({ + $, + orderId: this.orderId, + }); + + $.export("$summary", `Successfully retrieved ${response.length} comment(s) for order ${this.orderId}`); + return response; + }, +}; diff --git a/components/picqer/actions/get-order-tags/get-order-tags.mjs b/components/picqer/actions/get-order-tags/get-order-tags.mjs new file mode 100644 index 0000000000000..4e7f7fd58241a --- /dev/null +++ b/components/picqer/actions/get-order-tags/get-order-tags.mjs @@ -0,0 +1,32 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-get-order-tags", + name: "Get Order Tags", + description: "Retrieves all tags associated with an order. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getOrderTags({ + $, + orderId: this.orderId, + }); + + $.export("$summary", `Successfully retrieved ${response.length} tag(s) for order ${this.orderId}`); + return response; + }, +}; diff --git a/components/picqer/actions/get-order/get-order.mjs b/components/picqer/actions/get-order/get-order.mjs index c727725079b18..97375092345db 100644 --- a/components/picqer/actions/get-order/get-order.mjs +++ b/components/picqer/actions/get-order/get-order.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-get-order", name: "Get Picqer Order", description: "Get an order in Picqer. [See the documentation](https://picqer.com/en/api/orders#get-single-order)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/get-picklist/get-picklist.mjs b/components/picqer/actions/get-picklist/get-picklist.mjs index 65c3247665a0a..9b894ddd56481 100644 --- a/components/picqer/actions/get-picklist/get-picklist.mjs +++ b/components/picqer/actions/get-picklist/get-picklist.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-get-picklist", name: "Get Picklist", description: "Get a picklist in Picqer. [See the documentation](https://picqer.com/en/api/picklists#h-get-single-picklist)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/get-status-per-order-line/get-status-per-order-line.mjs b/components/picqer/actions/get-status-per-order-line/get-status-per-order-line.mjs index 1144149bb2ecd..8c8ccc3ce28f3 100644 --- a/components/picqer/actions/get-status-per-order-line/get-status-per-order-line.mjs +++ b/components/picqer/actions/get-status-per-order-line/get-status-per-order-line.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-get-status-per-order-line", name: "Get Status Per Order Line", description: "Get the status per order line in Picqer. [See the documentation](https://picqer.com/en/api/orders#get-status-per-order-line)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/pause-order/pause-order.mjs b/components/picqer/actions/pause-order/pause-order.mjs new file mode 100644 index 0000000000000..b8f38f1a8ccf9 --- /dev/null +++ b/components/picqer/actions/pause-order/pause-order.mjs @@ -0,0 +1,40 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-pause-order", + name: "Pause Order", + description: "Suspends processing of orders with 'processing' status. Pauses underlying picklists. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + reason: { + type: "string", + label: "Reason", + description: "A reason for pausing the order", + }, + }, + async run({ $ }) { + const response = await this.app.pauseOrder({ + $, + orderId: this.orderId, + data: { + reason: this.reason, + }, + }); + + $.export("$summary", `Successfully paused order ${this.orderId}`); + return response; + }, +}; diff --git a/components/picqer/actions/process-order/process-order.mjs b/components/picqer/actions/process-order/process-order.mjs new file mode 100644 index 0000000000000..3766437bb5912 --- /dev/null +++ b/components/picqer/actions/process-order/process-order.mjs @@ -0,0 +1,32 @@ +import app from "../../picqer.app.mjs"; + +export default { + key: "picqer-process-order", + name: "Process Order", + description: "Finalizes a concept or expected order and creates picklists or backorders automatically. Note: The processing itself will take place in the background after you receive the response. [See the documentation](https://picqer.com/en/api/orders)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.processOrder({ + $, + orderId: this.orderId, + }); + + $.export("$summary", `Successfully initiated processing for order ${this.orderId}`); + return response; + }, +}; diff --git a/components/picqer/actions/search-orders/search-orders.mjs b/components/picqer/actions/search-orders/search-orders.mjs index e40edd7e7196e..f8eb6c24aaafb 100644 --- a/components/picqer/actions/search-orders/search-orders.mjs +++ b/components/picqer/actions/search-orders/search-orders.mjs @@ -5,7 +5,7 @@ export default { key: "picqer-search-orders", name: "Search Picqer Orders", description: "Search for orders in Picqer. [See the documentation](https://picqer.com/en/api/orders#get-all-orders)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/picqer/actions/update-order/update-order.mjs b/components/picqer/actions/update-order/update-order.mjs index 8df2294706d33..f4b7356a3662e 100644 --- a/components/picqer/actions/update-order/update-order.mjs +++ b/components/picqer/actions/update-order/update-order.mjs @@ -4,7 +4,7 @@ export default { key: "picqer-update-order", name: "Update Picqer Order", description: "Update an order in Picqer. [See the documentation](https://picqer.com/en/api/orders#update)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/picqer/package.json b/components/picqer/package.json index 979add688e26d..f1f3a9dfa6e93 100644 --- a/components/picqer/package.json +++ b/components/picqer/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/picqer", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Picqer Components", "main": "picqer.app.mjs", "keywords": [ diff --git a/components/picqer/picqer.app.mjs b/components/picqer/picqer.app.mjs index 8193ece2eae68..10070d9e33f67 100644 --- a/components/picqer/picqer.app.mjs +++ b/components/picqer/picqer.app.mjs @@ -12,10 +12,13 @@ export default { type: "string", label: "Order ID", description: "The order id for searching orders.", - async options({ page }) { + async options({ + page, params, + }) { const data = await this.searchOrders({ params: { offset: page * LIMIT, + ...params, }, }); @@ -297,6 +300,42 @@ export default { label: "Visible In Fulfillment", description: "Only for Picqer Fulfilment: Whether the comment is visible for the fulfilment customer the resource belongs to.", }, + tagId: { + type: "string", + label: "Tag ID", + description: "The tag to associate with the order", + async options({ page }) { + const data = await this.listTags({ + params: { + offset: page * LIMIT, + }, + }); + return data.map(({ + idtag: value, title: label, + }) => ({ + label, + value, + })); + }, + }, + productId: { + type: "string", + label: "Product ID", + description: "The product to add to the order", + async options({ page }) { + const data = await this.listProducts({ + params: { + offset: page * LIMIT, + }, + }); + return data.map(({ + idproduct: value, productcode, name, + }) => ({ + label: `${productcode} - ${name}`, + value, + })); + }, + }, }, methods: { _baseUrl() { @@ -450,5 +489,87 @@ export default { path: `/hooks/${hookId}`, }); }, + processOrder({ + orderId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/orders/${orderId}/process`, + ...opts, + }); + }, + pauseOrder({ + orderId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/orders/${orderId}/pause`, + ...opts, + }); + }, + changeOrderToConcept({ + orderId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/orders/${orderId}/change-to-concept`, + ...opts, + }); + }, + cancelOrder({ + orderId, ...opts + }) { + return this._makeRequest({ + method: "DELETE", + path: `/orders/${orderId}`, + ...opts, + }); + }, + getOrderTags({ + orderId, ...opts + }) { + return this._makeRequest({ + path: `/orders/${orderId}/tags`, + ...opts, + }); + }, + addOrderTags({ + orderId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/orders/${orderId}/tags`, + ...opts, + }); + }, + addProductToOrder({ + orderId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/orders/${orderId}/products`, + ...opts, + }); + }, + getOrderComments({ + orderId, ...opts + }) { + return this._makeRequest({ + path: `/orders/${orderId}/comments`, + ...opts, + }); + }, + listTags(opts = {}) { + return this._makeRequest({ + path: "/tags", + ...opts, + }); + }, + listProducts(opts = {}) { + return this._makeRequest({ + path: "/products", + ...opts, + }); + }, }, }; diff --git a/components/picqer/sources/new-event-instant/new-event-instant.mjs b/components/picqer/sources/new-event-instant/new-event-instant.mjs index 5a9c2e5b54b39..5a5b89a9f72c4 100644 --- a/components/picqer/sources/new-event-instant/new-event-instant.mjs +++ b/components/picqer/sources/new-event-instant/new-event-instant.mjs @@ -7,7 +7,7 @@ export default { key: "picqer-new-event-instant", name: "New Event Instant", description: "Emit new event when Picqer sends a webhook matched with selected event. [See the documentation](https://picqer.com/en/api/webhooks)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: {