wip: booking process, refactoring
This commit is contained in:
@@ -59,8 +59,11 @@ class ApiResponseParser extends AbstractParser
|
||||
return (new AvailabilitiesParser())->parseRooms($resultNode);
|
||||
case ApiClient::TYPE_BOOKING_UPDATE:
|
||||
return (new BookingUpdateParser())->parse($resultNode);
|
||||
case ApiClient::TYPE_PRODUCTS:
|
||||
return (new ProductsParser())->parse($resultNode);
|
||||
case ApiClient::TYPE_PRODUCT_DATA:
|
||||
$travelNode = $crawler->filterXPath('//reise/termin');
|
||||
|
||||
return (new TravelParser())->parse($travelNode->first(), ...$additionalArgs);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\BusProNet\Model\BankAccount;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Communication;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\BusProNet\Model\Service;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class BookingParser extends AbstractParser
|
||||
@@ -40,7 +39,7 @@ class BookingParser extends AbstractParser
|
||||
$travelData = $node->filterXPath('//reise');
|
||||
|
||||
$booking->travelName = $travelData->attr('bezeichnung');
|
||||
$booking->travelId = $this->getIntOrNullValue($node->filterXPath('//idreise'));
|
||||
$booking->dateId = $this->getIntOrNullValue($node->filterXPath('//idreise'));
|
||||
$booking->travelCode = $travelData->attr('code');
|
||||
$booking->travelDate = $this->stringToDate($travelData->attr('termin'));
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class BookingsParser extends AbstractParser
|
||||
$booking->price = $this->getFloatOrNullValue($node->filterXPath('//preis'));
|
||||
$booking->bookingDate = $this->getDateTimeOrNullValue($node->filterXPath('//buchungsdatum'));
|
||||
$booking->travelName = $this->getStringOrNullValue($node->filterXPath('//reise'));
|
||||
$booking->travelId = $this->getIntOrNullValue($node->filterXPath('//idreise'));
|
||||
$booking->dateId = $this->getIntOrNullValue($node->filterXPath('//idreise'));
|
||||
$booking->travelDate = $this->getDateOrNullValue($node->filterXPath('//reisedatum'));
|
||||
$booking->hasDocuments = $this->getBoolValue($node->filterXPath('//reisedokument'));
|
||||
$booking->payment = $this->getFloatOrNullValue($node->filterXPath('//zahlung'));
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\XmlParser;
|
||||
|
||||
use App\BusProNet\Model\BaseData;
|
||||
use App\BusProNet\Model\Product;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class ProductsParser extends AbstractParser
|
||||
{
|
||||
public function parse(Crawler $result): BaseData
|
||||
{
|
||||
$products = [];
|
||||
|
||||
$result
|
||||
->filterXPath('//produkte/produkt')
|
||||
->each(function (Crawler $node) use (&$products) {
|
||||
if (false === empty($node->attr('code'))) {
|
||||
$product = new Product();
|
||||
$product->id = (int) $node->attr('id');
|
||||
$product->code = (string) $node->attr('code');
|
||||
$product->name = (string) $node->attr('bezeichnung');
|
||||
|
||||
$products[$product->id] = $product;
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
return new BaseData($products);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,9 @@ class TravelParser extends AbstractParser
|
||||
* Extracts all travel-related data from the XML node including dates,
|
||||
* pricing, services, rooms, pickups, and guide information.
|
||||
*
|
||||
* @param Crawler $node The XML node containing travel data
|
||||
* @param Crawler $node The XML node containing travel data
|
||||
* @param int|null $hotelId Optional hotel ID for specific hotel data
|
||||
*
|
||||
* @return Travel The parsed travel object
|
||||
*/
|
||||
public function parse(Crawler $node, ?int $hotelId = null): Travel
|
||||
@@ -67,6 +68,7 @@ class TravelParser extends AbstractParser
|
||||
* the XML structure. Each group contains multiple selection options.
|
||||
*
|
||||
* @param Crawler $node The XML node containing selection group data
|
||||
*
|
||||
* @return array<int, CrmSelectionGroup> Array of selection groups indexed by ID
|
||||
*/
|
||||
public function getSelectionGroups(Crawler $node): array
|
||||
@@ -104,6 +106,7 @@ class TravelParser extends AbstractParser
|
||||
* from the XML structure with pricing and availability information.
|
||||
*
|
||||
* @param Crawler $node The XML node containing additional service data
|
||||
*
|
||||
* @return array<int, Service> Array of additional services indexed by ID
|
||||
*/
|
||||
public function getAdditionalServices(Crawler $node): array
|
||||
@@ -139,6 +142,7 @@ class TravelParser extends AbstractParser
|
||||
* with scheduling, pricing, and direction information.
|
||||
*
|
||||
* @param Crawler $node The XML node containing transportation service data
|
||||
*
|
||||
* @return array<int, Service> Array of transportation services indexed by ID
|
||||
*/
|
||||
public function getTransportationServices(Crawler $node): array
|
||||
@@ -177,6 +181,7 @@ class TravelParser extends AbstractParser
|
||||
* and extracts name and phone contact details.
|
||||
*
|
||||
* @param Crawler $travelNode The XML node containing travel data
|
||||
*
|
||||
* @return Guide|null The guide object or null if no guide found
|
||||
*/
|
||||
public function getGuide(Crawler $travelNode): ?Guide
|
||||
@@ -204,8 +209,9 @@ class TravelParser extends AbstractParser
|
||||
* Date and time parsing is only performed for outbound journeys when
|
||||
* a default date is provided.
|
||||
*
|
||||
* @param Crawler $node The XML node containing pickup data
|
||||
* @param Crawler $node The XML node containing pickup data
|
||||
* @param \DateTimeImmutable|null $defaultDate Default date for time parsing (outbound only)
|
||||
*
|
||||
* @return array<int, Pickup> Array of pickup locations indexed by ID
|
||||
*/
|
||||
public function getPickups(Crawler $node, ?\DateTimeImmutable $defaultDate = null): array
|
||||
@@ -237,8 +243,9 @@ class TravelParser extends AbstractParser
|
||||
* Retrieves the hotel node either by specific hotel ID or returns
|
||||
* the first hotel node if no ID is specified.
|
||||
*
|
||||
* @param Crawler $node The XML node containing hotel data
|
||||
* @param Crawler $node The XML node containing hotel data
|
||||
* @param int|null $hotelId Optional hotel ID to filter by
|
||||
*
|
||||
* @return Crawler The hotel XML node
|
||||
*/
|
||||
public function getHotelNode(Crawler $node, ?int $hotelId): Crawler
|
||||
@@ -260,6 +267,7 @@ class TravelParser extends AbstractParser
|
||||
* and board options from the hotel XML structure.
|
||||
*
|
||||
* @param Crawler $node The XML node containing room data
|
||||
*
|
||||
* @return array<int, Room> Array of rooms indexed by room ID
|
||||
*/
|
||||
public function getRooms(Crawler $node): array
|
||||
|
||||
Reference in New Issue
Block a user