fix: treat api response properly
This commit is contained in:
@@ -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,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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user