UNPKG

sdksio-postnl-ecommerce-apis-sdk

Version:

Collection of PostNL API's for ecommerce processes

75 lines 4.37 kB
"use strict"; /** * PostNL Ecommerce APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ exports.__esModule = true; exports.BarcodeController = void 0; var tslib_1 = require("tslib"); var barcodeMethodNotAllowedError_1 = require("../errors/barcodeMethodNotAllowedError"); var barcodeResponseError_1 = require("../errors/barcodeResponseError"); var barcodeResponseInvalidError_1 = require("../errors/barcodeResponseInvalidError"); var barcodeTooManyRequestError_1 = require("../errors/barcodeTooManyRequestError"); var barcodeResponse_1 = require("../models/barcodeResponse"); var type1Enum_1 = require("../models/type1Enum"); var schema_1 = require("../schema"); var baseController_1 = require("./baseController"); var BarcodeController = /** @class */ (function (_super) { tslib_1.__extends(BarcodeController, _super); function BarcodeController() { return _super !== null && _super.apply(this, arguments) || this; } /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v1_1/barcode?CustomerCode=DEVC& * CustomerNumber=11223344&Type=3S&Serie=000000000-999999999&Range=NL" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" * ``` * * * @param customerCode The customer code for which you want a barcode to be generated * @param customerNumber The customer code for which you want a barcode to be generated * @param type The barcode type that you want to be generated * @param serie Barcode serie in the format '###000000-###000000', for example 100000-20000. * The range must consist of a minimal difference of 100.000. It is allowed to add * extra leading zeros at the beginning of the serie. See [Guidelines](https: * //developer.postnl.nl/browse-apis/send-and-track/barcode-webservice/) for more * information. * @param range Only used for International Mail and Packet products (PEPS) shipments (with * type LA, RI, UE). Identifying the issuing postal administration's country (NL * in this case). * @return Response from the API call */ BarcodeController.prototype.generateAUniqueBarcode = function (customerCode, customerNumber, type, serie, range, 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/v1_1/barcode'); mapped = req.prepareArgs({ customerCode: [customerCode, (0, schema_1.string)()], customerNumber: [customerNumber, (0, schema_1.string)()], type: [type, type1Enum_1.type1EnumSchema], serie: [serie, (0, schema_1.optional)((0, schema_1.string)())], range: [range, (0, schema_1.optional)((0, schema_1.string)())] }); req.query('CustomerCode', mapped.customerCode); req.query('CustomerNumber', mapped.customerNumber); req.query('Type', mapped.type); req.query('Serie', mapped.serie); req.query('Range', mapped.range); req.throwOn(400, barcodeResponseInvalidError_1.BarcodeResponseInvalidError, 'Invalid request'); req.throwOn(401, barcodeResponseError_1.BarcodeResponseError, 'Unauthorized'); req.throwOn(405, barcodeMethodNotAllowedError_1.BarcodeMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, barcodeTooManyRequestError_1.BarcodeTooManyRequestError, 'Too many requests'); req.throwOn(500, barcodeResponseError_1.BarcodeResponseError, 'Internal server error'); return [2 /*return*/, req.callAsJson(barcodeResponse_1.barcodeResponseSchema, requestOptions)]; }); }); }; return BarcodeController; }(baseController_1.BaseController)); exports.BarcodeController = BarcodeController; //# sourceMappingURL=barcodeController.js.map