41 lines
835 B
PHP
41 lines
835 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Contracts\WbSyncManagerInterface;
|
|
use App\Enums\WbEndpoint;
|
|
use Illuminate\Console\Command;
|
|
|
|
final class SyncStocksCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'sync:stocks {--date=}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Sync stocks from WB test API';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(WbSyncManagerInterface $manager): int
|
|
{
|
|
$date = (string)($this->option('date') ?? now()->toDateString());
|
|
|
|
$manager->start(WbEndpoint::STOCKS, $date);
|
|
|
|
$this->info('Sync started');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|