sdksio-postnl-ecommerce-apis-sdk
Version:
Collection of PostNL API's for ecommerce processes
92 lines • 5.74 kB
JavaScript
;
/**
* PostNL Ecommerce APIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.TimeframesController = void 0;
var tslib_1 = require("tslib");
var postCIFTimeframeMethodNotAllowedError_1 = require("../errors/postCIFTimeframeMethodNotAllowedError");
var postCIFTimeframeTooManyRequestError_1 = require("../errors/postCIFTimeframeTooManyRequestError");
var postCIFTimeframeUnauthorizedError_1 = require("../errors/postCIFTimeframeUnauthorizedError");
var timeframeResponseError_1 = require("../errors/timeframeResponseError");
var timeframeResponseInvalidError_1 = require("../errors/timeframeResponseInvalidError");
var countryCode1Enum_1 = require("../models/countryCode1Enum");
var options1Enum_1 = require("../models/options1Enum");
var timeframeResponse_1 = require("../models/timeframeResponse");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var TimeframesController = /** @class */ (function (_super) {
tslib_1.__extends(TimeframesController, _super);
function TimeframesController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Request example:
* ```
* curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_1/calculate/timeframes?
* AllowSundaySorting=false&StartDate=30-06-2022&EndDate=02-07-
* 2022&CountryCode=NL&PostalCode=2132WT&HouseNumber=42&HouseNrExt=A&City=Hoofddorp&Street=Siriusdreef&
* Options=Daytime%2CEvening" \
* -H "Accept: application/json" \
* -H "apikey: APIKEY-HERE" \
* ```
*
*
* @param allowSundaySorting Whether or not the requesting party allows for Sunday sorting
* (which leads to delivery on Monday).
* @param startDate Date of the beginning of the timeframe. Format: dd-MM-yyyy
* @param endDate Date of the enddate of the timeframe. Format:dd-MM-yyyy. Enddate
* may not be before StartDate.
* @param countryCode The ISO2 country code of the delivery address
* @param postalCode Zipcode of the delivery address
* @param houseNumber The house number of the delivery address
* @param options The delivery options for which expected timeframes should be
* calculated. At least one delivery option must be specified. Multiple
* values should be comma-separated.
* @param houseNrExt House number extension of the delivery address
* @param city City of the delivery address
* @param street The street name of the delivery address
* @return Response from the API call
*/
TimeframesController.prototype.retrieveExpectedDeliveryTimeframes = function (allowSundaySorting, startDate, endDate, countryCode, postalCode, houseNumber, options, houseNrExt, city, street, 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', '/shipment/v2_1/calculate/timeframes');
mapped = req.prepareArgs({
allowSundaySorting: [allowSundaySorting, (0, schema_1.boolean)()],
startDate: [startDate, (0, schema_1.string)()],
endDate: [endDate, (0, schema_1.string)()],
countryCode: [countryCode, countryCode1Enum_1.countryCode1EnumSchema],
postalCode: [postalCode, (0, schema_1.string)()],
houseNumber: [houseNumber, (0, schema_1.number)()],
options: [options, (0, schema_1.array)(options1Enum_1.options1EnumSchema)],
houseNrExt: [houseNrExt, (0, schema_1.optional)((0, schema_1.string)())],
city: [city, (0, schema_1.optional)((0, schema_1.string)())],
street: [street, (0, schema_1.optional)((0, schema_1.string)())]
});
req.query('AllowSundaySorting', mapped.allowSundaySorting);
req.query('StartDate', mapped.startDate);
req.query('EndDate', mapped.endDate);
req.query('CountryCode', mapped.countryCode);
req.query('PostalCode', mapped.postalCode);
req.query('HouseNumber', mapped.houseNumber);
req.query('Options', mapped.options);
req.query('HouseNrExt', mapped.houseNrExt);
req.query('City', mapped.city);
req.query('Street', mapped.street);
req.throwOn(400, timeframeResponseInvalidError_1.TimeframeResponseInvalidError, 'Invalid request');
req.throwOn(401, postCIFTimeframeUnauthorizedError_1.PostCIFTimeframeUnauthorizedError, 'Unauthorized');
req.throwOn(405, postCIFTimeframeMethodNotAllowedError_1.PostCIFTimeframeMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, postCIFTimeframeTooManyRequestError_1.PostCIFTimeframeTooManyRequestError, 'Too many requests');
req.throwOn(500, timeframeResponseError_1.TimeframeResponseError, 'Invalid request');
return [2 /*return*/, req.callAsJson(timeframeResponse_1.timeframeResponseSchema, requestOptions)];
});
});
};
return TimeframesController;
}(baseController_1.BaseController));
exports.TimeframesController = TimeframesController;
//# sourceMappingURL=timeframesController.js.map