skailan-crm
Version:
Servicio de CRM y gestión de ventas para Skailan
27 lines • 1 kB
JavaScript
export class SyncLeadWithContact {
leadRepository;
contactIntegrationService;
constructor(leadRepository, contactIntegrationService) {
this.leadRepository = leadRepository;
this.contactIntegrationService = contactIntegrationService;
}
async execute(request) {
const { leadId, organizationId } = request;
// Buscar el lead
const lead = await this.leadRepository.findById(leadId, organizationId);
if (!lead) {
throw new Error('Lead not found.');
}
if (!lead.email) {
throw new Error('Lead must have an email to sync with contacts.');
}
// Sincronizar con el módulo de contactos
const contact = await this.contactIntegrationService.syncLeadWithContact(lead);
return {
lead: lead,
contact: contact,
message: 'Lead successfully synchronized with contacts module'
};
}
}
//# sourceMappingURL=SyncLeadWithContact.js.map