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