/*
 * The version of the OpenAPI document: v1
 * 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.
 */


export * from './additionalSettings';
export * from './additionalSettingsResponse';
export * from './address';
export * from './address2';
export * from './allowedOrigin';
export * from './allowedOriginsResponse';
export * from './amount';
export * from './amount2';
export * from './androidApp';
export * from './androidAppsResponse';
export * from './androidCertificate';
export * from './androidCertificatesResponse';
export * from './apiCredential';
export * from './apiCredentialLinks';
export * from './applePayInfo';
export * from './bcmcInfo';
export * from './billingEntitiesResponse';
export * from './billingEntity';
export * from './cardholderReceipt';
export * from './cartesBancairesInfo';
export * from './company';
export * from './companyApiCredential';
export * from './companyLinks';
export * from './companyUser';
export * from './configuration';
export * from './connectivity';
export * from './contact';
export * from './createAllowedOriginRequest';
export * from './createApiCredentialResponse';
export * from './createCompanyApiCredentialRequest';
export * from './createCompanyApiCredentialResponse';
export * from './createCompanyUserRequest';
export * from './createCompanyUserResponse';
export * from './createCompanyWebhookRequest';
export * from './createMerchantApiCredentialRequest';
export * from './createMerchantRequest';
export * from './createMerchantResponse';
export * from './createMerchantUserRequest';
export * from './createMerchantWebhookRequest';
export * from './createUserResponse';
export * from './currency';
export * from './customNotification';
export * from './dataCenter';
export * from './eventUrl';
export * from './externalTerminalAction';
export * from './generateApiKeyResponse';
export * from './generateClientKeyResponse';
export * from './generateHmacKeyResponse';
export * from './giroPayInfo';
export * from './gratuity';
export * from './hardware';
export * from './idName';
export * from './installAndroidAppDetails';
export * from './installAndroidCertificateDetails';
export * from './invalidField';
export * from './jSONObject';
export * from './jSONPath';
export * from './klarnaInfo';
export * from './links';
export * from './linksElement';
export * from './listCompanyApiCredentialsResponse';
export * from './listCompanyResponse';
export * from './listCompanyUsersResponse';
export * from './listExternalTerminalActionsResponse';
export * from './listMerchantApiCredentialsResponse';
export * from './listMerchantResponse';
export * from './listMerchantUsersResponse';
export * from './listStoresResponse';
export * from './listTerminalsResponse';
export * from './listWebhooksResponse';
export * from './logo';
export * from './meApiCredential';
export * from './merchant';
export * from './merchantLinks';
export * from './minorUnitsMonetaryValue';
export * from './modelFile';
export * from './name';
export * from './name2';
export * from './nexo';
export * from './offlineProcessing';
export * from './opi';
export * from './orderItem';
export * from './paginationLinks';
export * from './payPalInfo';
export * from './paymentMethod';
export * from './paymentMethodResponse';
export * from './paymentMethodSetupInfo';
export * from './payoutSettings';
export * from './payoutSettingsRequest';
export * from './payoutSettingsResponse';
export * from './profile';
export * from './receiptOptions';
export * from './receiptPrinting';
export * from './releaseUpdateDetails';
export * from './requestActivationResponse';
export * from './restServiceError';
export * from './scheduleTerminalActionsRequest';
export * from './scheduleTerminalActionsResponse';
export * from './settings';
export * from './shippingLocation';
export * from './shippingLocationsResponse';
export * from './shopperStatement';
export * from './signature';
export * from './sofortInfo';
export * from './store';
export * from './storeCreationRequest';
export * from './storeCreationWithMerchantCodeRequest';
export * from './storeSplitConfiguration';
export * from './surcharge';
export * from './swishInfo';
export * from './terminal';
export * from './terminalActionScheduleDetail';
export * from './terminalModelsResponse';
export * from './terminalOrder';
export * from './terminalOrderRequest';
export * from './terminalOrdersResponse';
export * from './terminalProduct';
export * from './terminalProductsResponse';
export * from './terminalSettings';
export * from './testCompanyWebhookRequest';
export * from './testOutput';
export * from './testWebhookRequest';
export * from './testWebhookResponse';
export * from './timeouts';
export * from './uninstallAndroidAppDetails';
export * from './uninstallAndroidCertificateDetails';
export * from './updatableAddress';
export * from './updateCompanyApiCredentialRequest';
export * from './updateCompanyUserRequest';
export * from './updateCompanyWebhookRequest';
export * from './updateMerchantApiCredentialRequest';
export * from './updateMerchantUserRequest';
export * from './updateMerchantWebhookRequest';
export * from './updatePaymentMethodInfo';
export * from './updatePayoutSettingsRequest';
export * from './updateStoreRequest';
export * from './url';
export * from './user';
export * from './webhook';
export * from './webhookLinks';
export * from './wifiProfiles';


import { AdditionalSettings } from './additionalSettings';
import { AdditionalSettingsResponse } from './additionalSettingsResponse';
import { Address } from './address';
import { Address2 } from './address2';
import { AllowedOrigin } from './allowedOrigin';
import { AllowedOriginsResponse } from './allowedOriginsResponse';
import { Amount } from './amount';
import { Amount2 } from './amount2';
import { AndroidApp } from './androidApp';
import { AndroidAppsResponse } from './androidAppsResponse';
import { AndroidCertificate } from './androidCertificate';
import { AndroidCertificatesResponse } from './androidCertificatesResponse';
import { ApiCredential } from './apiCredential';
import { ApiCredentialLinks } from './apiCredentialLinks';
import { ApplePayInfo } from './applePayInfo';
import { BcmcInfo } from './bcmcInfo';
import { BillingEntitiesResponse } from './billingEntitiesResponse';
import { BillingEntity } from './billingEntity';
import { CardholderReceipt } from './cardholderReceipt';
import { CartesBancairesInfo } from './cartesBancairesInfo';
import { Company } from './company';
import { CompanyApiCredential } from './companyApiCredential';
import { CompanyLinks } from './companyLinks';
import { CompanyUser } from './companyUser';
import { Configuration } from './configuration';
import { Connectivity } from './connectivity';
import { Contact } from './contact';
import { CreateAllowedOriginRequest } from './createAllowedOriginRequest';
import { CreateApiCredentialResponse } from './createApiCredentialResponse';
import { CreateCompanyApiCredentialRequest } from './createCompanyApiCredentialRequest';
import { CreateCompanyApiCredentialResponse } from './createCompanyApiCredentialResponse';
import { CreateCompanyUserRequest } from './createCompanyUserRequest';
import { CreateCompanyUserResponse } from './createCompanyUserResponse';
import { CreateCompanyWebhookRequest } from './createCompanyWebhookRequest';
import { CreateMerchantApiCredentialRequest } from './createMerchantApiCredentialRequest';
import { CreateMerchantRequest } from './createMerchantRequest';
import { CreateMerchantResponse } from './createMerchantResponse';
import { CreateMerchantUserRequest } from './createMerchantUserRequest';
import { CreateMerchantWebhookRequest } from './createMerchantWebhookRequest';
import { CreateUserResponse } from './createUserResponse';
import { Currency } from './currency';
import { CustomNotification } from './customNotification';
import { DataCenter } from './dataCenter';
import { EventUrl } from './eventUrl';
import { ExternalTerminalAction } from './externalTerminalAction';
import { GenerateApiKeyResponse } from './generateApiKeyResponse';
import { GenerateClientKeyResponse } from './generateClientKeyResponse';
import { GenerateHmacKeyResponse } from './generateHmacKeyResponse';
import { GiroPayInfo } from './giroPayInfo';
import { Gratuity } from './gratuity';
import { Hardware } from './hardware';
import { IdName } from './idName';
import { InstallAndroidAppDetails } from './installAndroidAppDetails';
import { InstallAndroidCertificateDetails } from './installAndroidCertificateDetails';
import { InvalidField } from './invalidField';
import { JSONObject } from './jSONObject';
import { JSONPath } from './jSONPath';
import { KlarnaInfo } from './klarnaInfo';
import { Links } from './links';
import { LinksElement } from './linksElement';
import { ListCompanyApiCredentialsResponse } from './listCompanyApiCredentialsResponse';
import { ListCompanyResponse } from './listCompanyResponse';
import { ListCompanyUsersResponse } from './listCompanyUsersResponse';
import { ListExternalTerminalActionsResponse } from './listExternalTerminalActionsResponse';
import { ListMerchantApiCredentialsResponse } from './listMerchantApiCredentialsResponse';
import { ListMerchantResponse } from './listMerchantResponse';
import { ListMerchantUsersResponse } from './listMerchantUsersResponse';
import { ListStoresResponse } from './listStoresResponse';
import { ListTerminalsResponse } from './listTerminalsResponse';
import { ListWebhooksResponse } from './listWebhooksResponse';
import { Logo } from './logo';
import { MeApiCredential } from './meApiCredential';
import { Merchant } from './merchant';
import { MerchantLinks } from './merchantLinks';
import { MinorUnitsMonetaryValue } from './minorUnitsMonetaryValue';
import { ModelFile } from './modelFile';
import { Name } from './name';
import { Name2 } from './name2';
import { Nexo } from './nexo';
import { OfflineProcessing } from './offlineProcessing';
import { Opi } from './opi';
import { OrderItem } from './orderItem';
import { PaginationLinks } from './paginationLinks';
import { PayPalInfo } from './payPalInfo';
import { PaymentMethod } from './paymentMethod';
import { PaymentMethodResponse } from './paymentMethodResponse';
import { PaymentMethodSetupInfo } from './paymentMethodSetupInfo';
import { PayoutSettings } from './payoutSettings';
import { PayoutSettingsRequest } from './payoutSettingsRequest';
import { PayoutSettingsResponse } from './payoutSettingsResponse';
import { Profile } from './profile';
import { ReceiptOptions } from './receiptOptions';
import { ReceiptPrinting } from './receiptPrinting';
import { ReleaseUpdateDetails } from './releaseUpdateDetails';
import { RequestActivationResponse } from './requestActivationResponse';
import { RestServiceError } from './restServiceError';
import { ScheduleTerminalActionsRequest } from './scheduleTerminalActionsRequest';
import { ScheduleTerminalActionsResponse } from './scheduleTerminalActionsResponse';
import { Settings } from './settings';
import { ShippingLocation } from './shippingLocation';
import { ShippingLocationsResponse } from './shippingLocationsResponse';
import { ShopperStatement } from './shopperStatement';
import { Signature } from './signature';
import { SofortInfo } from './sofortInfo';
import { Store } from './store';
import { StoreCreationRequest } from './storeCreationRequest';
import { StoreCreationWithMerchantCodeRequest } from './storeCreationWithMerchantCodeRequest';
import { StoreSplitConfiguration } from './storeSplitConfiguration';
import { Surcharge } from './surcharge';
import { SwishInfo } from './swishInfo';
import { Terminal } from './terminal';
import { TerminalActionScheduleDetail } from './terminalActionScheduleDetail';
import { TerminalModelsResponse } from './terminalModelsResponse';
import { TerminalOrder } from './terminalOrder';
import { TerminalOrderRequest } from './terminalOrderRequest';
import { TerminalOrdersResponse } from './terminalOrdersResponse';
import { TerminalProduct } from './terminalProduct';
import { TerminalProductsResponse } from './terminalProductsResponse';
import { TerminalSettings } from './terminalSettings';
import { TestCompanyWebhookRequest } from './testCompanyWebhookRequest';
import { TestOutput } from './testOutput';
import { TestWebhookRequest } from './testWebhookRequest';
import { TestWebhookResponse } from './testWebhookResponse';
import { Timeouts } from './timeouts';
import { UninstallAndroidAppDetails } from './uninstallAndroidAppDetails';
import { UninstallAndroidCertificateDetails } from './uninstallAndroidCertificateDetails';
import { UpdatableAddress } from './updatableAddress';
import { UpdateCompanyApiCredentialRequest } from './updateCompanyApiCredentialRequest';
import { UpdateCompanyUserRequest } from './updateCompanyUserRequest';
import { UpdateCompanyWebhookRequest } from './updateCompanyWebhookRequest';
import { UpdateMerchantApiCredentialRequest } from './updateMerchantApiCredentialRequest';
import { UpdateMerchantUserRequest } from './updateMerchantUserRequest';
import { UpdateMerchantWebhookRequest } from './updateMerchantWebhookRequest';
import { UpdatePaymentMethodInfo } from './updatePaymentMethodInfo';
import { UpdatePayoutSettingsRequest } from './updatePayoutSettingsRequest';
import { UpdateStoreRequest } from './updateStoreRequest';
import { Url } from './url';
import { User } from './user';
import { Webhook } from './webhook';
import { WebhookLinks } from './webhookLinks';
import { WifiProfiles } from './wifiProfiles';

/* tslint:disable:no-unused-variable */
let primitives = [
                    "string",
                    "boolean",
                    "double",
                    "integer",
                    "long",
                    "float",
                    "number",
                    "any"
                 ];

let enumsMap: {[index: string]: any} = {
        "Configuration.SourcesEnum": Configuration.SourcesEnum,
        "Connectivity.SimcardStatusEnum": Connectivity.SimcardStatusEnum,
        "CreateCompanyWebhookRequest.CommunicationFormatEnum": CreateCompanyWebhookRequest.CommunicationFormatEnum,
        "CreateCompanyWebhookRequest.FilterMerchantAccountTypeEnum": CreateCompanyWebhookRequest.FilterMerchantAccountTypeEnum,
        "CreateCompanyWebhookRequest.NetworkTypeEnum": CreateCompanyWebhookRequest.NetworkTypeEnum,
        "CreateCompanyWebhookRequest.SslVersionEnum": CreateCompanyWebhookRequest.SslVersionEnum,
        "CreateMerchantWebhookRequest.CommunicationFormatEnum": CreateMerchantWebhookRequest.CommunicationFormatEnum,
        "CreateMerchantWebhookRequest.NetworkTypeEnum": CreateMerchantWebhookRequest.NetworkTypeEnum,
        "CreateMerchantWebhookRequest.SslVersionEnum": CreateMerchantWebhookRequest.SslVersionEnum,
        "InstallAndroidAppDetails.TypeEnum": InstallAndroidAppDetails.TypeEnum,
        "InstallAndroidCertificateDetails.TypeEnum": InstallAndroidCertificateDetails.TypeEnum,
        "KlarnaInfo.RegionEnum": KlarnaInfo.RegionEnum,
        "PaymentMethod.VerificationStatusEnum": PaymentMethod.VerificationStatusEnum,
        "PaymentMethodSetupInfo.ShopperInteractionEnum": PaymentMethodSetupInfo.ShopperInteractionEnum,
        "PaymentMethodSetupInfo.TypeEnum": PaymentMethodSetupInfo.TypeEnum,
        "PayoutSettings.PriorityEnum": PayoutSettings.PriorityEnum,
        "PayoutSettings.VerificationStatusEnum": PayoutSettings.VerificationStatusEnum,
        "ReleaseUpdateDetails.TypeEnum": ReleaseUpdateDetails.TypeEnum,
        "ShopperStatement.TypeEnum": ShopperStatement.TypeEnum,
        "Store.StatusEnum": Store.StatusEnum,
        "UninstallAndroidAppDetails.TypeEnum": UninstallAndroidAppDetails.TypeEnum,
        "UninstallAndroidCertificateDetails.TypeEnum": UninstallAndroidCertificateDetails.TypeEnum,
        "UpdateCompanyWebhookRequest.CommunicationFormatEnum": UpdateCompanyWebhookRequest.CommunicationFormatEnum,
        "UpdateCompanyWebhookRequest.FilterMerchantAccountTypeEnum": UpdateCompanyWebhookRequest.FilterMerchantAccountTypeEnum,
        "UpdateCompanyWebhookRequest.NetworkTypeEnum": UpdateCompanyWebhookRequest.NetworkTypeEnum,
        "UpdateCompanyWebhookRequest.SslVersionEnum": UpdateCompanyWebhookRequest.SslVersionEnum,
        "UpdateMerchantWebhookRequest.CommunicationFormatEnum": UpdateMerchantWebhookRequest.CommunicationFormatEnum,
        "UpdateMerchantWebhookRequest.NetworkTypeEnum": UpdateMerchantWebhookRequest.NetworkTypeEnum,
        "UpdateMerchantWebhookRequest.SslVersionEnum": UpdateMerchantWebhookRequest.SslVersionEnum,
        "UpdateStoreRequest.StatusEnum": UpdateStoreRequest.StatusEnum,
        "Webhook.CommunicationFormatEnum": Webhook.CommunicationFormatEnum,
        "Webhook.FilterMerchantAccountTypeEnum": Webhook.FilterMerchantAccountTypeEnum,
        "Webhook.NetworkTypeEnum": Webhook.NetworkTypeEnum,
        "Webhook.SslVersionEnum": Webhook.SslVersionEnum,
}

let typeMap: {[index: string]: any} = {
    "AdditionalSettings": AdditionalSettings,
    "AdditionalSettingsResponse": AdditionalSettingsResponse,
    "Address": Address,
    "Address2": Address2,
    "AllowedOrigin": AllowedOrigin,
    "AllowedOriginsResponse": AllowedOriginsResponse,
    "Amount": Amount,
    "Amount2": Amount2,
    "AndroidApp": AndroidApp,
    "AndroidAppsResponse": AndroidAppsResponse,
    "AndroidCertificate": AndroidCertificate,
    "AndroidCertificatesResponse": AndroidCertificatesResponse,
    "ApiCredential": ApiCredential,
    "ApiCredentialLinks": ApiCredentialLinks,
    "ApplePayInfo": ApplePayInfo,
    "BcmcInfo": BcmcInfo,
    "BillingEntitiesResponse": BillingEntitiesResponse,
    "BillingEntity": BillingEntity,
    "CardholderReceipt": CardholderReceipt,
    "CartesBancairesInfo": CartesBancairesInfo,
    "Company": Company,
    "CompanyApiCredential": CompanyApiCredential,
    "CompanyLinks": CompanyLinks,
    "CompanyUser": CompanyUser,
    "Configuration": Configuration,
    "Connectivity": Connectivity,
    "Contact": Contact,
    "CreateAllowedOriginRequest": CreateAllowedOriginRequest,
    "CreateApiCredentialResponse": CreateApiCredentialResponse,
    "CreateCompanyApiCredentialRequest": CreateCompanyApiCredentialRequest,
    "CreateCompanyApiCredentialResponse": CreateCompanyApiCredentialResponse,
    "CreateCompanyUserRequest": CreateCompanyUserRequest,
    "CreateCompanyUserResponse": CreateCompanyUserResponse,
    "CreateCompanyWebhookRequest": CreateCompanyWebhookRequest,
    "CreateMerchantApiCredentialRequest": CreateMerchantApiCredentialRequest,
    "CreateMerchantRequest": CreateMerchantRequest,
    "CreateMerchantResponse": CreateMerchantResponse,
    "CreateMerchantUserRequest": CreateMerchantUserRequest,
    "CreateMerchantWebhookRequest": CreateMerchantWebhookRequest,
    "CreateUserResponse": CreateUserResponse,
    "Currency": Currency,
    "CustomNotification": CustomNotification,
    "DataCenter": DataCenter,
    "EventUrl": EventUrl,
    "ExternalTerminalAction": ExternalTerminalAction,
    "GenerateApiKeyResponse": GenerateApiKeyResponse,
    "GenerateClientKeyResponse": GenerateClientKeyResponse,
    "GenerateHmacKeyResponse": GenerateHmacKeyResponse,
    "GiroPayInfo": GiroPayInfo,
    "Gratuity": Gratuity,
    "Hardware": Hardware,
    "IdName": IdName,
    "InstallAndroidAppDetails": InstallAndroidAppDetails,
    "InstallAndroidCertificateDetails": InstallAndroidCertificateDetails,
    "InvalidField": InvalidField,
    "JSONObject": JSONObject,
    "JSONPath": JSONPath,
    "KlarnaInfo": KlarnaInfo,
    "Links": Links,
    "LinksElement": LinksElement,
    "ListCompanyApiCredentialsResponse": ListCompanyApiCredentialsResponse,
    "ListCompanyResponse": ListCompanyResponse,
    "ListCompanyUsersResponse": ListCompanyUsersResponse,
    "ListExternalTerminalActionsResponse": ListExternalTerminalActionsResponse,
    "ListMerchantApiCredentialsResponse": ListMerchantApiCredentialsResponse,
    "ListMerchantResponse": ListMerchantResponse,
    "ListMerchantUsersResponse": ListMerchantUsersResponse,
    "ListStoresResponse": ListStoresResponse,
    "ListTerminalsResponse": ListTerminalsResponse,
    "ListWebhooksResponse": ListWebhooksResponse,
    "Logo": Logo,
    "MeApiCredential": MeApiCredential,
    "Merchant": Merchant,
    "MerchantLinks": MerchantLinks,
    "MinorUnitsMonetaryValue": MinorUnitsMonetaryValue,
    "ModelFile": ModelFile,
    "Name": Name,
    "Name2": Name2,
    "Nexo": Nexo,
    "OfflineProcessing": OfflineProcessing,
    "Opi": Opi,
    "OrderItem": OrderItem,
    "PaginationLinks": PaginationLinks,
    "PayPalInfo": PayPalInfo,
    "PaymentMethod": PaymentMethod,
    "PaymentMethodResponse": PaymentMethodResponse,
    "PaymentMethodSetupInfo": PaymentMethodSetupInfo,
    "PayoutSettings": PayoutSettings,
    "PayoutSettingsRequest": PayoutSettingsRequest,
    "PayoutSettingsResponse": PayoutSettingsResponse,
    "Profile": Profile,
    "ReceiptOptions": ReceiptOptions,
    "ReceiptPrinting": ReceiptPrinting,
    "ReleaseUpdateDetails": ReleaseUpdateDetails,
    "RequestActivationResponse": RequestActivationResponse,
    "RestServiceError": RestServiceError,
    "ScheduleTerminalActionsRequest": ScheduleTerminalActionsRequest,
    "ScheduleTerminalActionsResponse": ScheduleTerminalActionsResponse,
    "Settings": Settings,
    "ShippingLocation": ShippingLocation,
    "ShippingLocationsResponse": ShippingLocationsResponse,
    "ShopperStatement": ShopperStatement,
    "Signature": Signature,
    "SofortInfo": SofortInfo,
    "Store": Store,
    "StoreCreationRequest": StoreCreationRequest,
    "StoreCreationWithMerchantCodeRequest": StoreCreationWithMerchantCodeRequest,
    "StoreSplitConfiguration": StoreSplitConfiguration,
    "Surcharge": Surcharge,
    "SwishInfo": SwishInfo,
    "Terminal": Terminal,
    "TerminalActionScheduleDetail": TerminalActionScheduleDetail,
    "TerminalModelsResponse": TerminalModelsResponse,
    "TerminalOrder": TerminalOrder,
    "TerminalOrderRequest": TerminalOrderRequest,
    "TerminalOrdersResponse": TerminalOrdersResponse,
    "TerminalProduct": TerminalProduct,
    "TerminalProductsResponse": TerminalProductsResponse,
    "TerminalSettings": TerminalSettings,
    "TestCompanyWebhookRequest": TestCompanyWebhookRequest,
    "TestOutput": TestOutput,
    "TestWebhookRequest": TestWebhookRequest,
    "TestWebhookResponse": TestWebhookResponse,
    "Timeouts": Timeouts,
    "UninstallAndroidAppDetails": UninstallAndroidAppDetails,
    "UninstallAndroidCertificateDetails": UninstallAndroidCertificateDetails,
    "UpdatableAddress": UpdatableAddress,
    "UpdateCompanyApiCredentialRequest": UpdateCompanyApiCredentialRequest,
    "UpdateCompanyUserRequest": UpdateCompanyUserRequest,
    "UpdateCompanyWebhookRequest": UpdateCompanyWebhookRequest,
    "UpdateMerchantApiCredentialRequest": UpdateMerchantApiCredentialRequest,
    "UpdateMerchantUserRequest": UpdateMerchantUserRequest,
    "UpdateMerchantWebhookRequest": UpdateMerchantWebhookRequest,
    "UpdatePaymentMethodInfo": UpdatePaymentMethodInfo,
    "UpdatePayoutSettingsRequest": UpdatePayoutSettingsRequest,
    "UpdateStoreRequest": UpdateStoreRequest,
    "Url": Url,
    "User": User,
    "Webhook": Webhook,
    "WebhookLinks": WebhookLinks,
    "WifiProfiles": WifiProfiles,
}

export class ObjectSerializer {
    public static findCorrectType(data: any, expectedType: string) {
        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)
                }
            }
        }
    }

    public static serialize(data: any, type: string) {
        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: string = type.replace("Array<", ""); // Array<Type> => Type>
            subType = subType.substring(0, subType.length - 1); // Type> => Type
            let transformedData: any[] = [];
            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: {[index: string]: any} = {};
            for (let index = 0; index < attributeTypes.length; index++) {
                let attributeType = attributeTypes[index];
                instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type);
            }
            return instance;
        }
    }

    public static deserialize(data: any, type: string) {
        // 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: string = type.replace("Array<", ""); // Array<Type> => Type>
            subType = subType.substring(0, subType.length - 1); // Type> => Type
            let transformedData: any[] = [];
            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;
        }
    }
}
