Skip to content

Commit

Permalink
feat: add new command
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Jul 27, 2024
1 parent 1b733ae commit 316a7d7
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions app/Console/Commands/Connectors/Zoho/ZohoLeadsDownloadCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands\Connectors\Shopify;

use Baka\Traits\KanvasJobsTrait;
use Illuminate\Console\Command;
use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Models\Companies;
use Kanvas\Connectors\Zoho\Actions\DownloadAllZohoLeadAction;
use Kanvas\Guild\Leads\Models\LeadReceiver;

class ShopifyInventoryDownloadCommand extends Command
{
use KanvasJobsTrait;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'kanvas:guild-zoho-lead-sync {app_id} {company_id} {receiver_id} {page=50} {leadsPerPage=200}';

/**
* The console command description.
*
* @var string|null
*/
protected $description = 'Download all leads from Zoho to this branch';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$app = Apps::getById((int) $this->argument('app_id'));
$this->overwriteAppService($app);
$company = Companies::getById((int) $this->argument('company_id'));
$leadReceiver = LeadReceiver::getByIdFromCompanyApp((int) $this->argument('receiver_id'), $company, $app);
$page = (int) $this->argument('page');
$leadsPerPage = (int) $this->argument('leadsPerPage');

$downloadAllLeads = new DownloadAllZohoLeadAction($app, $company, $leadReceiver);
$downloadAllLeads->execute($page, $leadsPerPage);

$this->info($downloadAllLeads->getTotalLeadsProcessed() . ' leads downloaded from Zoho to ' . $leadReceiver->name);

return;
}
}

0 comments on commit 316a7d7

Please sign in to comment.