feat: integrate with flysystem for xml data
This commit is contained in:
@@ -14,6 +14,8 @@ use App\BusProNet\Model\Notification;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\Form\Model\BookingData;
|
||||
use App\Form\Model\RegistrationData;
|
||||
use League\Flysystem\FilesystemException;
|
||||
use League\Flysystem\FilesystemOperator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
@@ -35,6 +37,7 @@ class ApiClient
|
||||
public function __construct(
|
||||
private readonly SerializerInterface $serializer,
|
||||
private readonly ApiResponseParser $responseParser,
|
||||
private readonly FilesystemOperator $xmlDump,
|
||||
private readonly LoggerInterface $logger,
|
||||
array $options
|
||||
) {
|
||||
@@ -329,11 +332,10 @@ 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']);
|
||||
try {
|
||||
$this->xmlDump->write($requestId . '_' . $type . '.xml', $body);
|
||||
} catch (FilesystemException $e) {
|
||||
}
|
||||
|
||||
file_put_contents($this->config['target_folder_dumps'].'/'.$requestId.'_'.$type.'.xml', $body);
|
||||
}
|
||||
|
||||
private function createKey(string $username, string $password, string $type): string
|
||||
@@ -355,7 +357,6 @@ class ApiClient
|
||||
$optionsResolver->setDefaults([
|
||||
'max_retries' => 25,
|
||||
'debug' => false,
|
||||
'target_folder_dumps' => '/tmp/bpn',
|
||||
]);
|
||||
|
||||
return $optionsResolver->resolve($options);
|
||||
|
||||
Reference in New Issue
Block a user