const supportedAnyKeys = [ 'identifier' , 'name' ] ; export class TrackModel { public id : string ; public name : string ; public artist : any ; public album : any ; public duration : number ; public shoutoutId : string ; public playlistId : string ; public playing : boolean = false ; public order : number ; constructor ( track ) { if ( track ) { for ( let key in track ) { if ( track . hasOwnProperty ( key ) ) { if ( key === 'album' || key === 'artist' ) { this [ key ] = { } ; for ( let supportedKey of supportedAnyKeys ) { if ( supportedKey === 'identifier' ) { this [ key ] . id = track [ key ] [ supportedKey ] ; } else { this [ key ] [ supportedKey ] = track [ key ] [ supportedKey ] ; } } } else { this [ key ] = track [ key ] ; } } } if ( ! this . order ) { this . order = 0 ; } } } }