Skip to content

Commit 32a4d13

Browse files
committed
Update PlentyONE component: Bump version to 0.1.0, add new actions for order management, and enhance prop definitions. Introduced methods for creating, retrieving, and managing orders, including adding notes and fetching order items and documents. Added constants for order types and payment statuses. Improved utility functions for better data handling.
1 parent 4e64451 commit 32a4d13

File tree

11 files changed

+987
-6
lines changed

11 files changed

+987
-6
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import plentyone from "../../plentyone.app.mjs";
2+
3+
export default {
4+
key: "plentyone-add-order-note",
5+
name: "Add Order Note",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
plentyone,
11+
orderId: {
12+
propDefinition: [
13+
plentyone,
14+
"orderId",
15+
],
16+
},
17+
text: {
18+
type: "string",
19+
label: "Note Text",
20+
description: "The text of the note to add.",
21+
},
22+
isVisibleForContact: {
23+
type: "boolean",
24+
label: "Is Visible for Contact",
25+
description: "Whether the note is visible to the contact.",
26+
},
27+
},
28+
async run({ $ }) {
29+
const response = await this.plentyone.addOrderNote({
30+
$,
31+
data: {
32+
referenceType: "order",
33+
referenceValue: this.orderId,
34+
text: this.text,
35+
isVisibleForContact: this.isVisibleForContact,
36+
},
37+
});
38+
39+
$.export("$summary", `Successfully added note to order: ${this.orderId}`);
40+
return response;
41+
},
42+
};
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import {
3+
LOCK_STATUS_OPTIONS,
4+
ORDER_TYPE_OPTIONS,
5+
} from "../../common/constants.mjs";
6+
import plentyone from "../../plentyone.app.mjs";
7+
8+
export default {
9+
key: "plentyone-create-order",
10+
name: "Create Order",
11+
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)",
12+
version: "0.0.1",
13+
type: "action",
14+
props: {
15+
plentyone,
16+
orderTypeId: {
17+
type: "integer",
18+
label: "Order Type ID",
19+
description: "The ID of the order type.",
20+
options: ORDER_TYPE_OPTIONS,
21+
},
22+
plentyId: {
23+
type: "integer",
24+
label: "Plenty ID",
25+
description: "The plenty ID of the client that the order belongs to.",
26+
},
27+
statusId: {
28+
type: "integer",
29+
label: "Status ID",
30+
description: "The ID of the order status.",
31+
optional: true,
32+
},
33+
ownerId: {
34+
type: "integer",
35+
label: "Owner ID",
36+
description: "The user ID of the order's owner.",
37+
optional: true,
38+
},
39+
lockStatus: {
40+
type: "string",
41+
label: "Lock Status",
42+
description: "The lock status of the order.",
43+
options: LOCK_STATUS_OPTIONS,
44+
optional: true,
45+
},
46+
orderItems: {
47+
type: "string[]",
48+
label: "Order Items",
49+
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.",
50+
optional: true,
51+
},
52+
properties: {
53+
type: "string[]",
54+
label: "Properties",
55+
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.",
56+
optional: true,
57+
},
58+
addressRelations: {
59+
type: "string[]",
60+
label: "Address Relations",
61+
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.",
62+
optional: true,
63+
},
64+
relations: {
65+
type: "string[]",
66+
label: "Relations",
67+
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.",
68+
optional: true,
69+
},
70+
},
71+
async run({ $ }) {
72+
try {
73+
const response = await this.plentyone.createOrder({
74+
$,
75+
data: {
76+
orderTypeId: this.orderTypeId,
77+
plentyId: this.plentyId,
78+
statusId: this.statusId,
79+
ownerId: this.ownerId,
80+
lockStatus: this.lockStatus,
81+
orderItems: this.orderItems,
82+
properties: this.properties,
83+
addressRelations: this.addressRelations,
84+
relations: this.relations,
85+
},
86+
});
87+
88+
$.export("$summary", `Successfully created order: ${response.data?.id || "Unknown"}`);
89+
return response;
90+
} catch (error) {
91+
$.export("$summary", "Failed to create order");
92+
throw new ConfigurationError(error);
93+
}
94+
},
95+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import plentyone from "../../plentyone.app.mjs";
2+
3+
export default {
4+
key: "plentyone-get-order-documents",
5+
name: "Get Order Documents",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
plentyone,
11+
orderId: {
12+
propDefinition: [
13+
plentyone,
14+
"orderId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.plentyone.getOrderDocuments({
20+
$,
21+
params: {
22+
orderId: this.orderId,
23+
},
24+
});
25+
26+
$.export("$summary", `Successfully retrieved ${response.entries.length} documents for order: ${this.orderId}`);
27+
return response;
28+
},
29+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import plentyone from "../../plentyone.app.mjs";
2+
3+
export default {
4+
key: "plentyone-get-order-items",
5+
name: "Get Order Items",
6+
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_)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
plentyone,
11+
orderId: {
12+
propDefinition: [
13+
plentyone,
14+
"orderId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
try {
20+
const response = await this.plentyone.getOrder({
21+
$,
22+
orderId: this.orderId,
23+
params: {
24+
addOrderItems: true,
25+
},
26+
});
27+
28+
$.export("$summary", `Successfully retrieved ${response.orderItems.length} items for order: ${this.orderId}`);
29+
return response.orderItems;
30+
} catch (error) {
31+
$.export("$summary", `No items found for order: ${this.orderId}`);
32+
return {};
33+
}
34+
},
35+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import plentyone from "../../plentyone.app.mjs";
2+
3+
export default {
4+
key: "plentyone-get-order-properties",
5+
name: "Get Order Properties",
6+
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_)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
plentyone,
11+
orderId: {
12+
propDefinition: [
13+
plentyone,
14+
"orderId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.plentyone.getOrder({
20+
$,
21+
orderId: this.orderId,
22+
});
23+
24+
$.export("$summary", `Successfully retrieved properties for order with ID: ${this.orderId}`);
25+
return response.properties;
26+
},
27+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import plentyone from "../../plentyone.app.mjs";
2+
3+
export default {
4+
key: "plentyone-get-order",
5+
name: "Get Order",
6+
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_)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
plentyone,
11+
orderId: {
12+
propDefinition: [
13+
plentyone,
14+
"orderId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
try {
20+
const response = await this.plentyone.getOrder({
21+
$,
22+
orderId: this.orderId,
23+
});
24+
25+
$.export("$summary", `Successfully retrieved order: ${this.orderId}`);
26+
return response;
27+
} catch (error) {
28+
$.export("$summary", `No order found with ID: ${this.orderId}`);
29+
return {};
30+
}
31+
},
32+
};

0 commit comments

Comments
 (0)