fix: treat api response properly

This commit is contained in:
Björn Fromme
2025-02-19 12:25:35 +01:00
parent 6086369ce5
commit 063af73f3b
3 changed files with 8 additions and 7 deletions
+2 -3
View File
@@ -5,7 +5,6 @@ namespace App\BusProNet\Model;
class BookingUpdate
{
public bool $valid = false;
public bool $success = false;
public ?string $status = null;
public array $prices = [];
public ?float $totalPrice = null;
}
}
@@ -11,8 +11,9 @@ class BookingUpdateParser extends AbstractParser
{
$bookingUpdate = new BookingUpdate();
$bookingUpdate->valid = 'möglich' === $node->filterXPath('//aenderung')->text();
$bookingUpdate->totalPrice = $this->getFloatOrNullValue($node->filterXPath('//gesamtpreis'));
$bookingUpdate->success = 'erfolgt' === $node->filterXPath('//aenderung')->text();
$bookingUpdate->status = $node->filterXPath('//status')->text();
return $bookingUpdate;
}
}
}
+3 -2
View File
@@ -3,6 +3,7 @@
namespace App\Controller\Booking;
use App\BusProNet\ApiClient;
use App\BusProNet\Model\Notification;
use App\BusProNet\XmlLoader\PickupLoader;
use App\BusProNet\XmlLoader\TravelLoader;
use App\Form\BookingType;
@@ -93,7 +94,7 @@ class EditController extends AbstractController
'email' => $bpnUser->getEmail(),
'booking_id' => $id,
]);
if (false === $response->isSuccessful()) {
if ($response instanceof Notification && false === $response->isSuccessful()) {
$this->addFlash('error', $response->message);
$this->logger->error('Error initiating booking update', [
'email' => $bpnUser->getEmail(),
@@ -125,4 +126,4 @@ class EditController extends AbstractController
'form' => $form->createView(),
]);
}
}
}