export * from './additionalData' ; export * from './amount' ; export * from './notification' ; export * from './notificationItem' ; export * from './notificationRequestItem' ; import * as fs from 'fs' ; export interface RequestDetailedFile { value : Buffer ; options ? : { filename ? : string ; contentType ? : string ; } ; } export type RequestFile = string | Buffer | fs . ReadStream | RequestDetailedFile ; import { AdditionalData } from './additionalData' ; import { Amount } from './amount' ; import { Notification } from './notification' ; import { NotificationItem } from './notificationItem' ; import { NotificationRequestItem } from './notificationRequestItem' ; let primitives = [ "string" , "boolean" , "double" , "integer" , "long" , "float" , "number" , "any" ] ; let enumsMap = { "NotificationRequestItem.EventCodeEnum" : NotificationRequestItem . EventCodeEnum , "NotificationRequestItem.OperationsEnum" : NotificationRequestItem . OperationsEnum , "NotificationRequestItem.SuccessEnum" : NotificationRequestItem . SuccessEnum , } ; let typeMap = { "AdditionalData" : AdditionalData , "Amount" : Amount , "Notification" : Notification , "NotificationItem" : NotificationItem , "NotificationRequestItem" : NotificationRequestItem , } ; export class ObjectSerializer { public 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 ; } let discriminatorProperty = typeMap [ expectedType ] . discriminator ; if ( discriminatorProperty == null ) { return expectedType ; } else { if ( data [ discriminatorProperty ] ) { var discriminatorType = data [ discriminatorProperty ] ; if ( typeMap [ discriminatorType ] ) { return discriminatorType ; } else { return expectedType ; } } else { return expectedType ; } } } } public 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 ) { let subType = type . replace ( "Array<" , "" ) ; subType = subType . substring ( 0 , subType . length - 1 ) ; 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 ( enumsMap [ type ] ) { return data ; } if ( ! typeMap [ type ] ) { return data ; } type = this . findCorrectType ( data , 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 ; } } public static deserialize ( data , 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 ) { let subType = type . replace ( "Array<" , "" ) ; subType = subType . substring ( 0 , subType . length - 1 ) ; 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 ] ) { return data ; } if ( ! typeMap [ 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 ; } } }