Skip to content

Commit

Permalink
Merge pull request #1707 from bakaphp/feat-zoho-lead-reciever-job
Browse files Browse the repository at this point in the history
Merge pull request #1655 from bakaphp/hotfix-zoho-lead
  • Loading branch information
kaioken authored Jul 19, 2024
2 parents 1cea10c + 7e9f3b0 commit 4759d33
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Domains/Connectors/Zoho/Jobs/SyncZohoLeadFromReceiverJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Kanvas\Connectors\Zoho\Jobs;

use Kanvas\Connectors\Zoho\Actions\SyncZohoLeadAction;
use Kanvas\Guild\Leads\Models\LeadReceiver;
use Kanvas\Workflow\Jobs\ProcessWebhookJob;

class SyncZohoLeadFromReceiverJob extends ProcessWebhookJob
{
public function execute(): array
{
$zohoLeadId = $this->webhookRequest->payload['entity_id'] ?? null;
$leadReceiver = LeadReceiver::getByIdFromCompanyApp(
$this->receiver->configuration['receiver_id'],
$this->receiver->company,
$this->receiver->app
);

if (! $zohoLeadId) {
return [
'message' => 'Zoho Lead ID not found',
];
}

$syncLead = new SyncZohoLeadAction(
$this->receiver->app,
$this->receiver->company,
$leadReceiver,
$zohoLeadId
);

$lead = $syncLead->execute();

return [
'message' => 'Lead created successfully via receiver ' . $leadReceiver->uuid,
'receiver' => $leadReceiver->getId(),
'lead' => $lead->getId(),
];
}
}

0 comments on commit 4759d33

Please sign in to comment.