feat: per method debug setting in BPN API client
This commit is contained in:
@@ -104,8 +104,12 @@ class ApiClient
|
||||
* @throws ApiClientException
|
||||
* @throws ResponseParserException
|
||||
*/
|
||||
public function updatePersonalData(string $email, string $password, PersonalData $personalData): Notification|PersonalData
|
||||
{
|
||||
public function updatePersonalData(
|
||||
string $email,
|
||||
string $password,
|
||||
PersonalData $personalData,
|
||||
bool $debug
|
||||
): Notification|PersonalData {
|
||||
$data = [
|
||||
'user' => $this->config['bpn_username'],
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_CUSTOMER_DATA),
|
||||
@@ -117,7 +121,7 @@ class ApiClient
|
||||
'adressdaten' => $personalData->toPayload(),
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_CUSTOMER_DATA, $data);
|
||||
return $this->sendRequest(static::TYPE_CUSTOMER_DATA, $data, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +184,7 @@ class ApiClient
|
||||
* @throws ApiClientException
|
||||
* @throws ResponseParserException
|
||||
*/
|
||||
public function updateBooking(BookingData $formData): Notification|BookingUpdate
|
||||
public function updateBooking(BookingData $formData, bool $debug = false): Notification|BookingUpdate
|
||||
{
|
||||
$payload = (new BookingDataProcessor())->createUpdateRequestPayload($formData);
|
||||
|
||||
@@ -192,7 +196,7 @@ class ApiClient
|
||||
...$payload,
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_BOOKING_UPDATE, $data);
|
||||
return $this->sendRequest(static::TYPE_BOOKING_UPDATE, $data, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +288,7 @@ class ApiClient
|
||||
* @throws ApiClientException
|
||||
* @throws ResponseParserException
|
||||
*/
|
||||
private function sendRequest(string $type, array $data): mixed
|
||||
private function sendRequest(string $type, array $data, bool $debug = false): mixed
|
||||
{
|
||||
$requestId = date(DATE_ATOM).uniqid();
|
||||
|
||||
@@ -300,7 +304,7 @@ class ApiClient
|
||||
'requestId' => $requestId,
|
||||
]);
|
||||
|
||||
if (true === $this->config['debug']) {
|
||||
if (true === $debug || true === $this->config['debug']) {
|
||||
$this->dumpXmlToFile('request', $requestId, $body);
|
||||
}
|
||||
|
||||
@@ -316,7 +320,7 @@ class ApiClient
|
||||
// message length (10 bytes) is prepended to actual message
|
||||
$xml = substr($response, 10);
|
||||
|
||||
if (true === $this->config['debug']) {
|
||||
if (true === $debug || true === $this->config['debug']) {
|
||||
$this->dumpXmlToFile('response', $requestId, $xml);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user