import { CardConverter } from './card.converter'; import { CardCollection } from './card.collection'; import { HALConfig } from '../hal.config'; export class CardCollectionConverter { public constructor(private cardConverter: CardConverter) {} public toCollection(json: any): CardCollection { const collection: CardCollection = new CardCollection(); collection.count = json['count']; collection.total = json['total']; if (json[HALConfig.embedded] && json[HALConfig.embedded]['cards']) { collection.cards = this.cardConverter.toMany(json[HALConfig.embedded]['cards']); } return collection; } }