UNPKG

@adyen/api-library

Version:

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

214 lines 10.6 kB
"use strict"; /* * The version of the OpenAPI document: v6 * Contact: developer-experience@adyen.com * * 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("./createNotificationConfigurationRequest"), exports); __exportStar(require("./deleteNotificationConfigurationRequest"), exports); __exportStar(require("./errorFieldType"), exports); __exportStar(require("./exchangeMessage"), exports); __exportStar(require("./fieldType"), exports); __exportStar(require("./genericResponse"), exports); __exportStar(require("./getNotificationConfigurationListResponse"), exports); __exportStar(require("./getNotificationConfigurationRequest"), exports); __exportStar(require("./getNotificationConfigurationResponse"), exports); __exportStar(require("./notificationConfigurationDetails"), exports); __exportStar(require("./notificationEventConfiguration"), exports); __exportStar(require("./serviceError"), exports); __exportStar(require("./testNotificationConfigurationRequest"), exports); __exportStar(require("./testNotificationConfigurationResponse"), exports); __exportStar(require("./updateNotificationConfigurationRequest"), exports); const createNotificationConfigurationRequest_1 = require("./createNotificationConfigurationRequest"); const deleteNotificationConfigurationRequest_1 = require("./deleteNotificationConfigurationRequest"); const errorFieldType_1 = require("./errorFieldType"); const exchangeMessage_1 = require("./exchangeMessage"); const fieldType_1 = require("./fieldType"); const genericResponse_1 = require("./genericResponse"); const getNotificationConfigurationListResponse_1 = require("./getNotificationConfigurationListResponse"); const getNotificationConfigurationRequest_1 = require("./getNotificationConfigurationRequest"); const getNotificationConfigurationResponse_1 = require("./getNotificationConfigurationResponse"); const notificationConfigurationDetails_1 = require("./notificationConfigurationDetails"); const notificationEventConfiguration_1 = require("./notificationEventConfiguration"); const serviceError_1 = require("./serviceError"); const testNotificationConfigurationRequest_1 = require("./testNotificationConfigurationRequest"); const testNotificationConfigurationResponse_1 = require("./testNotificationConfigurationResponse"); const updateNotificationConfigurationRequest_1 = require("./updateNotificationConfigurationRequest"); /* tslint:disable:no-unused-variable */ let primitives = [ "string", "boolean", "double", "integer", "long", "float", "number", "any" ]; let enumsMap = { "FieldType.FieldNameEnum": fieldType_1.FieldType.FieldNameEnum, "NotificationConfigurationDetails.SslProtocolEnum": notificationConfigurationDetails_1.NotificationConfigurationDetails.SslProtocolEnum, "NotificationEventConfiguration.EventTypeEnum": notificationEventConfiguration_1.NotificationEventConfiguration.EventTypeEnum, "NotificationEventConfiguration.IncludeModeEnum": notificationEventConfiguration_1.NotificationEventConfiguration.IncludeModeEnum, "TestNotificationConfigurationRequest.EventTypesEnum": testNotificationConfigurationRequest_1.TestNotificationConfigurationRequest.EventTypesEnum, "TestNotificationConfigurationResponse.EventTypesEnum": testNotificationConfigurationResponse_1.TestNotificationConfigurationResponse.EventTypesEnum, }; let typeMap = { "CreateNotificationConfigurationRequest": createNotificationConfigurationRequest_1.CreateNotificationConfigurationRequest, "DeleteNotificationConfigurationRequest": deleteNotificationConfigurationRequest_1.DeleteNotificationConfigurationRequest, "ErrorFieldType": errorFieldType_1.ErrorFieldType, "ExchangeMessage": exchangeMessage_1.ExchangeMessage, "FieldType": fieldType_1.FieldType, "GenericResponse": genericResponse_1.GenericResponse, "GetNotificationConfigurationListResponse": getNotificationConfigurationListResponse_1.GetNotificationConfigurationListResponse, "GetNotificationConfigurationRequest": getNotificationConfigurationRequest_1.GetNotificationConfigurationRequest, "GetNotificationConfigurationResponse": getNotificationConfigurationResponse_1.GetNotificationConfigurationResponse, "NotificationConfigurationDetails": notificationConfigurationDetails_1.NotificationConfigurationDetails, "NotificationEventConfiguration": notificationEventConfiguration_1.NotificationEventConfiguration, "ServiceError": serviceError_1.ServiceError, "TestNotificationConfigurationRequest": testNotificationConfigurationRequest_1.TestNotificationConfigurationRequest, "TestNotificationConfigurationResponse": testNotificationConfigurationResponse_1.TestNotificationConfigurationResponse, "UpdateNotificationConfigurationRequest": updateNotificationConfigurationRequest_1.UpdateNotificationConfigurationRequest, }; 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