import { Lead } from './lead.model'; import { RequiredJsonPropertyError } from './../error/required-json-property.error'; export class LeadSerializer { public serialize(item: Lead): {[key: string]: any} { if (!item.client || !item.client.id) { throw new RequiredJsonPropertyError(item, 'client.id'); } if (!item.organization || !item.organization.id) { throw new RequiredJsonPropertyError(item, 'organization.id'); } const json: {[key: string]: any} = {}; if (item.id) { json['id'] = item.id; } json['client_id'] = item.client.id; json['organization_id'] = item.organization.id; json['description'] = item.vehicle; json['status'] = item.status; json['current_stage'] = item.stage; json['source'] = item.source; json['offer_value'] = item.offerValue; return json; } }