Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import app from "../../postnl.app.mjs";

export default {
key: "postnl-get-status-by-barcode",
name: "Get Status By Barcode",
description: "Retrieve the status of a shipment using its barcode. [See the documentation](https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/shippingstatus/get-status-by-barcode)",
type: "action",
version: "0.0.1",
props: {
app,
barcode: {
propDefinition: [
app,
"barcode",
],
},
detail: {
propDefinition: [
app,
"detail",
],
},
language: {
propDefinition: [
app,
"language",
],
},
maxDays: {
propDefinition: [
app,
"maxDays",
],
},
},
async run({ $ }) {
const {
app,
barcode,
detail,
language,
maxDays,
} = this;

const response = await app.getStatusByBarcode({
$,
barcode,
params: {
detail,
language,
maxDays,
},
});

$.export("$summary", "Successfully retrieved status by barcode");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import app from "../../postnl.app.mjs";

export default {
key: "postnl-get-status-by-reference",
name: "Get Status By Reference",
description: "Retrieve the status of a shipment using a reference number. [See the documentation](https://developer.postnl.nl/docs/#/http/api-endpoints/send-track/shippingstatus/get-status-by-reference)",
type: "action",
version: "0.0.1",
props: {
app,
customerCode: {
propDefinition: [
app,
"customerCode",
],
},
customerNumber: {
propDefinition: [
app,
"customerNumber",
],
},
reference: {
propDefinition: [
app,
"referenceId",
],
},
detail: {
propDefinition: [
app,
"detail",
],
},
language: {
propDefinition: [
app,
"language",
],
},
maxDays: {
propDefinition: [
app,
"maxDays",
],
},
},
async run({ $ }) {
const {
app,
customerCode,
customerNumber,
reference,
detail,
language,
maxDays,
} = this;

const response = await app.getStatusByReference({
$,
params: {
customerCode,
customerNumber,
reference,
detail,
language,
maxDays,
},
});

$.export("$summary", "Successfully retrieved status by reference");
return response;
},
};
7 changes: 5 additions & 2 deletions components/postnl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/postnl",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream PostNL Components",
"main": "postnl.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
91 changes: 87 additions & 4 deletions components/postnl/postnl.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,94 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "postnl",
propDefinitions: {},
propDefinitions: {
barcode: {
type: "string",
label: "Barcode",
description: "The barcode of the shipment to track. Eg. `3SABCD123456789`",
},
customerCode: {
type: "string",
label: "Customer Code",
description: "The customer code for reference tracking",
async options() {
return [
this.$auth.customer_code,
];
},
},
customerNumber: {
type: "string",
label: "Customer Number",
description: "The customer number for reference tracking",
},
referenceId: {
type: "string",
label: "Reference ID",
description: "The reference number to track",
},
detail: {
type: "boolean",
label: "Detail",
description: "Option to include old statuses in the response",
optional: true,
},
language: {
type: "string",
label: "Language",
description: "Language of the returned shipment and status descriptions (default is Dutch)",
options: [
"NL",
"EN",
"CN",
"DE",
"FR",
],
optional: true,
},
maxDays: {
type: "integer",
label: "Max Days",
description: "Limit the number of days that will be searched (decrease this amount for better performance).",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
const { api_url: baseUrl } = this.$auth;
return `${baseUrl}${path}`;
},
getHeaders(headers) {
return {
"Content-Type": "application/json",
"apikey": this.$auth.api_key,
...headers,
};
},
makeRequest({
$ = this, path, headers, ...config
}) {
return axios($, {
url: this.getUrl(path),
headers: this.getHeaders(headers),
...config,
});
},
getStatusByBarcode({
barcode, ...args
} = {}) {
return this.makeRequest({
path: `/shipment/v2/status/barcode/${barcode}`,
...args,
});
},
getStatusByReference(args = {}) {
return this.makeRequest({
path: "/shipment/v2/status/reference",
...args,
});
},
},
};
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading