From e4a1a992be655b536b618e492ad7228a9324f454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 8 Jan 2026 14:23:22 +0100 Subject: [PATCH] feat: command to read xml-dumps from bpn api by provided request id --- src/Command/ReadXmlDumpCommand.php | 71 ++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/Command/ReadXmlDumpCommand.php diff --git a/src/Command/ReadXmlDumpCommand.php b/src/Command/ReadXmlDumpCommand.php new file mode 100644 index 0000000..b22c0be --- /dev/null +++ b/src/Command/ReadXmlDumpCommand.php @@ -0,0 +1,71 @@ +addArgument('requestId', InputArgument::REQUIRED, 'The request ID to look up') + ->addOption('type', 't', InputOption::VALUE_REQUIRED, 'Dump type: request or response', 'request'); + } + + /** + * @see \Symfony\Component\Console\Command\Command::execute() + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + + $requestId = $input->getArgument('requestId'); + $type = $input->getOption('type'); + + if (false === in_array($type, ['request', 'response'], true)) { + $io->error('Invalid type. Must be "request" or "response".'); + + return Command::FAILURE; + } + + $filename = $requestId.'_'.$type.'.xml'; + + try { + if (false === $this->xmlDump->fileExists($filename)) { + $io->warning(sprintf('Dump file "%s" not found. It may have been cleaned up.', $filename)); + + return Command::FAILURE; + } + + $content = $this->xmlDump->read($filename); + $output->writeln($content); + + return Command::SUCCESS; + } catch (FilesystemException $e) { + $io->error(sprintf('Failed to read dump file: %s', $e->getMessage())); + + return Command::FAILURE; + } + } +}