Skip to content

Commit

Permalink
[Components] americommerce (#14229)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes authored Oct 10, 2024
1 parent da8d269 commit a2ce805
Show file tree
Hide file tree
Showing 15 changed files with 1,570 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import app from "../../americommerce.app.mjs";

export default {
key: "americommerce-change-order-status",
name: "Change Order Status",
description: "Changes the status of an existing order. [See the documentation](https://developers.cart.com/docs/rest-api/6898d9f254dfb-update-an-order-status).",
version: "0.0.1",
type: "action",
props: {
app,
orderStatusId: {
optional: false,
propDefinition: [
app,
"orderStatusId",
],
},
name: {
type: "string",
label: "Name",
description: "The name of the order status.",
optional: true,
},
isOpen: {
type: "boolean",
label: "Is Open",
description: "Indicates whether the order status is open.",
optional: true,
},
isDeclined: {
type: "boolean",
label: "Is Declined",
description: "Indicates whether the order status is declined.",
optional: true,
},
isCancelled: {
type: "boolean",
label: "Is Cancelled",
description: "Indicates whether the order status is cancelled.",
optional: true,
},
isShipped: {
type: "boolean",
label: "Is Shipped",
description: "Indicates whether the order status is shipped.",
optional: true,
},
color: {
type: "string",
label: "Color",
description: "The color of the order status.",
optional: true,
},
emailTemplateId: {
propDefinition: [
app,
"emailTemplateId",
],
},
isFullyRefunded: {
type: "boolean",
label: "Is Fully Refunded",
description: "Indicates whether the order status is fully refunded.",
optional: true,
},
isPartiallyRefunded: {
type: "boolean",
label: "Is Partially Refunded",
description: "Indicates whether the order status is partially refunded.",
optional: true,
},
isQuoteStatus: {
type: "boolean",
label: "Is Quote Status",
description: "Indicates whether the order status is a quote status.",
optional: true,
},
isPartiallyShipped: {
type: "boolean",
label: "Is Partially Shipped",
description: "Indicates whether the order status is partially shipped.",
optional: true,
},
},
methods: {
changeOrderStatus({
orderStatusId, ...args
} = {}) {
return this.app.put({
path: `/order_statuses/${orderStatusId}`,
...args,
});
},
},
async run({ $ }) {
const {
changeOrderStatus,
orderStatusId,
name,
isOpen,
isDeclined,
isCancelled,
isShipped,
color,
emailTemplateId,
isFullyRefunded,
isPartiallyRefunded,
isQuoteStatus,
isPartiallyShipped,
} = this;

const response = await changeOrderStatus({
$,
orderStatusId,
data: {
name,
is_open: isOpen,
is_declined: isDeclined,
is_cancelled: isCancelled,
is_shipped: isShipped,
color,
email_template_id: emailTemplateId,
is_fully_refunded: isFullyRefunded,
is_partially_refunded: isPartiallyRefunded,
is_quote_status: isQuoteStatus,
is_partially_shipped: isPartiallyShipped,
},
});
$.export("$summary", `Successfully changed the order status with ID \`${response.id}\`.`);
return response;
},
};
Loading

0 comments on commit a2ce805

Please sign in to comment.