-
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.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
app/Console/Commands/Connectors/Zoho/ZohoLeadsDownloadCommand.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,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; | ||
} | ||
} |