UNPKG

skailan-crm

Version:

Servicio de CRM y gestión de ventas para Skailan

37 lines 1.51 kB
export class UpdateLead { leadRepository; constructor(leadRepository) { this.leadRepository = leadRepository; } async execute(request) { const { id, organizationId, ...updates } = request; const existingLead = await this.leadRepository.findById(id, organizationId); if (!existingLead) { throw new Error('Lead not found.'); } // Apply updates to the domain entity if (updates.name !== undefined) existingLead.name = updates.name; if (updates.email !== undefined) existingLead.email = updates.email; if (updates.phone !== undefined) existingLead.phone = updates.phone; if (updates.status !== undefined) existingLead.status = updates.status; if (updates.source !== undefined) existingLead.source = updates.source; if (updates.notes !== undefined) existingLead.notes = updates.notes; if (updates.score !== undefined) existingLead.score = updates.score; if (updates.company !== undefined) existingLead.company = updates.company; if (updates.title !== undefined) existingLead.title = updates.title; if (updates.industry !== undefined) existingLead.industry = updates.industry; existingLead.updatedAt = new Date(); // Update timestamp return this.leadRepository.save(existingLead); } } //# sourceMappingURL=UpdateLead.js.map