Skip to content

Commit 64de5ea

Browse files
committed
updates
1 parent 493b188 commit 64de5ea

File tree

9 files changed

+61
-149
lines changed

9 files changed

+61
-149
lines changed

components/oto/actions/create-product/create-product.mjs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import oto from "../../oto.app.mjs";
2-
import utils from "../../common/utils.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
33

44
export default {
55
key: "oto-create-product",
@@ -28,7 +28,6 @@ export default {
2828
type: "string",
2929
label: "Tax Amount",
3030
description: "Tax Amount of the product",
31-
optional: true,
3231
},
3332
brandId: {
3433
propDefinition: [
@@ -78,12 +77,6 @@ export default {
7877
description: "Origin of the product",
7978
optional: true,
8079
},
81-
bundleItems: {
82-
type: "boolean",
83-
label: "Bundle Items",
84-
description: "It can be true/ false",
85-
optional: true,
86-
},
8780
customAttributes: {
8881
type: "object",
8982
label: "Custom Attributes",
@@ -107,11 +100,12 @@ export default {
107100
category: this.category,
108101
hsCode: this.hsCode,
109102
itemOrigin: this.itemOrigin,
110-
bundleItems: this.bundleItems,
111-
customAttributes: utils.parseObject(this.customAttributes),
103+
customAttributes: parseObject(this.customAttributes),
112104
},
113105
});
114-
$.export("$summary", `Successfully created product with ID: ${response.productId}`);
106+
if (response.productId) {
107+
$.export("$summary", `Successfully created product with ID: ${response.productId}`);
108+
}
115109
return response;
116110
},
117111
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import oto from "../../oto.app.mjs";
2+
3+
export default {
4+
key: "oto-get-order-details",
5+
name: "Get Order Details",
6+
description: "Provides detailed information about a specific order. [See the documentation](https://apis.tryoto.com/#53964419-2d64-4c07-b39d-b26a92b379c9)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
oto,
11+
orderId: {
12+
propDefinition: [
13+
oto,
14+
"orderId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.oto.getOrderDetails({
20+
$,
21+
params: {
22+
orderId: this.orderId,
23+
},
24+
});
25+
$.export("$summary", `Successfully retrieved details for order with ID: ${this.orderId}`);
26+
return response;
27+
},
28+
};

components/oto/actions/list-orders/list-orders.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ export default {
5454
orders.push(order);
5555
}
5656

57-
$.export("$summary", `Successfully retrieved ${orders.length} order${orders.length === 1
58-
? ""
59-
: "s"}`);
57+
if (orders[0].items?.length) {
58+
$.export("$summary", `Successfully retrieved ${orders.length} order${orders.length === 1
59+
? ""
60+
: "s"}`);
61+
} else {
62+
$.export("$summary", "No orders found");
63+
}
6064
return orders;
6165
},
6266
};

components/oto/actions/track-shipment/track-shipment.mjs

Lines changed: 0 additions & 41 deletions
This file was deleted.

components/oto/oto.app.mjs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ export default {
3030
})) || [];
3131
},
3232
},
33+
orderId: {
34+
type: "string",
35+
label: "Order ID",
36+
description: "The ID of an order",
37+
async options({ page }) {
38+
const { orders } = await this.listOrders({
39+
params: {
40+
page,
41+
},
42+
});
43+
return orders?.map(({ orderId }) => orderId ) || [];
44+
},
45+
},
3346
status: {
3447
type: "string",
3548
label: "Status",
@@ -67,6 +80,12 @@ export default {
6780
...opts,
6881
});
6982
},
83+
getOrderDetails(opts = {}) {
84+
return this._makeRequest({
85+
path: "/orderDetails",
86+
...opts,
87+
});
88+
},
7089
listOrders(opts = {}) {
7190
return this._makeRequest({
7291
path: "/orders",
@@ -86,13 +105,6 @@ export default {
86105
...opts,
87106
});
88107
},
89-
trackShipment(opts = {}) {
90-
return this._makeRequest({
91-
method: "POST",
92-
path: "/trackShipment",
93-
...opts,
94-
});
95-
},
96108
async *paginate({
97109
fn, args, resourceKey, max,
98110
}) {

components/oto/sources/new-order-instant/new-order-instant.mjs

Lines changed: 0 additions & 26 deletions
This file was deleted.

components/oto/sources/new-order-instant/test-event.mjs

Lines changed: 0 additions & 35 deletions
This file was deleted.

components/oto/sources/new-shipment-error-instant/new-shipment-error-instant.mjs

Lines changed: 0 additions & 24 deletions
This file was deleted.

components/oto/sources/order-status-updated-instant/new-order-status-updated.mjs renamed to components/oto/sources/order-status-updated-instant/order-status-updated-instant.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import sampleEmit from "./test-event.mjs";
33

44
export default {
55
...common,
6-
key: "oto-new-order-status-instant",
7-
name: "New Order Status (Instant)",
6+
key: "oto-order-status-updated-instant",
7+
name: "Order Status Updated (Instant)",
88
description: "Emit new event when the status of an order changes. [See the documentation](https://apis.tryoto.com/#9671ca1f-7d06-43fc-8ee9-cf9c336b088d)",
99
version: "0.0.1",
1010
type: "source",

0 commit comments

Comments
 (0)