import { TaskConverter } from './task.converter'; import { TaskCollection } from './task.collection'; import { HALConfig } from '../hal.config'; export class TaskCollectionConverter { public constructor(private taskConverter: TaskConverter) {} public toCollection(json: any): TaskCollection { const collection: TaskCollection = new TaskCollection(); collection.total = json['total']; if (json[HALConfig.embedded] && json[HALConfig.embedded]['tasks']) { collection.tasks = this.taskConverter.toMany(json[HALConfig.embedded]['tasks']); } return collection; } }