UNPKG

@adyen/api-library

Version:

The Adyen API Library for NodeJS enables you to work with Adyen APIs.

214 lines 9.89 kB
"use strict"; /* * The version of the OpenAPI document: v1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit this class manually. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObjectSerializer = void 0; __exportStar(require("./amount"), exports); __exportStar(require("./authenticationDecision"), exports); __exportStar(require("./authenticationInfo"), exports); __exportStar(require("./authenticationNotificationData"), exports); __exportStar(require("./authenticationNotificationRequest"), exports); __exportStar(require("./balancePlatformNotificationResponse"), exports); __exportStar(require("./challengeInfo"), exports); __exportStar(require("./purchase"), exports); __exportStar(require("./purchaseInfo"), exports); __exportStar(require("./relayedAuthenticationRequest"), exports); __exportStar(require("./relayedAuthenticationResponse"), exports); __exportStar(require("./resource"), exports); __exportStar(require("./serviceError"), exports); const amount_1 = require("./amount"); const authenticationDecision_1 = require("./authenticationDecision"); const authenticationInfo_1 = require("./authenticationInfo"); const authenticationNotificationData_1 = require("./authenticationNotificationData"); const authenticationNotificationRequest_1 = require("./authenticationNotificationRequest"); const balancePlatformNotificationResponse_1 = require("./balancePlatformNotificationResponse"); const challengeInfo_1 = require("./challengeInfo"); const purchase_1 = require("./purchase"); const purchaseInfo_1 = require("./purchaseInfo"); const relayedAuthenticationRequest_1 = require("./relayedAuthenticationRequest"); const relayedAuthenticationResponse_1 = require("./relayedAuthenticationResponse"); const resource_1 = require("./resource"); const serviceError_1 = require("./serviceError"); /* tslint:disable:no-unused-variable */ let primitives = [ "string", "boolean", "double", "integer", "long", "float", "number", "any" ]; let enumsMap = { "AuthenticationDecision.StatusEnum": authenticationDecision_1.AuthenticationDecision.StatusEnum, "AuthenticationInfo.ChallengeIndicatorEnum": authenticationInfo_1.AuthenticationInfo.ChallengeIndicatorEnum, "AuthenticationInfo.DeviceChannelEnum": authenticationInfo_1.AuthenticationInfo.DeviceChannelEnum, "AuthenticationInfo.ExemptionIndicatorEnum": authenticationInfo_1.AuthenticationInfo.ExemptionIndicatorEnum, "AuthenticationInfo.MessageCategoryEnum": authenticationInfo_1.AuthenticationInfo.MessageCategoryEnum, "AuthenticationInfo.TransStatusEnum": authenticationInfo_1.AuthenticationInfo.TransStatusEnum, "AuthenticationInfo.TransStatusReasonEnum": authenticationInfo_1.AuthenticationInfo.TransStatusReasonEnum, "AuthenticationInfo.TypeEnum": authenticationInfo_1.AuthenticationInfo.TypeEnum, "AuthenticationNotificationData.StatusEnum": authenticationNotificationData_1.AuthenticationNotificationData.StatusEnum, "AuthenticationNotificationRequest.TypeEnum": authenticationNotificationRequest_1.AuthenticationNotificationRequest.TypeEnum, "ChallengeInfo.ChallengeCancelEnum": challengeInfo_1.ChallengeInfo.ChallengeCancelEnum, "ChallengeInfo.FlowEnum": challengeInfo_1.ChallengeInfo.FlowEnum, }; let typeMap = { "Amount": amount_1.Amount, "AuthenticationDecision": authenticationDecision_1.AuthenticationDecision, "AuthenticationInfo": authenticationInfo_1.AuthenticationInfo, "AuthenticationNotificationData": authenticationNotificationData_1.AuthenticationNotificationData, "AuthenticationNotificationRequest": authenticationNotificationRequest_1.AuthenticationNotificationRequest, "BalancePlatformNotificationResponse": balancePlatformNotificationResponse_1.BalancePlatformNotificationResponse, "ChallengeInfo": challengeInfo_1.ChallengeInfo, "Purchase": purchase_1.Purchase, "PurchaseInfo": purchaseInfo_1.PurchaseInfo, "RelayedAuthenticationRequest": relayedAuthenticationRequest_1.RelayedAuthenticationRequest, "RelayedAuthenticationResponse": relayedAuthenticationResponse_1.RelayedAuthenticationResponse, "Resource": resource_1.Resource, "ServiceError": serviceError_1.ServiceError, }; class ObjectSerializer { static findCorrectType(data, expectedType) { if (data == undefined) { return expectedType; } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { return expectedType; } else if (expectedType === "Date") { return expectedType; } else { if (enumsMap[expectedType]) { return expectedType; } if (!typeMap[expectedType]) { return expectedType; // w/e we don't know the type } // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; if (typeMap[discriminatorType]) { return discriminatorType; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } } else { return expectedType; // discriminator was not present (or an empty string) } } } } static serialize(data, type) { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 let subType = type.replace("Array<", ""); // Array<Type> => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.serialize(datum, subType)); } return transformedData; } else if (type === "Date") { return data.toISOString(); } else if (type === "SaleToAcquirerData") { const dataString = JSON.stringify(data); return Buffer.from(dataString).toString("base64"); } else { if (enumsMap[type]) { return data; } if (!typeMap[type]) { // in case we dont know the type return data; } // Get the actual type of this object type = this.findCorrectType(data, type); // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance = {}; for (let index = 0; index < attributeTypes.length; index++) { let attributeType = attributeTypes[index]; instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); } return instance; } } static deserialize(data, type) { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 let subType = type.replace("Array<", ""); // Array<Type> => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.deserialize(datum, subType)); } return transformedData; } else if (type === "Date") { return new Date(data); } else { if (enumsMap[type]) { // is Enum return data; } if (!typeMap[type]) { // dont know the type return data; } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); for (let index = 0; index < attributeTypes.length; index++) { let attributeType = attributeTypes[index]; instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); } return instance; } } } exports.ObjectSerializer = ObjectSerializer; //# sourceMappingURL=models.js.map