import { HALConfig } from '../hal.config'; import { LeadCommentCollection } from './lead-comment.collection'; import { LeadCommentConverter } from './lead-comment.converter'; export class LeadCommentCollectionConverter { public constructor(private converter: LeadCommentConverter) { } public toCollection(json: any): LeadCommentCollection { const collection: LeadCommentCollection = new LeadCommentCollection(); collection.count = json['count']; collection.total = json['total']; if (json[HALConfig.embedded] && json[HALConfig.embedded]['comments']) { collection.comments = this.converter.toMany(json[HALConfig.embedded]['comments']); } return collection; } }