sdksio-postnl-ecommerce-apis-sdk
Version:
Collection of PostNL API's for ecommerce processes
59 lines • 3.37 kB
JavaScript
;
/**
* PostNL Ecommerce APIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.LabellingController = void 0;
var tslib_1 = require("tslib");
var labellingMethodNotAllowedError_1 = require("../errors/labellingMethodNotAllowedError");
var labellingResponseError_1 = require("../errors/labellingResponseError");
var labellingResponseInvalidError_1 = require("../errors/labellingResponseInvalidError");
var labellingTooManyRequestError_1 = require("../errors/labellingTooManyRequestError");
var labellingUnauthorizedError_1 = require("../errors/labellingUnauthorizedError");
var labellingRequest_1 = require("../models/labellingRequest");
var labellingResponse_1 = require("../models/labellingResponse");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var LabellingController = /** @class */ (function (_super) {
tslib_1.__extends(LabellingController, _super);
function LabellingController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Generate a label and confirmation
*
* @param body
* @param confirm With the Confirm boolean in the request, you can determine if you
* want to confirm the shipment in the same call or not. If the
* Boolean variable is true the shipment will be preannounced. If this
* is set to false, then an additional Confirming API request needs to
* be made.
* @return Response from the API call
*/
LabellingController.prototype.generateALabelAndConfirmation = function (body, confirm, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('POST', '/shipment/v2_2/label');
mapped = req.prepareArgs({
body: [body, labellingRequest_1.labellingRequestSchema],
confirm: [confirm, (0, schema_1.optional)((0, schema_1.boolean)())]
});
req.header('Content-Type', 'application/json');
req.query('confirm', mapped.confirm);
req.json(mapped.body);
req.throwOn(400, labellingResponseInvalidError_1.LabellingResponseInvalidError, 'Error payload');
req.throwOn(401, labellingUnauthorizedError_1.LabellingUnauthorizedError, 'Invalid apikey');
req.throwOn(405, labellingMethodNotAllowedError_1.LabellingMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, labellingTooManyRequestError_1.LabellingTooManyRequestError, 'Too many requests');
req.throwOn(500, labellingResponseError_1.LabellingResponseError, 'Internal server error');
return [2 /*return*/, req.callAsJson(labellingResponse_1.labellingResponseSchema, requestOptions)];
});
});
};
return LabellingController;
}(baseController_1.BaseController));
exports.LabellingController = LabellingController;
//# sourceMappingURL=labellingController.js.map