UNPKG

dhl-express-api-client

Version:
171 lines 11.9 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.IdentifierApiResponseProcessor = exports.IdentifierApiRequestFactory = void 0; var baseapi_1 = require("./baseapi"); var http_1 = require("../http/http"); var ObjectSerializer_1 = require("../models/ObjectSerializer"); var exception_1 = require("./exception"); var util_1 = require("../util"); var IdentifierApiRequestFactory = (function (_super) { __extends(IdentifierApiRequestFactory, _super); function IdentifierApiRequestFactory() { return _super !== null && _super.apply(this, arguments) || this; } IdentifierApiRequestFactory.prototype.expApiIdentifiers = function (accountNumber, type, size, messageReference, messageReferenceDate, pluginName, pluginVersion, shippingSystemPlatformName, shippingSystemPlatformVersion, webstorePlatformName, webstorePlatformVersion, _options) { var _a, _b, _c; return __awaiter(this, void 0, void 0, function () { var _config, localVarPath, requestContext, authMethod, defaultAuth; return __generator(this, function (_d) { switch (_d.label) { case 0: _config = _options || this.configuration; if (accountNumber === null || accountNumber === undefined) { throw new baseapi_1.RequiredError("IdentifierApi", "expApiIdentifiers", "accountNumber"); } if (type === null || type === undefined) { throw new baseapi_1.RequiredError("IdentifierApi", "expApiIdentifiers", "type"); } if (size === null || size === undefined) { throw new baseapi_1.RequiredError("IdentifierApi", "expApiIdentifiers", "size"); } localVarPath = '/identifiers'; requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); if (accountNumber !== undefined) { requestContext.setQueryParam("accountNumber", ObjectSerializer_1.ObjectSerializer.serialize(accountNumber, "string", "")); } if (type !== undefined) { requestContext.setQueryParam("type", ObjectSerializer_1.ObjectSerializer.serialize(type, "'SID' | 'PID' | 'ASID3' | 'ASID6' | 'ASID12' | 'ASID24' | 'HUID'", "")); } if (size !== undefined) { requestContext.setQueryParam("size", ObjectSerializer_1.ObjectSerializer.serialize(size, "string", "")); } requestContext.setHeaderParam("Message-Reference", ObjectSerializer_1.ObjectSerializer.serialize(messageReference, "string", "")); requestContext.setHeaderParam("Message-Reference-Date", ObjectSerializer_1.ObjectSerializer.serialize(messageReferenceDate, "string", "")); requestContext.setHeaderParam("Plugin-Name", ObjectSerializer_1.ObjectSerializer.serialize(pluginName, "string", "")); requestContext.setHeaderParam("Plugin-Version", ObjectSerializer_1.ObjectSerializer.serialize(pluginVersion, "string", "")); requestContext.setHeaderParam("Shipping-System-Platform-Name", ObjectSerializer_1.ObjectSerializer.serialize(shippingSystemPlatformName, "string", "")); requestContext.setHeaderParam("Shipping-System-Platform-Version", ObjectSerializer_1.ObjectSerializer.serialize(shippingSystemPlatformVersion, "string", "")); requestContext.setHeaderParam("Webstore-Platform-Name", ObjectSerializer_1.ObjectSerializer.serialize(webstorePlatformName, "string", "")); requestContext.setHeaderParam("Webstore-Platform-Version", ObjectSerializer_1.ObjectSerializer.serialize(webstorePlatformVersion, "string", "")); authMethod = _config.authMethods["basicAuth"]; if (!(authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication)) return [3, 2]; return [4, (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext))]; case 1: _d.sent(); _d.label = 2; case 2: defaultAuth = ((_a = _options === null || _options === void 0 ? void 0 : _options.authMethods) === null || _a === void 0 ? void 0 : _a.default) || ((_c = (_b = this.configuration) === null || _b === void 0 ? void 0 : _b.authMethods) === null || _c === void 0 ? void 0 : _c.default); if (!(defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication)) return [3, 4]; return [4, (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext))]; case 3: _d.sent(); _d.label = 4; case 4: return [2, requestContext]; } }); }); }; return IdentifierApiRequestFactory; }(baseapi_1.BaseAPIRequestFactory)); exports.IdentifierApiRequestFactory = IdentifierApiRequestFactory; var IdentifierApiResponseProcessor = (function () { function IdentifierApiResponseProcessor() { } IdentifierApiResponseProcessor.prototype.expApiIdentifiers = function (response) { return __awaiter(this, void 0, void 0, function () { var contentType, body, _a, _b, _c, _d, body, _e, _f, _g, _h, body, _j, _k, _l, _m, _o, _p; return __generator(this, function (_q) { switch (_q.label) { case 0: contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (!(0, util_1.isCodeInRange)("200", response.httpStatusCode)) return [3, 2]; _b = (_a = ObjectSerializer_1.ObjectSerializer).deserialize; _d = (_c = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 1: body = _b.apply(_a, [_d.apply(_c, [_q.sent(), contentType]), "SupermodelIoLogisticsExpressIdentifierResponse", ""]); return [2, body]; case 2: if (!(0, util_1.isCodeInRange)("400", response.httpStatusCode)) return [3, 4]; _f = (_e = ObjectSerializer_1.ObjectSerializer).deserialize; _h = (_g = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 3: body = _f.apply(_e, [_h.apply(_g, [_q.sent(), contentType]), "SupermodelIoLogisticsExpressErrorResponse", ""]); throw new exception_1.ApiException(response.httpStatusCode, "Wrong input parameters", body, response.headers); case 4: if (!(response.httpStatusCode >= 200 && response.httpStatusCode <= 299)) return [3, 6]; _k = (_j = ObjectSerializer_1.ObjectSerializer).deserialize; _m = (_l = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 5: body = _k.apply(_j, [_m.apply(_l, [_q.sent(), contentType]), "SupermodelIoLogisticsExpressIdentifierResponse", ""]); return [2, body]; case 6: _o = exception_1.ApiException.bind; _p = [void 0, response.httpStatusCode, "Unknown API Status Code!"]; return [4, response.getBodyAsAny()]; case 7: throw new (_o.apply(exception_1.ApiException, _p.concat([_q.sent(), response.headers])))(); } }); }); }; return IdentifierApiResponseProcessor; }()); exports.IdentifierApiResponseProcessor = IdentifierApiResponseProcessor; //# sourceMappingURL=IdentifierApi.js.map