Merge remote-tracking branch 'origin/feature/cierres' into feature/cierres
This commit is contained in:
@ -9,7 +9,7 @@ class Reset extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addOption('venta_ids', 'vid', Console\Input\InputOption::VALUE_OPTIONAL, 'Venta IDs separated by |', '');
|
||||
$this->addOption('venta_ids', 'vid', Console\Input\InputOption::VALUE_REQUIRED, 'Venta IDs separated by |', '');
|
||||
}
|
||||
|
||||
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
|
||||
@ -17,10 +17,15 @@ class Reset extends Command
|
||||
$this->logger->debug("Running {$this->getName()}");
|
||||
$uri = '/api/external/toku/reset';
|
||||
$output->writeln("DELETE {$uri}");
|
||||
$body = ['venta_ids' => explode('|', $input->getArgument('venta_ids'))];
|
||||
$venta_ids = $input->getOption('venta_ids');
|
||||
$body = [];
|
||||
if (!empty($venta_ids)) {
|
||||
$body = ['skips' => ['subscription' => explode('|', $venta_ids)]];
|
||||
}
|
||||
$options = count($body) > 0 ? ['json' => $body] : [];
|
||||
$response = $this->client->delete($uri, $options);
|
||||
$output->writeln("Response Code: {$response->getStatusCode()}");
|
||||
$this->logger->debug("Response: {$response->getBody()->getContents()}");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
@ -45,7 +45,9 @@ class Login
|
||||
$body = $response->getBody()->getContents();
|
||||
$data = json_decode($body, true);
|
||||
if (!key_exists('token', $data)) {
|
||||
$this->logger->error('Token not found');
|
||||
$this->logger->error('Token not found', [
|
||||
'body' => $body
|
||||
]);
|
||||
return '';
|
||||
}
|
||||
$result = file_put_contents($this->tokenFilename, $data['token']);
|
||||
@ -93,7 +95,7 @@ class Login
|
||||
} catch (Exception $exception) {
|
||||
$this->logger->notice($exception);
|
||||
$savedToken = $this->login();
|
||||
if ($savedToken === '') {
|
||||
if ($savedToken === '' and file_exists($this->tokenFilename)) {
|
||||
unlink($this->tokenFilename);
|
||||
return '';
|
||||
}
|
||||
|
Reference in New Issue
Block a user