feat: api endpoints and xml sync for contingents data
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Utility;
|
||||
|
||||
class BookingUrlUtility
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $defaultBaseUrl,
|
||||
) {
|
||||
}
|
||||
|
||||
public function build(int $hotelId, int $dateId, ?string $myEpUrl = null): string
|
||||
{
|
||||
$query = http_build_query([
|
||||
'date_id' => $dateId,
|
||||
'hotel_id' => $hotelId,
|
||||
], '', '&', PHP_QUERY_RFC3986);
|
||||
|
||||
$baseUrlInput = null !== $myEpUrl && '' !== trim($myEpUrl)
|
||||
? $myEpUrl
|
||||
: $this->defaultBaseUrl;
|
||||
$baseUrl = $this->normalizeBaseUrl($baseUrlInput);
|
||||
if ('' === $baseUrl) {
|
||||
return sprintf('/bookings/create?%s', $query);
|
||||
}
|
||||
|
||||
return sprintf('%s/bookings/create?%s', $baseUrl, $query);
|
||||
}
|
||||
|
||||
private function normalizeBaseUrl(string $url): string
|
||||
{
|
||||
$trimmedUrl = trim($url);
|
||||
|
||||
return rtrim($trimmedUrl, '/');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user