UNPKG

sdksio-postnl-ecommerce-apis-sdk

Version:

Collection of PostNL API's for ecommerce processes

218 lines 16.1 kB
"use strict"; /** * PostNL Ecommerce APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ exports.__esModule = true; exports.DeliverydateController = void 0; var tslib_1 = require("tslib"); var deliverydateResponseError_1 = require("../errors/deliverydateResponseError"); var deliverydateResponseInvalidError_1 = require("../errors/deliverydateResponseInvalidError"); var postCIFDeliveryDateMethodNotAllowedError_1 = require("../errors/postCIFDeliveryDateMethodNotAllowedError"); var postCIFDeliveryDateTooManyRequestError_1 = require("../errors/postCIFDeliveryDateTooManyRequestError"); var postCIFDeliveryDateUnauthorizedError_1 = require("../errors/postCIFDeliveryDateUnauthorizedError"); var countryCode1Enum_1 = require("../models/countryCode1Enum"); var option3Enum_1 = require("../models/option3Enum"); var originCountryCodeEnum_1 = require("../models/originCountryCodeEnum"); var shipmentV22CalculateDateDeliveryResponse_1 = require("../models/shipmentV22CalculateDateDeliveryResponse"); var shipmentV22CalculateDateShippingResponse_1 = require("../models/shipmentV22CalculateDateShippingResponse"); var schema_1 = require("../schema"); var baseController_1 = require("./baseController"); var DeliverydateController = /** @class */ (function (_super) { tslib_1.__extends(DeliverydateController, _super); function DeliverydateController() { return _super !== null && _super.apply(this, arguments) || this; } /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_2/calculate/date/delivery?ShippingDate=29-05- * 2022+14%3A00%3A00&ShippingDuration=1&CutOffTime=17%3A00%3A00&PostalCode=2132WT& * CountryCode=NL&City=Hoofddorp&Street=Siriusdreef&HouseNumber=42&HouseNrExt=A" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" * ``` * * * @param shippingDate Date/time of preparing the shipment for sending. Format: dd- * MM-yyyy hh:mm:ss * @param shippingDuration The duration it takes for the shipment to be delivered to * PostNL in days. A value of 1 means that the parcel will be * delivered to PostNL on the same day as the date specified in * ShippingDate. A value of 2 means the parcel will arrive at * PostNL a day later etc. * @param cutOffTime Default cutoff time * @param postalCode Zipcode of the destination address * @param countryCode The ISO2 destination country code * @param options The delivery options that you want to take into account when * calculating the expected delivery date * @param originCountryCode The ISO2 origin country code * @param city City of the destination address * @param street The street name of the destination address. * @param houseNumber The house number of the destination address * @param houseNrExt House number extension of the delivery address * @param cutOffTimeMonday Overrides default cutoff time specified in the CutOffTime * parameter for mondays specifically * @param availableMonday Specifies if you are available to ship to PostNL on mondays * @param cutOffTimeTuesday Overrides default cutoff time specified in the CutOffTime * parameter for tuesdays specifically * @param availableTuesday Specifies if you are available to ship to PostNL on tuesdays * @param cutOffTimeWednesday Overrides default cutoff time specified in the CutOffTime * parameter for wednesdays specifically * @param availableWednesday Specifies if you are available to ship to PostNL on * wednesdays * @param cutOffTimeThursday Overrides default cutoff time specified in the CutOffTime * parameter for thursdays specifically * @param availableThursday Specifies if you are available to ship to PostNL on * thursdays * @param cutOffTimeFriday Overrides default cutoff time specified in the CutOffTime * parameter for fridays specifically * @param availableFriday Specifies if you are available to ship to PostNL on fridays * @param cutOffTimeSaturday Overrides default cutoff time specified in the CutOffTime * parameter for saturdays specifically * @param availableSaturday Specifies if you are available to ship to PostNL on * saturdays * @param cutOffTimeSunday Overrides default cutoff time specified in the CutOffTime * parameter for sundays specifically * @param availableSunday Specifies if you are available to ship to PostNL on sundays * @return Response from the API call */ DeliverydateController.prototype.calculateExpectedDeliveryDate = function (shippingDate, shippingDuration, cutOffTime, postalCode, countryCode, options, originCountryCode, city, street, houseNumber, houseNrExt, cutOffTimeMonday, availableMonday, cutOffTimeTuesday, availableTuesday, cutOffTimeWednesday, availableWednesday, cutOffTimeThursday, availableThursday, cutOffTimeFriday, availableFriday, cutOffTimeSaturday, availableSaturday, cutOffTimeSunday, availableSunday, 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_2/calculate/date/delivery'); mapped = req.prepareArgs({ shippingDate: [shippingDate, (0, schema_1.string)()], shippingDuration: [shippingDuration, (0, schema_1.number)()], cutOffTime: [cutOffTime, (0, schema_1.string)()], postalCode: [postalCode, (0, schema_1.string)()], countryCode: [countryCode, countryCode1Enum_1.countryCode1EnumSchema], options: [options, (0, schema_1.array)(option3Enum_1.option3EnumSchema)], originCountryCode: [ originCountryCode, (0, schema_1.optional)(originCountryCodeEnum_1.originCountryCodeEnumSchema), ], city: [city, (0, schema_1.optional)((0, schema_1.string)())], street: [street, (0, schema_1.optional)((0, schema_1.string)())], houseNumber: [houseNumber, (0, schema_1.optional)((0, schema_1.number)())], houseNrExt: [houseNrExt, (0, schema_1.optional)((0, schema_1.string)())], cutOffTimeMonday: [cutOffTimeMonday, (0, schema_1.optional)((0, schema_1.string)())], availableMonday: [availableMonday, (0, schema_1.optional)((0, schema_1.boolean)())], cutOffTimeTuesday: [cutOffTimeTuesday, (0, schema_1.optional)((0, schema_1.string)())], availableTuesday: [availableTuesday, (0, schema_1.optional)((0, schema_1.boolean)())], cutOffTimeWednesday: [cutOffTimeWednesday, (0, schema_1.optional)((0, schema_1.string)())], availableWednesday: [availableWednesday, (0, schema_1.optional)((0, schema_1.boolean)())], cutOffTimeThursday: [cutOffTimeThursday, (0, schema_1.optional)((0, schema_1.string)())], availableThursday: [availableThursday, (0, schema_1.optional)((0, schema_1.boolean)())], cutOffTimeFriday: [cutOffTimeFriday, (0, schema_1.optional)((0, schema_1.string)())], availableFriday: [availableFriday, (0, schema_1.optional)((0, schema_1.boolean)())], cutOffTimeSaturday: [cutOffTimeSaturday, (0, schema_1.optional)((0, schema_1.string)())], availableSaturday: [availableSaturday, (0, schema_1.optional)((0, schema_1.boolean)())], cutOffTimeSunday: [cutOffTimeSunday, (0, schema_1.optional)((0, schema_1.string)())], availableSunday: [availableSunday, (0, schema_1.optional)((0, schema_1.boolean)())] }); req.query('ShippingDate', mapped.shippingDate); req.query('ShippingDuration', mapped.shippingDuration); req.query('CutOffTime', mapped.cutOffTime); req.query('PostalCode', mapped.postalCode); req.query('CountryCode', mapped.countryCode); req.query('Options', mapped.options); req.query('OriginCountryCode', mapped.originCountryCode); req.query('City', mapped.city); req.query('Street', mapped.street); req.query('HouseNumber', mapped.houseNumber); req.query('HouseNrExt', mapped.houseNrExt); req.query('CutOffTimeMonday', mapped.cutOffTimeMonday); req.query('AvailableMonday', mapped.availableMonday); req.query('CutOffTimeTuesday', mapped.cutOffTimeTuesday); req.query('AvailableTuesday', mapped.availableTuesday); req.query('CutOffTimeWednesday', mapped.cutOffTimeWednesday); req.query('AvailableWednesday', mapped.availableWednesday); req.query('CutOffTimeThursday', mapped.cutOffTimeThursday); req.query('AvailableThursday', mapped.availableThursday); req.query('CutOffTimeFriday', mapped.cutOffTimeFriday); req.query('AvailableFriday', mapped.availableFriday); req.query('CutOffTimeSaturday', mapped.cutOffTimeSaturday); req.query('AvailableSaturday', mapped.availableSaturday); req.query('CutOffTimeSunday', mapped.cutOffTimeSunday); req.query('AvailableSunday', mapped.availableSunday); req.throwOn(400, deliverydateResponseInvalidError_1.DeliverydateResponseInvalidError, 'Bad request'); req.throwOn(401, postCIFDeliveryDateUnauthorizedError_1.PostCIFDeliveryDateUnauthorizedError, 'Invalid apikey'); req.throwOn(405, postCIFDeliveryDateMethodNotAllowedError_1.PostCIFDeliveryDateMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, postCIFDeliveryDateTooManyRequestError_1.PostCIFDeliveryDateTooManyRequestError, 'Too many requests'); req.throwOn(500, deliverydateResponseError_1.DeliverydateResponseError, 'Internal server error'); return [2 /*return*/, req.callAsJson(shipmentV22CalculateDateDeliveryResponse_1.shipmentV22CalculateDateDeliveryResponseSchema, requestOptions)]; }); }); }; /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_2/calculate/date/shipping?DeliveryDate=30-05- * 2022&ShippingDuration=1&PostalCode=2132WT&CountryCode=NL&City=Hoofddorp& * Street=Siriusdreef&HouseNumber=42&HouseNrExt=A" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" \ * * ``` * * * @param deliveryDate Date of the expected delivery (to the final destination) of the * shipment. * @param shippingDuration The duration it takes for the shipment to be delivered to * PostNL in days. A value of 1 means that the parcel will be * delivered to PostNL on the same day as the date specified in * ShippingDate. A value of 2 means the parcel will arrive at * PostNL a day later etc. * @param postalCode Zipcode of the address * @param countryCode The ISO2 destination country code * @param originCountryCode The ISO2 country code of the origin country * @param city City of the destination address * @param street The street name of the destination address * @param houseNumber The house number of the destination address * @param houseNrExt House number extension of the destination address * @return Response from the API call */ DeliverydateController.prototype.calculateRequiredShippingDate = function (deliveryDate, shippingDuration, postalCode, countryCode, originCountryCode, city, street, houseNumber, houseNrExt, 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_2/calculate/date/shipping'); mapped = req.prepareArgs({ deliveryDate: [deliveryDate, (0, schema_1.string)()], shippingDuration: [shippingDuration, (0, schema_1.number)()], postalCode: [postalCode, (0, schema_1.string)()], countryCode: [countryCode, countryCode1Enum_1.countryCode1EnumSchema], originCountryCode: [ originCountryCode, (0, schema_1.optional)(originCountryCodeEnum_1.originCountryCodeEnumSchema), ], city: [city, (0, schema_1.optional)((0, schema_1.string)())], street: [street, (0, schema_1.optional)((0, schema_1.string)())], houseNumber: [houseNumber, (0, schema_1.optional)((0, schema_1.number)())], houseNrExt: [houseNrExt, (0, schema_1.optional)((0, schema_1.string)())] }); req.query('DeliveryDate', mapped.deliveryDate); req.query('ShippingDuration', mapped.shippingDuration); req.query('PostalCode', mapped.postalCode); req.query('CountryCode', mapped.countryCode); req.query('OriginCountryCode', mapped.originCountryCode); req.query('City', mapped.city); req.query('Street', mapped.street); req.query('HouseNumber', mapped.houseNumber); req.query('HouseNrExt', mapped.houseNrExt); req.throwOn(400, deliverydateResponseInvalidError_1.DeliverydateResponseInvalidError, 'Bad request'); req.throwOn(401, postCIFDeliveryDateUnauthorizedError_1.PostCIFDeliveryDateUnauthorizedError, 'Invalid apikey'); req.throwOn(405, postCIFDeliveryDateMethodNotAllowedError_1.PostCIFDeliveryDateMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, postCIFDeliveryDateTooManyRequestError_1.PostCIFDeliveryDateTooManyRequestError, 'Too many requests'); req.throwOn(500, deliverydateResponseError_1.DeliverydateResponseError, 'Internal server error'); return [2 /*return*/, req.callAsJson(shipmentV22CalculateDateShippingResponse_1.shipmentV22CalculateDateShippingResponseSchema, requestOptions)]; }); }); }; return DeliverydateController; }(baseController_1.BaseController)); exports.DeliverydateController = DeliverydateController; //# sourceMappingURL=deliverydateController.js.map