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
22 changes: 19 additions & 3 deletions components/shopify_developer_app/actions/get-order/get-order.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { MAX_LIMIT } from "@pipedream/shopify/common/constants.mjs";
import shopify from "../../shopify_developer_app.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "shopify_developer_app-get-order",
name: "Get Order",
description: "Retrieve an order by specifying the order ID. [See the documentation](https://shopify.dev/docs/api/admin-graphql/latest/queries/order)",
version: "0.0.9",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -21,12 +22,27 @@ export default {
],
},
},
methods: {
validateOrderId(orderId) {
const prefix = "gid://shopify/Order/";
const value = String(orderId).trim();
if (value.startsWith(prefix)) {
return value;
}
if (/^\d+$/.test(value)) {
return `${prefix}${value}`;
}
throw new ConfigurationError(`Invalid order ID: ${orderId}`);
},
},
async run({ $ }) {
const orderId = this.validateOrderId(this.orderId);

const response = await this.shopify.getOrder({
id: this.orderId,
id: orderId,
first: MAX_LIMIT,
});
$.export("$summary", `Successfully retrieved order with ID: ${this.orderId}`);
$.export("$summary", `Successfully retrieved order with ID: ${orderId}`);
return response;
},
};
2 changes: 1 addition & 1 deletion components/shopify_developer_app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/shopify_developer_app",
"version": "0.10.0",
"version": "0.10.1",
"description": "Pipedream Shopify (Developer App) Components",
"main": "shopify_developer_app.app.mjs",
"keywords": [
Expand Down
Loading