feat: parse travel guide per date
This commit is contained in:
@@ -48,3 +48,8 @@ GET {{base_url}}/api/travels
|
||||
Accept: application/json
|
||||
Authorization: Bearer {{$auth.token("oauth2_api")}}
|
||||
|
||||
### API travel
|
||||
GET {{base_url}}/api/travels/DWWMP301125
|
||||
Accept: application/json
|
||||
Authorization: Bearer {{$auth.token("oauth2_api")}}
|
||||
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
class Guide
|
||||
{
|
||||
#[Groups(['api:single'])]
|
||||
public ?string $name = null;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?string $phone = null;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,9 @@ class Travel
|
||||
#[Groups(['api:single'])]
|
||||
public bool $participantCountMutable = true;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?Guide $guide = null;
|
||||
|
||||
public function getAdditionalServicesByGroup(mixed $group, bool $availableOnly = true): array
|
||||
{
|
||||
$group = (array) $group;
|
||||
|
||||
@@ -132,7 +132,7 @@ class TravelLoader extends AbstractLoader
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->id = (int) $node->attr('idbuspro');
|
||||
$travel->hotelId = $hotelId;
|
||||
$travel->hotelId = (int) $hotelNode->attr('idbuspro');
|
||||
$travel->label = $this->getStringOrNullValue($node->filterXPath('//text'));
|
||||
$travel->dateFrom = $this->stringToDate($node->attr('termin'));
|
||||
$travel->dateTo = $this->stringToDate($node->attr('bis'));
|
||||
@@ -147,6 +147,7 @@ class TravelLoader extends AbstractLoader
|
||||
$travel->rooms = $this->getRooms($hotelNode);
|
||||
$travel->pickupsTo = $this->getPickups($node->filterXPath('//zustiege/zustieg'));
|
||||
$travel->pickupsFro = $this->getPickups($node->filterXPath('//zustiege_rueck/zustieg_rueck'));
|
||||
$travel->guide = $this->getGuide($node);
|
||||
|
||||
return $travel;
|
||||
}
|
||||
@@ -205,17 +206,22 @@ class TravelLoader extends AbstractLoader
|
||||
return $additionalServices;
|
||||
}
|
||||
|
||||
public function getGuideForTransportationService(\SimpleXMLElement $xmlTransportationService): ?Guide
|
||||
public function getGuide(Crawler $travelNode): ?Guide
|
||||
{
|
||||
if (null === $xmlTransportationService->reiseleiter) {
|
||||
return null;
|
||||
$guideNodes = $travelNode
|
||||
->filterXPath('//lei_befoerderung/leistung[@unterart="BUS"]/zustiegsplanung/reiseleiter');
|
||||
|
||||
if (0 < $guideNodes->count()) {
|
||||
$guideNode = $guideNodes->first();
|
||||
|
||||
$guide = new Guide();
|
||||
$guide->name = $this->getStringOrNullValue($guideNode->filterXPath('//name'));
|
||||
$guide->phone = $this->getStringOrNullValue($guideNode->filterXPath('//telefon'));
|
||||
|
||||
return $guide;
|
||||
}
|
||||
|
||||
$guide = new Guide();
|
||||
$guide->name = $xmlTransportationService->reiseleiter->name;
|
||||
$guide->phone = $xmlTransportationService->reiseleiter->telefon;
|
||||
|
||||
return $guide;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTransportationServices(Crawler $node): array
|
||||
|
||||
@@ -38,7 +38,8 @@ class TravelController extends AbstractController
|
||||
#[Route(
|
||||
path: '/travels/{travelId}/{hotelId}',
|
||||
name: 'api_travel_single_id',
|
||||
requirements: ['travelId' => '\d+', 'hotelId' => '\d+']
|
||||
requirements: ['travelId' => '\d+', 'hotelId' => '\d+'],
|
||||
defaults: ['hotelId' => null],
|
||||
)]
|
||||
public function singleById(int $travelId, ?int $hotelId = null): JsonResponse
|
||||
{
|
||||
@@ -50,6 +51,7 @@ class TravelController extends AbstractController
|
||||
#[Route(
|
||||
path: '/travels/{travelCode}/{hotelCode}',
|
||||
name: 'api_travel_single_code',
|
||||
defaults: ['hotelCode' => null],
|
||||
)]
|
||||
public function singleByCode(string $travelCode, ?string $hotelCode = null): JsonResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user