Skip to content

Commit 69f72da

Browse files
committed
Add order and shipment management features to Paazl app
- Introduced prop definitions for Order ID and Shipment ID. - Implemented methods for retrieving order shipments and shipment details. - Added methods for creating orders and shipments. - Enhanced request handling with improved headers and base URL configuration.
1 parent a00e05a commit 69f72da

File tree

1 file changed

+79
-5
lines changed

1 file changed

+79
-5
lines changed

components/paazl/paazl.app.mjs

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,85 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "paazl",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
orderId: {
8+
type: "string",
9+
label: "Order ID",
10+
description: "The unique identifier of the order",
11+
},
12+
shipmentId: {
13+
type: "string",
14+
label: "Shipment ID",
15+
description: "The unique identifier of the shipment",
16+
async options({
17+
page, orderId,
18+
}) {
19+
const { shipments } = await this.getOrderShipments({
20+
orderId,
21+
params: {
22+
page,
23+
},
24+
});
25+
26+
return shipments.map(({ trackingNumber }) => trackingNumber);
27+
},
28+
},
29+
},
530
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
31+
_headers() {
32+
return {
33+
"Authorization": `Bearer ${this.$auth.api_key}:${this.$auth.api_secret}`,
34+
"Content-Type": "application/json",
35+
"Accept": "application/json;charset=utf-8",
36+
};
37+
},
38+
_baseUrl() {
39+
return `${this.$auth.environment}/v1`;
40+
},
41+
_makeRequest({
42+
$ = this, path, ...opts
43+
}) {
44+
const config = {
45+
url: this._baseUrl() + path,
46+
headers: this._headers(),
47+
...opts,
48+
};
49+
console.log("config: ", config);
50+
return axios($, config);
51+
},
52+
getOrderShipments({
53+
orderId, ...opts
54+
}) {
55+
return this._makeRequest({
56+
path: `/orders/${orderId}/shipments`,
57+
...opts,
58+
});
59+
},
60+
getOrderShipmentDetails({
61+
orderId, shipmentId, ...opts
62+
}) {
63+
return this._makeRequest({
64+
path: `/orders/${orderId}/shipments/${shipmentId}`,
65+
...opts,
66+
});
67+
},
68+
createOrder(opts = {}) {
69+
return this._makeRequest({
70+
path: "/order",
71+
method: "POST",
72+
...opts,
73+
});
74+
},
75+
createShipment({
76+
orderId, ...opts
77+
}) {
78+
return this._makeRequest({
79+
path: `/orders/${orderId}/shipments`,
80+
method: "POST",
81+
...opts,
82+
});
983
},
1084
},
11-
};
85+
};

0 commit comments

Comments
 (0)