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
42 changes: 42 additions & 0 deletions components/plentyone/actions/add-order-note/add-order-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import plentyone from "../../plentyone.app.mjs";

export default {
key: "plentyone-add-order-note",
name: "Add Order Note",
description: "Adds a note to an order in PlentyONE. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Comment/post_rest_comments)",
version: "0.0.1",
type: "action",
props: {
plentyone,
orderId: {
propDefinition: [
plentyone,
"orderId",
],
},
text: {
type: "string",
label: "Note Text",
description: "The text of the note to add.",
},
isVisibleForContact: {
type: "boolean",
label: "Is Visible for Contact",
description: "Whether the note is visible to the contact.",
},
},
async run({ $ }) {
const response = await this.plentyone.addOrderNote({
$,
data: {
referenceType: "order",
referenceValue: this.orderId,
text: this.text,
isVisibleForContact: this.isVisibleForContact,
},
});

$.export("$summary", `Successfully added note to order: ${this.orderId}`);
return response;
},
};
97 changes: 97 additions & 0 deletions components/plentyone/actions/create-order/create-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { ConfigurationError } from "@pipedream/platform";
import {
LOCK_STATUS_OPTIONS,
ORDER_TYPE_OPTIONS,
} from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import plentyone from "../../plentyone.app.mjs";

export default {
key: "plentyone-create-order",
name: "Create Order",
description: "Creates a new order in PlentyONE. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/post_rest_orders)",
version: "0.0.1",
type: "action",
props: {
plentyone,
orderTypeId: {
type: "integer",
label: "Order Type ID",
description: "The ID of the order type.",
options: ORDER_TYPE_OPTIONS,
},
plentyId: {
type: "integer",
label: "Plenty ID",
description: "The plenty ID of the client that the order belongs to.",
},
statusId: {
propDefinition: [
plentyone,
"statusId",
],
optional: true,
},
ownerId: {
type: "integer",
label: "Owner ID",
description: "The user ID of the order's owner.",
optional: true,
},
lockStatus: {
type: "string",
label: "Lock Status",
description: "The lock status of the order.",
options: LOCK_STATUS_OPTIONS,
optional: true,
},
orderItems: {
type: "string[]",
label: "Order Items",
description: "A list of objects of the order items. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/post_rest_orders) for more details.",
optional: true,
},
properties: {
type: "string[]",
label: "Properties",
description: "A list of objects of the order properties. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/post_rest_orders) for more details.",
optional: true,
},
addressRelations: {
type: "string[]",
label: "Address Relations",
description: "A list of objects of the order address relations. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/post_rest_orders) for more details.",
optional: true,
},
relations: {
type: "string[]",
label: "Relations",
description: "A list of objects of the order relations. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/post_rest_orders) for more details.",
optional: true,
},
},
async run({ $ }) {
try {
const response = await this.plentyone.createOrder({
$,
data: {
typeId: this.orderTypeId,
plentyId: this.plentyId,
statusId: this.statusId,
ownerId: this.ownerId,
lockStatus: this.lockStatus,
orderItems: parseObject(this.orderItems),
properties: parseObject(this.properties),
addressRelations: parseObject(this.addressRelations),
relations: parseObject(this.relations),
},
});

$.export("$summary", `Successfully created order: ${response.id}`);
return response;
} catch (error) {
$.export("$summary", "Failed to create order");
throw new ConfigurationError(error);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import plentyone from "../../plentyone.app.mjs";

export default {
key: "plentyone-get-order-documents",
name: "Get Order Documents",
description: "Retrieves documents for a specific order from PlentyONE. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Document/get_rest_orders_documents_find)",
version: "0.0.1",
type: "action",
props: {
plentyone,
orderId: {
propDefinition: [
plentyone,
"orderId",
],
},
},
async run({ $ }) {
const response = await this.plentyone.getOrderDocuments({
$,
params: {
orderId: this.orderId,
},
});

$.export("$summary", `Successfully retrieved ${response.entries.length} documents for order: ${this.orderId}`);
return response;
},
};
35 changes: 35 additions & 0 deletions components/plentyone/actions/get-order-items/get-order-items.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import plentyone from "../../plentyone.app.mjs";

export default {
key: "plentyone-get-order-items",
name: "Get Order Items",
description: "Retrieves items for a specific order from PlentyONE [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/get_rest_orders__orderId_)",
version: "0.0.1",
type: "action",
props: {
plentyone,
orderId: {
propDefinition: [
plentyone,
"orderId",
],
},
},
async run({ $ }) {
try {
const response = await this.plentyone.getOrder({
$,
orderId: this.orderId,
params: {
addOrderItems: true,
},
});

$.export("$summary", `Successfully retrieved ${response.orderItems.length} items for order: ${this.orderId}`);
return response.orderItems;
} catch (error) {
$.export("$summary", `No items found for order: ${this.orderId}`);
return {};
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import plentyone from "../../plentyone.app.mjs";

export default {
key: "plentyone-get-order-properties",
name: "Get Order Properties",
description: "Retrieves properties for a specific order from PlentyONE [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/get_rest_orders__orderId_)",
version: "0.0.1",
type: "action",
props: {
plentyone,
orderId: {
propDefinition: [
plentyone,
"orderId",
],
},
},
async run({ $ }) {
const response = await this.plentyone.getOrder({
$,
orderId: this.orderId,
});

$.export("$summary", `Successfully retrieved properties for order with ID: ${this.orderId}`);
return response.properties;
},
};
32 changes: 32 additions & 0 deletions components/plentyone/actions/get-order/get-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import plentyone from "../../plentyone.app.mjs";

export default {
key: "plentyone-get-order",
name: "Get Order",
description: "Retrieves a specific order by ID from PlentyONE. [See the documentation](https://developers.plentymarkets.com/en-gb/plentymarkets-rest-api/index.html#/Order/get_rest_orders__orderId_)",
version: "0.0.1",
type: "action",
props: {
plentyone,
orderId: {
propDefinition: [
plentyone,
"orderId",
],
},
},
async run({ $ }) {
try {
const response = await this.plentyone.getOrder({
$,
orderId: this.orderId,
});

$.export("$summary", `Successfully retrieved order: ${this.orderId}`);
return response;
} catch (error) {
$.export("$summary", `No order found with ID: ${this.orderId}`);
return {};
}
},
};
Loading
Loading