UNPKG

sdksio-postnl-ecommerce-apis-sdk

Version:

Collection of PostNL API's for ecommerce processes

247 lines 16.5 kB
"use strict"; /** * PostNL Ecommerce APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ exports.__esModule = true; exports.LocationsController = void 0; var tslib_1 = require("tslib"); var locationsResponseError_1 = require("../errors/locationsResponseError"); var locationsResponseInvalidError_1 = require("../errors/locationsResponseInvalidError"); var postCIFLocationMethodNotAllowedError_1 = require("../errors/postCIFLocationMethodNotAllowedError"); var postCIFLocationTooManyRequestError_1 = require("../errors/postCIFLocationTooManyRequestError"); var postCIFLocationUnauthorizedError_1 = require("../errors/postCIFLocationUnauthorizedError"); var countryCode1Enum_1 = require("../models/countryCode1Enum"); var deliveryOption1Enum_1 = require("../models/deliveryOption1Enum"); var deliveryOptions1Enum_1 = require("../models/deliveryOptions1Enum"); var locationResponse_1 = require("../models/locationResponse"); var locationsResponse_1 = require("../models/locationsResponse"); var schema_1 = require("../schema"); var baseController_1 = require("./baseController"); var LocationsController = /** @class */ (function (_super) { tslib_1.__extends(LocationsController, _super); function LocationsController() { return _super !== null && _super.apply(this, arguments) || this; } /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_1/locations/nearest? * CountryCode=NL&PostalCode=2132WT&City=Hoofddorp&Street=Siriusdreef&HouseNumber=42&HouseNumberExtensi * on=-60&DeliveryDate=24-12-2022&OpeningTime=09%3A00%3A00" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" \ * ``` * * * @param countryCode The country of the recipient's address * @param postalCode The zipcode of the recipient's address * @param city The city of the recipient's address * @param street The street name of the recipient's address * @param houseNumber The house number of the recipient's address * @param houseNumberExtension The house number extension of the recipient's address * @param deliveryDate The date of the earliest delivery date at the pickup * location. Format: dd-MM-yyyy. Note: this date cannot be in * the past, otherwise an error is returned. If not provided, * the present day is used as a default * @param openingTime Opening time filter. Format: hh:mm:ss. This field will be * used to filter out locations that are closed at the time * provided. If no opening time is provided all locations will * be returned regardless of their opening times. * @param deliveryOptions The pickup location types for which locations should be * filtered. By default all location types are returned (PG = * Retail points and parcel lockers). This can be used to filter * on only parcel lockers (PA) or specifically exclude parcel * lockers from the response (PG_EX). * @return Response from the API call */ LocationsController.prototype.returnsPickupLocationsNearestToTheProvidedAddress = function (countryCode, postalCode, city, street, houseNumber, houseNumberExtension, deliveryDate, openingTime, deliveryOptions, 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_1/locations/nearest'); mapped = req.prepareArgs({ countryCode: [countryCode, countryCode1Enum_1.countryCode1EnumSchema], postalCode: [postalCode, (0, schema_1.string)()], 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)())], houseNumberExtension: [houseNumberExtension, (0, schema_1.optional)((0, schema_1.string)())], deliveryDate: [deliveryDate, (0, schema_1.optional)((0, schema_1.string)())], openingTime: [openingTime, (0, schema_1.optional)((0, schema_1.string)())], deliveryOptions: [ deliveryOptions, (0, schema_1.optional)((0, schema_1.array)(deliveryOption1Enum_1.deliveryOption1EnumSchema)), ] }); req.query('CountryCode', mapped.countryCode); req.query('PostalCode', mapped.postalCode); req.query('City', mapped.city); req.query('Street', mapped.street); req.query('HouseNumber', mapped.houseNumber); req.query('HouseNumberExtension', mapped.houseNumberExtension); req.query('DeliveryDate', mapped.deliveryDate); req.query('OpeningTime', mapped.openingTime); req.query('DeliveryOptions', mapped.deliveryOptions); req.throwOn(400, locationsResponseInvalidError_1.LocationsResponseInvalidError, 'Invalid request'); req.throwOn(401, postCIFLocationUnauthorizedError_1.PostCIFLocationUnauthorizedError, 'Unauthorized'); req.throwOn(405, postCIFLocationMethodNotAllowedError_1.PostCIFLocationMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, postCIFLocationTooManyRequestError_1.PostCIFLocationTooManyRequestError, 'Too many requests'); req.throwOn(500, locationsResponseError_1.LocationsResponseError, 'Internal server error'); return [2 /*return*/, req.callAsJson(locationsResponse_1.locationsResponseSchema, requestOptions)]; }); }); }; /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_1/locations/nearest/geocode?Latitude=52. * 2864669620795&Longitude=4.68239055845954&CountryCode=NL&DeliveryDate=24-12- * 2022&OpeningTime=09%3A00%3A00" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" \ * ``` * * * @param latitude The latitude of the location * @param longitude The longitude of the location * @param countryCode The coutry for which the coordinates are provided * @param deliveryDate The date of the earliest delivery date. Format: dd-MM-yyyy. * Note: this date cannot be in the past, otherwise an error is * returned. * @param openingTime Opening time filter. Format: hh:mm:ss. This field will be used * to filter out locations that are closed at the time provided. * @param deliveryOptions The pickup location types for which locations should be filtered. * By default all location types are returned (PG = Retail points * and parcel lockers). This can be used to filter on only parcel * lockers (PA) or specifically exclude parcel lockers from the * response (PG_EX). * @return Response from the API call */ LocationsController.prototype.returnsPickupLocationsNearestToTheProvidedCoordinates = function (latitude, longitude, countryCode, deliveryDate, openingTime, deliveryOptions, 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_1/locations/nearest/geocode'); mapped = req.prepareArgs({ latitude: [latitude, (0, schema_1.number)()], longitude: [longitude, (0, schema_1.number)()], countryCode: [countryCode, countryCode1Enum_1.countryCode1EnumSchema], deliveryDate: [deliveryDate, (0, schema_1.optional)((0, schema_1.string)())], openingTime: [openingTime, (0, schema_1.optional)((0, schema_1.string)())], deliveryOptions: [ deliveryOptions, (0, schema_1.optional)((0, schema_1.array)(deliveryOptions1Enum_1.deliveryOptions1EnumSchema)), ] }); req.query('Latitude', mapped.latitude); req.query('Longitude', mapped.longitude); req.query('CountryCode', mapped.countryCode); req.query('DeliveryDate', mapped.deliveryDate); req.query('OpeningTime', mapped.openingTime); req.query('DeliveryOptions', mapped.deliveryOptions); req.throwOn(400, locationsResponseInvalidError_1.LocationsResponseInvalidError, 'Invalid request'); req.throwOn(401, postCIFLocationUnauthorizedError_1.PostCIFLocationUnauthorizedError, 'Unauthorized'); req.throwOn(405, postCIFLocationMethodNotAllowedError_1.PostCIFLocationMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, postCIFLocationTooManyRequestError_1.PostCIFLocationTooManyRequestError, 'Too many requests'); req.throwOn(500, locationsResponseError_1.LocationsResponseError, 'Internal server error'); return [2 /*return*/, req.callAsJson(locationsResponse_1.locationsResponseSchema, requestOptions)]; }); }); }; /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_1/locations/area?LatitudeNorth=52. * 156439&LongitudeWest=5.015643&LatitudeSouth=52.017473&LongitudeEast=5. * 065254&CountryCode=NL&DeliveryDate=24-12-2023&OpeningTime=09%3A00%3A00" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" \ * ``` * * * @param latitudeNorth The northmost coordinates of the area * @param longitudeWest The westmost coordinates of the area * @param latitudeSouth The southmost coordinates of the area * @param longitudeEast The eastmost coordinates of the area * @param countryCode * @param deliveryDate The date of the earliest delivery date. Format: dd-MM-yyyy. * Note: this date cannot be in the past, otherwise an error is * returned. * @param openingTime Opening time filter. Format: hh:mm:ss. This field will be used * to filter out locations that are closed at the time provided. * @param deliveryOptions The pickup location types for which locations should be filtered. * By default all location types are returned (PG = Retail points * and parcel lockers). This can be used to filter on only parcel * lockers (PA) or specifically exclude parcel lockers from the * response (PG_EX). * @return Response from the API call */ LocationsController.prototype.returnsPickupLocationsWithinAProvidedArea = function (latitudeNorth, longitudeWest, latitudeSouth, longitudeEast, countryCode, deliveryDate, openingTime, deliveryOptions, 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_1/locations/area'); mapped = req.prepareArgs({ latitudeNorth: [latitudeNorth, (0, schema_1.number)()], longitudeWest: [longitudeWest, (0, schema_1.number)()], latitudeSouth: [latitudeSouth, (0, schema_1.number)()], longitudeEast: [longitudeEast, (0, schema_1.number)()], countryCode: [countryCode, countryCode1Enum_1.countryCode1EnumSchema], deliveryDate: [deliveryDate, (0, schema_1.optional)((0, schema_1.string)())], openingTime: [openingTime, (0, schema_1.optional)((0, schema_1.string)())], deliveryOptions: [ deliveryOptions, (0, schema_1.optional)((0, schema_1.array)(deliveryOptions1Enum_1.deliveryOptions1EnumSchema)), ] }); req.query('LatitudeNorth', mapped.latitudeNorth); req.query('LongitudeWest', mapped.longitudeWest); req.query('LatitudeSouth', mapped.latitudeSouth); req.query('LongitudeEast', mapped.longitudeEast); req.query('CountryCode', mapped.countryCode); req.query('DeliveryDate', mapped.deliveryDate); req.query('OpeningTime', mapped.openingTime); req.query('DeliveryOptions', mapped.deliveryOptions); req.throwOn(400, locationsResponseInvalidError_1.LocationsResponseInvalidError, 'Invalid request'); req.throwOn(401, postCIFLocationUnauthorizedError_1.PostCIFLocationUnauthorizedError, 'Unauthorized'); req.throwOn(405, postCIFLocationMethodNotAllowedError_1.PostCIFLocationMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, postCIFLocationTooManyRequestError_1.PostCIFLocationTooManyRequestError, 'Too many requests'); req.throwOn(500, locationsResponseError_1.LocationsResponseError, 'Internal server error'); return [2 /*return*/, req.callAsJson(locationsResponse_1.locationsResponseSchema, requestOptions)]; }); }); }; /** * Request example: * ``` * curl -X GET "https://api-sandbox.postnl.nl/shipment/v2_1/locations/lookup?LocationCode=216877" \ * -H "Accept: application/json" \ * -H "apikey: APIKEY-HERE" * ``` * * * @param locationCode LocationCode information * @return Response from the API call */ LocationsController.prototype.returnsASpecificPickupLocation = function (locationCode, 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_1/locations/lookup'); mapped = req.prepareArgs({ locationCode: [locationCode, (0, schema_1.string)()] }); req.query('LocationCode', mapped.locationCode); req.throwOn(400, locationsResponseInvalidError_1.LocationsResponseInvalidError, 'Invalid request'); req.throwOn(401, postCIFLocationUnauthorizedError_1.PostCIFLocationUnauthorizedError, 'Unauthorized'); req.throwOn(405, postCIFLocationMethodNotAllowedError_1.PostCIFLocationMethodNotAllowedError, 'Method not allowed'); req.throwOn(429, postCIFLocationTooManyRequestError_1.PostCIFLocationTooManyRequestError, 'Too many requests'); req.throwOn(500, locationsResponseError_1.LocationsResponseError, 'Invalid request'); return [2 /*return*/, req.callAsJson(locationResponse_1.locationResponseSchema, requestOptions)]; }); }); }; return LocationsController; }(baseController_1.BaseController)); exports.LocationsController = LocationsController; //# sourceMappingURL=locationsController.js.map