UNPKG

@adyen/api-library

Version:

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

215 lines 9.59 kB
"use strict"; /* * The version of the OpenAPI document: v4 * * * 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("./balancePlatformNotificationResponse"), exports); __exportStar(require("./bankCategoryData"), exports); __exportStar(require("./internalCategoryData"), exports); __exportStar(require("./issuedCard"), exports); __exportStar(require("./paymentInstrument"), exports); __exportStar(require("./platformPayment"), exports); __exportStar(require("./relayedAuthorisationData"), exports); __exportStar(require("./resource"), exports); __exportStar(require("./resourceReference"), exports); __exportStar(require("./transaction"), exports); __exportStar(require("./transactionNotificationRequestV4"), exports); __exportStar(require("./transferNotificationValidationFact"), exports); __exportStar(require("./transferView"), exports); const amount_1 = require("./amount"); const balancePlatformNotificationResponse_1 = require("./balancePlatformNotificationResponse"); const bankCategoryData_1 = require("./bankCategoryData"); const internalCategoryData_1 = require("./internalCategoryData"); const issuedCard_1 = require("./issuedCard"); const paymentInstrument_1 = require("./paymentInstrument"); const platformPayment_1 = require("./platformPayment"); const relayedAuthorisationData_1 = require("./relayedAuthorisationData"); const resource_1 = require("./resource"); const resourceReference_1 = require("./resourceReference"); const transaction_1 = require("./transaction"); const transactionNotificationRequestV4_1 = require("./transactionNotificationRequestV4"); const transferNotificationValidationFact_1 = require("./transferNotificationValidationFact"); const transferView_1 = require("./transferView"); /* tslint:disable:no-unused-variable */ let primitives = [ "string", "boolean", "double", "integer", "long", "float", "number", "any" ]; let enumsMap = { "BankCategoryData.PriorityEnum": bankCategoryData_1.BankCategoryData.PriorityEnum, "BankCategoryData.TypeEnum": bankCategoryData_1.BankCategoryData.TypeEnum, "InternalCategoryData.TypeEnum": internalCategoryData_1.InternalCategoryData.TypeEnum, "IssuedCard.PanEntryModeEnum": issuedCard_1.IssuedCard.PanEntryModeEnum, "IssuedCard.ProcessingTypeEnum": issuedCard_1.IssuedCard.ProcessingTypeEnum, "IssuedCard.TypeEnum": issuedCard_1.IssuedCard.TypeEnum, "PlatformPayment.PlatformPaymentTypeEnum": platformPayment_1.PlatformPayment.PlatformPaymentTypeEnum, "PlatformPayment.TypeEnum": platformPayment_1.PlatformPayment.TypeEnum, "Transaction.StatusEnum": transaction_1.Transaction.StatusEnum, "TransactionNotificationRequestV4.TypeEnum": transactionNotificationRequestV4_1.TransactionNotificationRequestV4.TypeEnum, }; let typeMap = { "Amount": amount_1.Amount, "BalancePlatformNotificationResponse": balancePlatformNotificationResponse_1.BalancePlatformNotificationResponse, "BankCategoryData": bankCategoryData_1.BankCategoryData, "InternalCategoryData": internalCategoryData_1.InternalCategoryData, "IssuedCard": issuedCard_1.IssuedCard, "PaymentInstrument": paymentInstrument_1.PaymentInstrument, "PlatformPayment": platformPayment_1.PlatformPayment, "RelayedAuthorisationData": relayedAuthorisationData_1.RelayedAuthorisationData, "Resource": resource_1.Resource, "ResourceReference": resourceReference_1.ResourceReference, "Transaction": transaction_1.Transaction, "TransactionNotificationRequestV4": transactionNotificationRequestV4_1.TransactionNotificationRequestV4, "TransferNotificationValidationFact": transferNotificationValidationFact_1.TransferNotificationValidationFact, "TransferView": transferView_1.TransferView, }; 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