Skip to content

Commit 5d04efc

Browse files
authored
New Components - DHL (#18181)
* new components * pnpm-lock.yaml * fix typo * remove subscription actions
1 parent 68da7a3 commit 5d04efc

File tree

5 files changed

+133
-7
lines changed

5 files changed

+133
-7
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import dhl from "../../dhl.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "dhl-get-tracking",
6+
name: "Get Tracking Information",
7+
description: "Get tracking information for shipments. [See the documentation](https://developer.dhl.com/api-reference/shipment-tracking#operations-default-getTrackingShipment)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
dhl,
12+
trackingNumber: {
13+
type: "string",
14+
label: "Tracking Number",
15+
description: "The tracking number of the shipment to get tracking information for",
16+
},
17+
service: {
18+
type: "string",
19+
label: "Service",
20+
description: "The service of the shipment to get tracking information for",
21+
options: constants.SHIPPING_SERVICES,
22+
optional: true,
23+
},
24+
requesterCountryCode: {
25+
type: "string",
26+
label: "Requester Country Code",
27+
description: "Optional ISO 3166-1 alpha-2 country code represents country of the consumer of the API response.",
28+
optional: true,
29+
},
30+
originCountryCode: {
31+
type: "string",
32+
label: "Origin Country Code",
33+
description: "Optional ISO 3166-1 alpha-2 country code of the shipment origin to further qualify the shipment tracking number (trackingNumber) parameter of the request.",
34+
optional: true,
35+
},
36+
recipientPostalCode: {
37+
type: "string",
38+
label: "Requester Postal Code",
39+
description: "Postal code of the destination address",
40+
optional: true,
41+
},
42+
language: {
43+
type: "string",
44+
label: "Language",
45+
description: "ISO 639-1 2-character language code for the response. This parameter serves as an indication of the client preferences ONLY. Language availability depends on the service used.",
46+
optional: true,
47+
},
48+
limit: {
49+
type: "integer",
50+
label: "Limit",
51+
description: "Maximum number of events to be returned in the response. Default: 5",
52+
optional: true,
53+
},
54+
offset: {
55+
type: "integer",
56+
label: "Offset",
57+
description: "Offset of the first event to be returned in the response. Default: 0",
58+
optional: true,
59+
},
60+
},
61+
async run({ $ }) {
62+
const response = await this.dhl.getTracking({
63+
$,
64+
params: {
65+
trackingNumber: this.trackingNumber,
66+
service: this.service,
67+
requesterCountryCode: this.requesterCountryCode,
68+
originCountryCode: this.originCountryCode,
69+
recipientPostalCode: this.recipientPostalCode,
70+
language: this.language,
71+
limit: this.limit,
72+
offset: this.offset,
73+
},
74+
});
75+
$.export("$summary", `Successfully fetched tracking information for ${this.trackingNumber}`);
76+
return response;
77+
},
78+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const SHIPPING_SERVICES = [
2+
"dgf",
3+
"dsc",
4+
"ecommerce",
5+
"ecommerce-apac",
6+
"ecommerce-europe",
7+
"ecommerce-ppl",
8+
"ecommerce-iberia",
9+
"express",
10+
"freight",
11+
"parcel-de",
12+
"parcel-nl",
13+
"parcel-pl",
14+
"parcel-uk",
15+
"post-de",
16+
"post-international",
17+
"sameday",
18+
"svb",
19+
];
20+
21+
export default {
22+
SHIPPING_SERVICES,
23+
};

components/dhl/dhl.app.mjs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "dhl",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return this.$auth.api_url;
10+
},
11+
_makeRequest({
12+
$ = this, path, ...opts
13+
}) {
14+
return axios($, {
15+
url: `${this._baseUrl()}${path}`,
16+
headers: {
17+
"dhl-api-key": `${this.$auth.api_key}`,
18+
},
19+
...opts,
20+
});
21+
},
22+
getTracking(opts = {}) {
23+
return this._makeRequest({
24+
path: "/track/shipments",
25+
...opts,
26+
});
927
},
1028
},
11-
};
29+
};

components/dhl/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/dhl",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream DHL Components",
55
"main": "dhl.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)