import { LeadSearchCollection } from './lead-search.collection'; import { LeadSearchConverter } from './lead-search.converter'; import { ElasticResponseConfig } from '../search/elastic-response.config'; export class LeadSearchCollectionConverter { public constructor(private converter: LeadSearchConverter) { } public toCollection(json: any): LeadSearchCollection { const collection: LeadSearchCollection = new LeadSearchCollection(); collection.total = json[ElasticResponseConfig.hits]['total']; collection.leads = this.converter.toMany( json[ElasticResponseConfig.hits][ElasticResponseConfig.hits] ); collection.count = collection.leads.length; return collection; } }