sdksio-postnl-ecommerce-apis-sdk
Version:
Collection of PostNL API's for ecommerce processes
34 lines • 1.8 kB
JavaScript
/**
* PostNL Ecommerce APIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
import { CheckoutResponseError } from '../errors/checkoutResponseError';
import { CheckoutResponseInvalidError, } from '../errors/checkoutResponseInvalidError';
import { PostCIFCheckoutServiceMethodNotAllowedError, } from '../errors/postCIFCheckoutServiceMethodNotAllowedError';
import { PostCIFCheckoutServiceTooManyRequestError, } from '../errors/postCIFCheckoutServiceTooManyRequestError';
import { PostCIFCheckoutServiceUnauthorizedError, } from '../errors/postCIFCheckoutServiceUnauthorizedError';
import { checkoutRequestSchema, } from '../models/checkoutRequest';
import { checkoutResponseSchema, } from '../models/checkoutResponse';
import { BaseController } from './baseController';
export class CheckoutController extends BaseController {
/**
* Checkout
*
* @param body
* @return Response from the API call
*/
async checkout(body, requestOptions) {
const req = this.createRequest('POST', '/shipment/v1/checkout');
const mapped = req.prepareArgs({ body: [body, checkoutRequestSchema] });
req.header('Content-Type', 'application/json');
req.json(mapped.body);
req.throwOn(400, CheckoutResponseInvalidError, 'Invalid request');
req.throwOn(401, PostCIFCheckoutServiceUnauthorizedError, 'Invalid apikey');
req.throwOn(405, PostCIFCheckoutServiceMethodNotAllowedError, 'Method not allowed');
req.throwOn(429, PostCIFCheckoutServiceTooManyRequestError, 'Too many requests');
req.throwOn(500, CheckoutResponseError, 'Internal server error');
return req.callAsJson(checkoutResponseSchema, requestOptions);
}
}
//# sourceMappingURL=checkoutController.js.map