-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1707 from bakaphp/feat-zoho-lead-reciever-job
Merge pull request #1655 from bakaphp/hotfix-zoho-lead
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/Domains/Connectors/Zoho/Jobs/SyncZohoLeadFromReceiverJob.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
]; | ||
} | ||
} |