sdksio-postnl-ecommerce-apis-sdk
Version:
Collection of PostNL API's for ecommerce processes
187 lines • 12.1 kB
JavaScript
;
/**
* PostNL Ecommerce APIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.TrackTraceController = void 0;
var tslib_1 = require("tslib");
var shippingstatusMethodNotAllowedError_1 = require("../errors/shippingstatusMethodNotAllowedError");
var shippingstatusResponseError_1 = require("../errors/shippingstatusResponseError");
var shippingstatusTooManyRequestError_1 = require("../errors/shippingstatusTooManyRequestError");
var shippingstatusUnauthorizedError_1 = require("../errors/shippingstatusUnauthorizedError");
var languageEnum_1 = require("../models/languageEnum");
var shippingstatusResponse_1 = require("../models/shippingstatusResponse");
var shippingstatusResponseSignature_1 = require("../models/shippingstatusResponseSignature");
var shippingstatusResponseUpdatedShipment_1 = require("../models/shippingstatusResponseUpdatedShipment");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var TrackTraceController = /** @class */ (function (_super) {
tslib_1.__extends(TrackTraceController, _super);
function TrackTraceController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Request example:
* ```
* curl -X GET "https://api-sandbox.postnl.nl/shipment/v2/status/barcode/3SDEVC172649258" \
* -H "Accept: application/json" \
* -H "apikey: APIKEY-HERE" \
* ```
*
*
* @param barcode Barcode of the shipment. This is a unique value.
* @param detail Option to include old statuses in the response
* @param language Language of the returned shipment and status descriptions (default is Dutch).
* @param maxDays Limit the number of days that will be searched (decrease this amount for better
* performance).
* @return Response from the API call
*/
TrackTraceController.prototype.returnsTheStatusesForAParticularBarcode = function (barcode, detail, language, maxDays, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
barcode: [barcode, (0, schema_1.string)()],
detail: [detail, (0, schema_1.optional)((0, schema_1.boolean)())],
language: [language, (0, schema_1.optional)(languageEnum_1.languageEnumSchema)],
maxDays: [maxDays, (0, schema_1.optional)((0, schema_1.string)())]
});
req.query('detail', mapped.detail);
req.query('language', mapped.language);
req.query('maxDays', mapped.maxDays);
req.appendTemplatePath(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/shipment/v2/status/barcode/", ""], ["/shipment/v2/status/barcode/", ""])), mapped.barcode);
req.throwOn(400, shippingstatusResponseError_1.ShippingstatusResponseError, 'Invalid request');
req.throwOn(401, shippingstatusUnauthorizedError_1.ShippingstatusUnauthorizedError, 'Invalid apikey');
req.throwOn(405, shippingstatusMethodNotAllowedError_1.ShippingstatusMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, shippingstatusTooManyRequestError_1.ShippingstatusTooManyRequestError, 'Too many requests');
req.throwOn(500, shippingstatusResponseError_1.ShippingstatusResponseError, 'Internal server error');
return [2 /*return*/, req.callAsJson(shippingstatusResponse_1.shippingstatusResponseSchema, requestOptions)];
});
});
};
/**
* Request example:
* ```
* curl -X GET "https://api-sandbox.postnl.nl/shipment/v2/status/reference?
* detail=true&language=NL&customerCode={{CustomerCode}}&customerNumber={{CustomerNumber}}&reference=RE
* F98173245876329" \
* -H "Accept: application/json" \
* -H "apikey: APIKEY-HERE"
* ```
*
*
* @param customerCode Customer code as known at PostNL Pakketten
* @param customerNumber Customer number as known at PostNL Pakketten
* @param referenceId The customer reference belonging to the shipment
* @param detail Option to include old statuses in the response
* @param language Language of the returned shipment and status descriptions (default is
* Dutch).
* @param maxDays Limit the number of days that will be searched (decrease this amount for
* better performance). By default this is 90 days in the past.
* @return Response from the API call
*/
TrackTraceController.prototype.getStatusInformationByCustomerReference = function (customerCode, customerNumber, referenceId, detail, language, maxDays, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
customerCode: [customerCode, (0, schema_1.string)()],
customerNumber: [customerNumber, (0, schema_1.string)()],
referenceId: [referenceId, (0, schema_1.string)()],
detail: [detail, (0, schema_1.optional)((0, schema_1.boolean)())],
language: [language, (0, schema_1.optional)(languageEnum_1.languageEnumSchema)],
maxDays: [maxDays, (0, schema_1.optional)((0, schema_1.string)())]
});
req.query('customerCode', mapped.customerCode);
req.query('customerNumber', mapped.customerNumber);
req.query('detail', mapped.detail);
req.query('language', mapped.language);
req.query('maxDays', mapped.maxDays);
req.appendTemplatePath(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["/shipment/v2/status/reference/", ""], ["/shipment/v2/status/reference/", ""])), mapped.referenceId);
req.throwOn(400, shippingstatusResponseError_1.ShippingstatusResponseError, 'Invalid request');
req.throwOn(401, shippingstatusUnauthorizedError_1.ShippingstatusUnauthorizedError, 'Invalid apikey');
req.throwOn(405, shippingstatusMethodNotAllowedError_1.ShippingstatusMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, shippingstatusTooManyRequestError_1.ShippingstatusTooManyRequestError, 'Too many requests');
req.throwOn(500, shippingstatusResponseError_1.ShippingstatusResponseError, 'Internal server error');
return [2 /*return*/, req.callAsJson(shippingstatusResponse_1.shippingstatusResponseSchema, requestOptions)];
});
});
};
/**
* Request example:
* ```
* curl -X GET "https://api-sandbox.postnl.nl/shipment/v2/status/signature/3SDEVC172649258" \
* -H "Accept: application/json" \
* -H "apikey: APIKEY-HERE"
* ```
*
*
* @param barcode Barcode of the shipment
* @return Response from the API call
*/
TrackTraceController.prototype.returnsTheSignatureOfAParticularShipment = function (barcode, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET');
mapped = req.prepareArgs({ barcode: [barcode, (0, schema_1.string)()] });
req.appendTemplatePath(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["/shipment/v2/status/signature/", ""], ["/shipment/v2/status/signature/", ""])), mapped.barcode);
req.throwOn(400, shippingstatusResponseError_1.ShippingstatusResponseError, 'Invalid request');
req.throwOn(401, shippingstatusUnauthorizedError_1.ShippingstatusUnauthorizedError, 'Invalid apikey');
req.throwOn(405, shippingstatusMethodNotAllowedError_1.ShippingstatusMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, shippingstatusTooManyRequestError_1.ShippingstatusTooManyRequestError, 'Too many requests');
req.throwOn(500, shippingstatusResponseError_1.ShippingstatusResponseError, 'Internal server error');
return [2 /*return*/, req.callAsJson(shippingstatusResponseSignature_1.shippingstatusResponseSignatureSchema, requestOptions)];
});
});
};
/**
* Request example:
* ```
* curl -X GET "https://api-sandbox.postnl.nl/shipment/v2/status/11223344/updatedshipments?period=2022-
* 12-25T10:00:00&period=2022-12-25T10:12:00" \
* -H "Accept: application/json" \
* -H "apikey: APIKEY-HERE" \
* ```
*
*
* @param customernumber Your customer number
* @param period Optional array which defines a specific period in which to return updated
* shipments. For optimal results, schedule calls at a frequency between 5-15
* minutes and align the requested period accordingly to ensure complete coverage
* of past updates. Shorter periods yield improved response times. The API
* accommodates a maximum requested period of 2 hours, granting access to shipment
* data up to 48 hours in the past. Please use the following format: YYYY-MM-DDTHH:
* MM:SS and repeat this variable to define the period (e.g. /updatedshipments?
* period=2022-11-07T12:00:00.000&period=2022-11-07T12:05:00.000).
* @return Response from the API call
*/
TrackTraceController.prototype.returnsTheUpdatedStatusesForAParticularCustomerNumber = function (customernumber, period, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
customernumber: [customernumber, (0, schema_1.string)()],
period: [period, (0, schema_1.optional)((0, schema_1.array)((0, schema_1.string)()))]
});
req.query('period', mapped.period);
req.appendTemplatePath(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["/shipment/v2/status/", "/updatedshipments"], ["/shipment/v2/status/", "/updatedshipments"])), mapped.customernumber);
req.throwOn(400, shippingstatusResponseError_1.ShippingstatusResponseError, 'Invalid request');
req.throwOn(401, shippingstatusUnauthorizedError_1.ShippingstatusUnauthorizedError, 'Invalid apikey');
req.throwOn(405, shippingstatusMethodNotAllowedError_1.ShippingstatusMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, shippingstatusTooManyRequestError_1.ShippingstatusTooManyRequestError, 'Too many requests');
req.throwOn(500, shippingstatusResponseError_1.ShippingstatusResponseError, 'Internal server error');
return [2 /*return*/, req.callAsJson((0, schema_1.array)(shippingstatusResponseUpdatedShipment_1.shippingstatusResponseUpdatedShipmentSchema), requestOptions)];
});
});
};
return TrackTraceController;
}(baseController_1.BaseController));
exports.TrackTraceController = TrackTraceController;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
//# sourceMappingURL=trackTraceController.js.map