diff --git a/components/returnless/actions/create-return-order/create-return-order.mjs b/components/returnless/actions/create-return-order/create-return-order.mjs index 56573bca31e11..79357f690a4b3 100644 --- a/components/returnless/actions/create-return-order/create-return-order.mjs +++ b/components/returnless/actions/create-return-order/create-return-order.mjs @@ -6,7 +6,7 @@ export default { key: "returnless-create-return-order", name: "Create Return Order", description: "Create a return order. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/1fce50b07484b-creates-a-return-order-from-a-return-order-intent)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/returnless/actions/list-return-orders/list-return-orders.mjs b/components/returnless/actions/list-return-orders/list-return-orders.mjs index dac1384340a71..52751db4e55fa 100644 --- a/components/returnless/actions/list-return-orders/list-return-orders.mjs +++ b/components/returnless/actions/list-return-orders/list-return-orders.mjs @@ -4,7 +4,7 @@ export default { key: "returnless-list-return-orders", name: "List Return Orders", description: "Retrieve a list of return orders. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/0640e3c064cdc-list-all-return-orders)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/returnless/actions/list-return-statuses/list-return-statuses.mjs b/components/returnless/actions/list-return-statuses/list-return-statuses.mjs new file mode 100644 index 0000000000000..796c60cbd435c --- /dev/null +++ b/components/returnless/actions/list-return-statuses/list-return-statuses.mjs @@ -0,0 +1,32 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-list-return-statuses", + name: "List Return Statuses", + description: "List all return statuses. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/6129c8f41f66f-list-all-return-statuses)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + const resources = await this.app.listReturnStatuses({ + $, + }); + + $.export("$summary", `Successfully retrieved ${resources.length} return status(es)`); + return resources.data; + }, +}; diff --git a/components/returnless/actions/list-sales-order-items/list-sales-order-items.mjs b/components/returnless/actions/list-sales-order-items/list-sales-order-items.mjs index 851d4d761fe6d..79ff293c6c637 100644 --- a/components/returnless/actions/list-sales-order-items/list-sales-order-items.mjs +++ b/components/returnless/actions/list-sales-order-items/list-sales-order-items.mjs @@ -4,7 +4,7 @@ export default { key: "returnless-list-sales-order-items", name: "List Sales Order Items", description: "Retrieve all items from a specific sales order with cursor-based pagination support. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/6b3c26dad0434-list-all-items-of-a-sales-order)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/returnless/actions/list-sales-orders/list-sales-orders.mjs b/components/returnless/actions/list-sales-orders/list-sales-orders.mjs index 6925976432a00..4907a0c8f913b 100644 --- a/components/returnless/actions/list-sales-orders/list-sales-orders.mjs +++ b/components/returnless/actions/list-sales-orders/list-sales-orders.mjs @@ -4,7 +4,7 @@ export default { key: "returnless-list-sales-orders", name: "List Sales Orders", description: "Retrieve a list of sales orders sorted by creation date, with the most recent sales orders appearing first. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/ce6a0e3d66378-list-all-sales-orders)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/returnless/actions/list-shipments-of-return-order/list-shipments-of-return-order.mjs b/components/returnless/actions/list-shipments-of-return-order/list-shipments-of-return-order.mjs new file mode 100644 index 0000000000000..882976395efb4 --- /dev/null +++ b/components/returnless/actions/list-shipments-of-return-order/list-shipments-of-return-order.mjs @@ -0,0 +1,42 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-list-shipments-of-return-order", + name: "List Shipments of Return Order", + description: "List all shipments of a return order. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/1e0748fdd876f-list-all-shipments-of-a-return-order)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + returnOrderId: { + propDefinition: [ + app, + "returnOrderId", + ], + }, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + const resources = await this.app.getPaginatedResources({ + fn: this.app.listReturnOrderShipments, + args: { + returnOrderId: this.returnOrderId, + }, + max: this.maxResults, + }); + + $.export("$summary", `Successfully retrieved ${resources.length} shipment(s) for return order ${this.returnOrderId}`); + return resources; + }, +}; diff --git a/components/returnless/actions/list-shipments/list-shipments.mjs b/components/returnless/actions/list-shipments/list-shipments.mjs new file mode 100644 index 0000000000000..f4eeb7fe285d9 --- /dev/null +++ b/components/returnless/actions/list-shipments/list-shipments.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-list-shipments", + name: "List Shipments", + description: "List all shipments. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/7daf3fa2c9bf9-list-all-shipments)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + const resources = await this.app.getPaginatedResources({ + fn: this.app.listShipments, + max: this.maxResults, + }); + + $.export("$summary", `Successfully retrieved ${resources.length} shipment(s)`); + return resources; + }, +}; diff --git a/components/returnless/actions/list-statuses-of-shipment/list-statuses-of-shipment.mjs b/components/returnless/actions/list-statuses-of-shipment/list-statuses-of-shipment.mjs new file mode 100644 index 0000000000000..0dde80d8db8d7 --- /dev/null +++ b/components/returnless/actions/list-statuses-of-shipment/list-statuses-of-shipment.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-list-statuses-of-shipment", + name: "List Statuses of Shipment", + description: "List all statuses of a shipment. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/e274dab430bb7-list-all-statuses-of-a-shipment)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + shipmentId: { + propDefinition: [ + app, + "shipmentId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.app.listShipmentStatuses({ + $, + shipmentId: this.shipmentId, + }); + + $.export("$summary", `Successfully retrieved ${data.length} status(es) for shipment ${this.shipmentId}`); + return data; + }, +}; diff --git a/components/returnless/actions/retrieve-return-address/retrieve-return-address.mjs b/components/returnless/actions/retrieve-return-address/retrieve-return-address.mjs new file mode 100644 index 0000000000000..4f1ed647c46d3 --- /dev/null +++ b/components/returnless/actions/retrieve-return-address/retrieve-return-address.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-retrieve-return-address", + name: "Retrieve Return Address", + description: "Retrieve a return address. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/b702161eed54f-retrieve-a-return-address)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + returnAddressId: { + propDefinition: [ + app, + "returnAddressId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.app.getReturnAddress({ + $, + returnAddressId: this.returnAddressId, + }); + + $.export("$summary", `Successfully retrieved return address ${this.returnAddressId}`); + return data; + }, +}; diff --git a/components/returnless/actions/retrieve-return-order/retrieve-return-order.mjs b/components/returnless/actions/retrieve-return-order/retrieve-return-order.mjs new file mode 100644 index 0000000000000..2a1d4cfb62b98 --- /dev/null +++ b/components/returnless/actions/retrieve-return-order/retrieve-return-order.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-retrieve-return-order", + name: "Retrieve Return Order", + description: "Retrieve a return order. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/f670282943eae-retrieve-a-return-order)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + returnOrderId: { + propDefinition: [ + app, + "returnOrderId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.app.getReturnOrder({ + $, + returnOrderId: this.returnOrderId, + }); + + $.export("$summary", `Successfully retrieved return order ${this.returnOrderId}`); + return data; + }, +}; diff --git a/components/returnless/actions/retrieve-return-status/retrieve-return-status.mjs b/components/returnless/actions/retrieve-return-status/retrieve-return-status.mjs new file mode 100644 index 0000000000000..2d359951b6203 --- /dev/null +++ b/components/returnless/actions/retrieve-return-status/retrieve-return-status.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-retrieve-return-status", + name: "Retrieve Return Status", + description: "Retrieve a return status. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/ba30f75e2c5fd-retrieve-a-return-status)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + returnStatusId: { + propDefinition: [ + app, + "returnStatusId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.app.getReturnStatus({ + $, + returnStatusId: this.returnStatusId, + }); + + $.export("$summary", `Successfully retrieved return status ${this.returnStatusId}`); + return data; + }, +}; diff --git a/components/returnless/actions/retrieve-sales-order/retrieve-sales-order.mjs b/components/returnless/actions/retrieve-sales-order/retrieve-sales-order.mjs new file mode 100644 index 0000000000000..df6627a1c7256 --- /dev/null +++ b/components/returnless/actions/retrieve-sales-order/retrieve-sales-order.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-retrieve-sales-order", + name: "Retrieve Sales Order", + description: "Retrieve a sales order. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/4a6a8fe812c44-retrieve-a-sales-order)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + orderId: { + propDefinition: [ + app, + "orderId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.app.getOrder({ + $, + orderId: this.orderId, + }); + + $.export("$summary", `Successfully retrieved sales order ${this.orderId}`); + return data; + }, +}; diff --git a/components/returnless/actions/retrieve-shipment/retrieve-shipment.mjs b/components/returnless/actions/retrieve-shipment/retrieve-shipment.mjs new file mode 100644 index 0000000000000..b482f2ca56b79 --- /dev/null +++ b/components/returnless/actions/retrieve-shipment/retrieve-shipment.mjs @@ -0,0 +1,33 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-retrieve-shipment", + name: "Retrieve Shipment", + description: "Retrieve a shipment. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/8add0ab769032-retrieve-a-shipment)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + idempotentHint: true, + }, + type: "action", + props: { + app, + shipmentId: { + propDefinition: [ + app, + "shipmentId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.app.getShipment({ + $, + shipmentId: this.shipmentId, + }); + + $.export("$summary", `Successfully retrieved shipment ${this.shipmentId}`); + return data; + }, +}; diff --git a/components/returnless/actions/update-return-address/update-return-address.mjs b/components/returnless/actions/update-return-address/update-return-address.mjs new file mode 100644 index 0000000000000..a8a9a853cfcfb --- /dev/null +++ b/components/returnless/actions/update-return-address/update-return-address.mjs @@ -0,0 +1,103 @@ +import app from "../../returnless.app.mjs"; + +export default { + key: "returnless-update-return-address", + name: "Update Return Address", + description: "Update a return address. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/bdf8070b84150-update-a-return-address)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + idempotentHint: false, + }, + type: "action", + props: { + app, + returnAddressId: { + propDefinition: [ + app, + "returnAddressId", + ], + }, + name: { + type: "string", + label: "Name", + description: "The name of the return address", + optional: true, + }, + companyName: { + type: "string", + label: "Company Name", + description: "The company name of the return address", + optional: true, + }, + street: { + type: "string", + label: "Street", + description: "The street of the return address", + optional: true, + }, + houseNumber: { + type: "string", + label: "House Number", + description: "The house number of the return address", + optional: true, + }, + postalCode: { + type: "string", + label: "Postal Code", + description: "The postal code of the return address", + optional: true, + }, + city: { + type: "string", + label: "City", + description: "The city of the return address", + optional: true, + }, + latitude: { + type: "string", + label: "Latitude", + description: "The latitude of the return address", + optional: true, + }, + longitude: { + type: "string", + label: "Longitude", + description: "The longitude of the return address", + optional: true, + }, + }, + async run({ $ }) { + const { + returnAddressId, + name, + companyName, + street, + houseNumber, + postalCode, + city, + latitude, + longitude, + } = this; + + const { data: response } = await this.app.updateReturnAddress({ + $, + returnAddressId, + data: { + name, + company_name: companyName, + street, + house_number: houseNumber, + postal_code: postalCode, + city, + latitude, + longitude, + }, + }); + + $.export("$summary", `Successfully updated return address ${this.returnAddressId}`); + return response; + }, +}; diff --git a/components/returnless/actions/update-return-order-status/update-return-order-status.mjs b/components/returnless/actions/update-return-order-status/update-return-order-status.mjs index 6000277546db2..731305bb35b9b 100644 --- a/components/returnless/actions/update-return-order-status/update-return-order-status.mjs +++ b/components/returnless/actions/update-return-order-status/update-return-order-status.mjs @@ -4,7 +4,7 @@ export default { key: "returnless-update-return-order-status", name: "Update Return Order Status", description: "Update the status of a return order. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/1d07e272437a4-update-a-return-order-status)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/returnless/package.json b/components/returnless/package.json index a3e373654d2fe..cd2602c6d5d58 100644 --- a/components/returnless/package.json +++ b/components/returnless/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/returnless", - "version": "0.1.1", + "version": "0.2.0", "description": "Pipedream Returnless Components", "main": "returnless.app.mjs", "keywords": [ diff --git a/components/returnless/returnless.app.mjs b/components/returnless/returnless.app.mjs index c7eabda076dcd..309d8cef6f2a0 100644 --- a/components/returnless/returnless.app.mjs +++ b/components/returnless/returnless.app.mjs @@ -159,6 +159,81 @@ export default { default: 100, optional: true, }, + shipmentId: { + type: "string", + label: "Shipment ID", + description: "The ID of the shipment", + async options({ prevContext }) { + const { + data, meta, + } = await this.listShipments({ + params: { + cursor: prevContext?.cursor, + }, + }); + return { + options: data.map(({ + id: value, tracking_code: code, + }) => ({ + value, + label: code || value, + })) || [], + context: { + cursor: meta.next_cursor, + }, + }; + }, + }, + returnAddressId: { + type: "string", + label: "Return Address ID", + description: "The ID of the return address", + async options({ prevContext }) { + const { + data, meta, + } = await this.listReturnAddresses({ + params: { + cursor: prevContext?.cursor, + }, + }); + return { + options: data.map(({ + id: value, name: label, + }) => ({ + value, + label: label || value, + })) || [], + context: { + cursor: meta.next_cursor, + }, + }; + }, + }, + customerId: { + type: "string", + label: "Customer ID", + description: "The ID of the customer", + async options({ prevContext }) { + const { + data, meta, + } = await this.listCustomers({ + params: { + cursor: prevContext?.cursor, + }, + }); + return { + options: data.map(({ + id: value, email: label, + }) => ({ + value, + label: label || value, + })) || [], + context: { + cursor: meta.next_cursor, + }, + }; + }, + }, }, methods: { _baseUrl() { @@ -252,6 +327,97 @@ export default { ...opts, }); }, + getReturnOrder({ + returnOrderId, ...opts + }) { + return this._makeRequest({ + path: `/return-orders/${returnOrderId}`, + ...opts, + }); + }, + listReturnOrderShipments({ + returnOrderId, ...opts + }) { + return this._makeRequest({ + path: `/return-orders/${returnOrderId}/shipments`, + ...opts, + }); + }, + getReturnStatus({ + returnStatusId, ...opts + }) { + return this._makeRequest({ + path: `/return-statuses/${returnStatusId}`, + ...opts, + }); + }, + listShipments(opts = {}) { + return this._makeRequest({ + path: "/shipments", + ...opts, + }); + }, + getShipment({ + shipmentId, ...opts + }) { + return this._makeRequest({ + path: `/shipments/${shipmentId}`, + ...opts, + }); + }, + listShipmentStatuses({ + shipmentId, ...opts + }) { + return this._makeRequest({ + path: `/shipments/${shipmentId}/statuses`, + ...opts, + }); + }, + listReturnAddresses(opts = {}) { + return this._makeRequest({ + path: "/return-addresses", + ...opts, + }); + }, + getReturnAddress({ + returnAddressId, ...opts + }) { + return this._makeRequest({ + path: `/return-addresses/${returnAddressId}`, + ...opts, + }); + }, + updateReturnAddress({ + returnAddressId, ...opts + }) { + return this._makeRequest({ + path: `/return-addresses/${returnAddressId}`, + method: "PATCH", + ...opts, + }); + }, + listCustomers(opts = {}) { + return this._makeRequest({ + path: "/customers", + ...opts, + }); + }, + getCustomer({ + customerId, ...opts + }) { + return this._makeRequest({ + path: `/customers/${customerId}`, + ...opts, + }); + }, + listCustomerReturnOrders({ + customerId, ...opts + }) { + return this._makeRequest({ + path: `/customers/${customerId}/return-orders`, + ...opts, + }); + }, createReturnOrderIntent(opts = {}) { return this._makeRequest({ path: "/return-order-intents", diff --git a/components/returnless/sources/new-return-created/new-return-created.mjs b/components/returnless/sources/new-return-created/new-return-created.mjs index a54aaa1ed0367..7a27e8f3c1a61 100644 --- a/components/returnless/sources/new-return-created/new-return-created.mjs +++ b/components/returnless/sources/new-return-created/new-return-created.mjs @@ -5,7 +5,7 @@ export default { key: "returnless-new-return-created", name: "New Return Created (Instant)", description: "Emit new event when a return is created. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/fd4ad9c27648b-creates-a-webhook-subscriptions)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/returnless/sources/return-notes-added/return-notes-added.mjs b/components/returnless/sources/return-notes-added/return-notes-added.mjs index 21c7c3d680ffc..3adc185cf51d3 100644 --- a/components/returnless/sources/return-notes-added/return-notes-added.mjs +++ b/components/returnless/sources/return-notes-added/return-notes-added.mjs @@ -5,7 +5,7 @@ export default { key: "returnless-return-notes-added", name: "Return Notes Added (Instant)", description: "Emit new event when a return note is added. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/fd4ad9c27648b-creates-a-webhook-subscriptions)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/returnless/sources/return-product-marked-received/return-product-marked-received.mjs b/components/returnless/sources/return-product-marked-received/return-product-marked-received.mjs index edc71205b1f19..a79c2318e470c 100644 --- a/components/returnless/sources/return-product-marked-received/return-product-marked-received.mjs +++ b/components/returnless/sources/return-product-marked-received/return-product-marked-received.mjs @@ -5,7 +5,7 @@ export default { key: "returnless-return-product-marked-received", name: "Return Product Marked Received (Instant)", description: "Emit new event when a return product is marked as received. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/fd4ad9c27648b-creates-a-webhook-subscriptions)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/returnless/sources/return-status-changed/return-status-changed.mjs b/components/returnless/sources/return-status-changed/return-status-changed.mjs index 229893f484a93..42943d462f950 100644 --- a/components/returnless/sources/return-status-changed/return-status-changed.mjs +++ b/components/returnless/sources/return-status-changed/return-status-changed.mjs @@ -5,7 +5,7 @@ export default { key: "returnless-return-status-changed", name: "Return Status Changed (Instant)", description: "Emit new event when a return status is changed. [See the documentation](https://docs.returnless.com/docs/api-rest-reference/fd4ad9c27648b-creates-a-webhook-subscriptions)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: {