Skip to content

Commit 4c090b2

Browse files
authored
18059 plentymarkets (#18232)
* 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. * pnpm update * Fix package.json formatting by adding a newline at the end of the file. * Add statusId prop definition to create-order action and implement getOrderStatuses method in PlentyONE component. Enhanced order creation by parsing order items and related properties for improved data handling.
1 parent cc81de2 commit 4c090b2

File tree

12 files changed

+1020
-8
lines changed

12 files changed

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