Skip to content

Commit

Permalink
Merge pull request #860 from bakaphp/kaioken-patch-1
Browse files Browse the repository at this point in the history
Update ZohoLeadActivity.php
  • Loading branch information
kaioken authored Jan 29, 2024
2 parents d157870 + 30059ed commit 0d0d48a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Domains/Connectors/Zoho/Workflows/ZohoLeadActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Kanvas\Connectors\Zoho\ZohoService;
use Kanvas\Guild\Agents\Models\Agent;
use Kanvas\Guild\Leads\Models\Lead;
use Kanvas\SystemModules\Repositories\SystemModulesRepository;
use Kanvas\Workflow\Contracts\WorkflowActivityInterface;
use Throwable;
use Webleit\ZohoCrmApi\Modules\Leads as ZohoLeadModule;
Expand All @@ -27,7 +28,6 @@ class ZohoLeadActivity extends Activity implements WorkflowActivityInterface
*/
public function execute(Model $lead, AppInterface $app, array $params): array
{
$lead = Lead::getById($lead->getId());
$zohoLead = ZohoLead::fromLead($lead);
$zohoData = $zohoLead->toArray();
$company = Companies::getById($lead->companies_id);
Expand Down Expand Up @@ -60,6 +60,7 @@ public function execute(Model $lead, AppInterface $app, array $params): array
'zohoLeadId' => $zohoLeadId,
'zohoRequest' => $zohoData,
'leadId' => $lead->getId(),
'systemModule' => SystemModulesRepository::getByModelName(get_class($lead))->getId()
];
}

Expand Down Expand Up @@ -139,15 +140,19 @@ protected function uploadAttachments(ZohoLeadModule $zohoLead, Lead $lead): void
continue;
}

$fileContent = file_get_contents($file->url);
try {
$fileContent = file_get_contents($file->url);

$zohoLead->uploadAttachment(
(string) $lead->get(CustomFieldEnum::ZOHO_LEAD_ID->value),
$file->name,
$fileContent
);
$zohoLead->uploadAttachment(
(string) $lead->get(CustomFieldEnum::ZOHO_LEAD_ID->value),
$file->name,
$fileContent
);

$syncFiles[$file->id] = $file->id;
$syncFiles[$file->id] = $file->id;
} catch(Throwable $e) {
//do nothing
}
}

$lead->set(
Expand Down

0 comments on commit 0d0d48a

Please sign in to comment.