feat: dump request/response for debugging
This commit is contained in:
@@ -149,10 +149,7 @@ class ApiClient
|
|||||||
;
|
;
|
||||||
|
|
||||||
if (true === $this->config['debug']) {
|
if (true === $this->config['debug']) {
|
||||||
$this->logger->info('Request sent', [
|
$this->dumpXmlToFile('request', $requestId, $body);
|
||||||
'id' => $requestId,
|
|
||||||
'request' => $body,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$socket = $this->connect(
|
$socket = $this->connect(
|
||||||
@@ -168,15 +165,21 @@ class ApiClient
|
|||||||
$xml = substr($response, 10);
|
$xml = substr($response, 10);
|
||||||
|
|
||||||
if (true === $this->config['debug']) {
|
if (true === $this->config['debug']) {
|
||||||
$this->logger->info('Response received', [
|
$this->dumpXmlToFile('response', $requestId, $xml);
|
||||||
'id' => $requestId,
|
|
||||||
'response' => $xml,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->responseParser->parseXmlString($type, $xml);
|
return $this->responseParser->parseXmlString($type, $xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($this->config['target_folder_dumps'].'/'.$requestId.'_'.$type.'.xml', $body);
|
||||||
|
}
|
||||||
|
|
||||||
private function createKey(string $username, string $password, string $type): string
|
private function createKey(string $username, string $password, string $type): string
|
||||||
{
|
{
|
||||||
$date = (new \DateTimeImmutable())->format('Ymd');
|
$date = (new \DateTimeImmutable())->format('Ymd');
|
||||||
@@ -196,6 +199,7 @@ class ApiClient
|
|||||||
$optionsResolver->setDefaults([
|
$optionsResolver->setDefaults([
|
||||||
'max_retries' => 25,
|
'max_retries' => 25,
|
||||||
'debug' => false,
|
'debug' => false,
|
||||||
|
'target_folder_dumps' => '/var/www/html/var/bpn',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $optionsResolver->resolve($options);
|
return $optionsResolver->resolve($options);
|
||||||
|
|||||||
Reference in New Issue
Block a user