diff --git a/app/resources/routes/api/external/toku.php b/app/resources/routes/api/external/toku.php index 52bd715..8d293e1 100644 --- a/app/resources/routes/api/external/toku.php +++ b/app/resources/routes/api/external/toku.php @@ -5,4 +5,6 @@ $app->group('/toku', function($app) { $app->post('/cuotas/{venta_id}[/]', [Toku::class, 'cuotas']); $app->post('/success[/]', [Toku::class, 'success']); $app->get('/test[/]', [Toku::class, 'test']); + $app->delete('/reset[/]', [Toku::class, 'reset']); + $app->post('/enqueue[/]', [Toku::class, 'enqueue']); }); diff --git a/app/src/Controller/API/Ventas/MediosPago/Toku.php b/app/src/Controller/API/Ventas/MediosPago/Toku.php index 1c45f0e..11311f0 100644 --- a/app/src/Controller/API/Ventas/MediosPago/Toku.php +++ b/app/src/Controller/API/Ventas/MediosPago/Toku.php @@ -1,6 +1,7 @@ withJson($response); } - $output = $tokuService->reset(); + $input = $request->getParsedBody(); + $output = [ + 'input' => $input, + 'success' => false + ]; + try { + $tokuService->reset($input['skips'] ?? []); + $output['success'] = true; + } catch (Exception $exception) {} return $this->withJson($response, $output); } public function enqueue(ServerRequestInterface $request, ResponseInterface $response, diff --git a/cli/src/Command/Ventas/MedioPagos/Toku/Reset.php b/cli/src/Command/Ventas/MedioPagos/Toku/Reset.php index e2572c0..dc17d61 100644 --- a/cli/src/Command/Ventas/MedioPagos/Toku/Reset.php +++ b/cli/src/Command/Ventas/MedioPagos/Toku/Reset.php @@ -7,12 +7,19 @@ use Incoviba\Common\Alias\Command; #[Console\Attribute\AsCommand(name: 'external:toku:reset')] class Reset extends Command { + protected function configure(): void + { + $this->addOption('venta_ids', 'vid', Console\Input\InputOption::VALUE_OPTIONAL, 'Venta IDs separated by |', ''); + } + protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int { $this->logger->debug("Running {$this->getName()}"); $uri = '/api/external/toku/reset'; - $output->writeln("GET {$uri}"); - $response = $this->client->get($uri); + $output->writeln("DELETE {$uri}"); + $body = ['venta_ids' => explode('|', $input->getArgument('venta_ids'))]; + $options = count($body) > 0 ? ['json' => $body] : []; + $response = $this->client->delete($uri, $options); $output->writeln("Response Code: {$response->getStatusCode()}"); return self::SUCCESS;