sdksio-postnl-ecommerce-apis-sdk
Version:
Collection of PostNL API's for ecommerce processes
44 lines • 2.43 kB
JavaScript
/**
* PostNL Ecommerce APIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
import { LabellingMethodNotAllowedError, } from '../errors/labellingMethodNotAllowedError';
import { LabellingResponseError } from '../errors/labellingResponseError';
import { LabellingResponseInvalidError, } from '../errors/labellingResponseInvalidError';
import { LabellingTooManyRequestError, } from '../errors/labellingTooManyRequestError';
import { LabellingUnauthorizedError, } from '../errors/labellingUnauthorizedError';
import { labellingRequestSchema, } from '../models/labellingRequest';
import { labellingResponseSchema, } from '../models/labellingResponse';
import { boolean, optional } from '../schema';
import { BaseController } from './baseController';
export class LabellingController extends BaseController {
/**
* 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
*/
async generateALabelAndConfirmation(body, confirm, requestOptions) {
const req = this.createRequest('POST', '/shipment/v2_2/label');
const mapped = req.prepareArgs({
body: [body, labellingRequestSchema],
confirm: [confirm, optional(boolean())],
});
req.header('Content-Type', 'application/json');
req.query('confirm', mapped.confirm);
req.json(mapped.body);
req.throwOn(400, LabellingResponseInvalidError, 'Error payload');
req.throwOn(401, LabellingUnauthorizedError, 'Invalid apikey');
req.throwOn(405, LabellingMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, LabellingTooManyRequestError, 'Too many requests');
req.throwOn(500, LabellingResponseError, 'Internal server error');
return req.callAsJson(labellingResponseSchema, requestOptions);
}
}
//# sourceMappingURL=labellingController.js.map