feat: integrate with flysystem for xml data
This commit is contained in:
1 parent
42b7c2b546
commit
a92832f069
11 files changed
+601
-21
No files matched your search
@@ -7,6 +7,8 @@ use App\BusProNet\Model\CrmAttributesResponse;
|
||||
use App\BusProNet\Model\NotificationResponse;
|
||||
use App\BusProNet\Model\ProfileResponse;
|
||||
use App\Entity\User;
|
||||
use League\Flysystem\FilesystemException;
|
||||
use League\Flysystem\FilesystemOperator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
@@ -28,6 +30,7 @@ class ApiClient
|
||||
private readonly SerializerInterface $serializer,
|
||||
private readonly ResponseParser $responseParser,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly FilesystemOperator $xmlDump,
|
||||
array $options
|
||||
) {
|
||||
$this->config = $this->resolveOptions($options);
|
||||
@@ -173,11 +176,12 @@ class ApiClient
|
||||
|
||||
private function dumpXmlToFile(string $type, string $requestId, string $body): void
|
||||
{
|
||||
if (false === file_exists($this->config['target_folder_dumps'])) {
|
||||
mkdir($this->config['target_folder_dumps']);
|
||||
$filename = $requestId.'_'.$type.'.xml';
|
||||
try {
|
||||
$this->xmlDump->write($filename, $body);
|
||||
} catch (FilesystemException $e) {
|
||||
$this->logger->error('Unable to dump XML file '.$e->getMessage());
|
||||
}
|
||||
|
||||
file_put_contents($this->config['target_folder_dumps'].'/'.$requestId.'_'.$type.'.xml', $body);
|
||||
}
|
||||
|
||||
private function createKey(string $username, string $password, string $type): string
|
||||
@@ -199,9 +203,8 @@ class ApiClient
|
||||
$optionsResolver->setDefaults([
|
||||
'max_retries' => 25,
|
||||
'debug' => false,
|
||||
'target_folder_dumps' => '/var/www/html/var/bpn',
|
||||
]);
|
||||
|
||||
return $optionsResolver->resolve($options);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user