wip: booking process
This commit is contained in:
+45
-11
@@ -11,6 +11,7 @@ use App\BusProNet\Model\BookingUpdate;
|
||||
use App\BusProNet\Model\CrmAttributes;
|
||||
use App\BusProNet\Model\Notification;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Traits\ApiClientTrait;
|
||||
use App\BusProNet\XmlParser\ApiResponseParser;
|
||||
use App\Form\Model\BookingEditDto;
|
||||
@@ -31,7 +32,9 @@ class ApiClient
|
||||
public const TYPE_BASE_DATA_COUNTRIES = 'STAMMLAENDER';
|
||||
public const TYPE_MUTABLE_DATA = 'MOEGLICHEAENDERUNGEN';
|
||||
public const TYPE_AVAILABILITY = 'VERFUEGBARKEIT';
|
||||
public const TYPE_AVAILABILITY_HOTEL = 'VERFUEGBARKEITHOTEL';
|
||||
public const TYPE_BOOKING_UPDATE = 'BUCHUNGAENDERUNG';
|
||||
public const TYPE_PRODUCT_DATA = 'PRODUKTDATEN';
|
||||
|
||||
private array $config;
|
||||
|
||||
@@ -121,7 +124,7 @@ class ApiClient
|
||||
'adressdaten' => $personalData->toPayload(),
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_CUSTOMER_DATA, $data, $debug);
|
||||
return $this->sendRequest(static::TYPE_CUSTOMER_DATA, $data, [], $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,20 +199,19 @@ class ApiClient
|
||||
...$payload,
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_BOOKING_UPDATE, $data, $debug);
|
||||
return $this->sendRequest(static::TYPE_BOOKING_UPDATE, $data, [], $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
public function getMutableData(int $id): Notification|BaseData
|
||||
public function getMutableData(int $travelId): Notification|BaseData
|
||||
{
|
||||
$data = [
|
||||
'user' => $this->config['bpn_username'],
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_MUTABLE_DATA),
|
||||
'satz' => ['@typ' => static::TYPE_MUTABLE_DATA],
|
||||
'art' => 'Vorgang_Details',
|
||||
'idreise' => $id,
|
||||
'idreise' => $travelId,
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_MUTABLE_DATA, $data);
|
||||
@@ -218,18 +220,35 @@ class ApiClient
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
public function getAvailabilities(int $id): Notification|BaseData
|
||||
public function getAvailabilities(int $travelId): Notification|BaseData
|
||||
{
|
||||
$data = [
|
||||
'user' => $this->config['bpn_username'],
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_AVAILABILITY),
|
||||
'satz' => ['@typ' => static::TYPE_AVAILABILITY],
|
||||
'idreise' => $id,
|
||||
'idreise' => $travelId,
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_AVAILABILITY, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
public function getHotelAvailability(int $travelId, int $hotelId, \DateTimeInterface $dateTo): Notification|BaseData
|
||||
{
|
||||
$data = [
|
||||
'user' => $this->config['bpn_username'],
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_AVAILABILITY_HOTEL),
|
||||
'satz' => ['@typ' => static::TYPE_AVAILABILITY_HOTEL],
|
||||
'idreise' => $travelId,
|
||||
'idpartner' => $hotelId,
|
||||
'terminbis' => $dateTo->format('d.m.Y'),
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_AVAILABILITY_HOTEL, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
@@ -264,7 +283,7 @@ class ApiClient
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
public function getDocuments(string $email, string $password, int $id, string $type): mixed
|
||||
public function getDocuments(string $email, string $password, int $bookingId, string $type): mixed
|
||||
{
|
||||
$data = [
|
||||
'user' => $this->config['bpn_username'],
|
||||
@@ -273,7 +292,7 @@ class ApiClient
|
||||
'art' => $type,
|
||||
'email' => $email,
|
||||
'passwort' => $password,
|
||||
'idbuchung' => $id,
|
||||
'idbuchung' => $bookingId,
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_CUSTOMER_DATA, $data);
|
||||
@@ -282,7 +301,22 @@ class ApiClient
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
private function sendRequest(string $type, array $data, bool $debug = false): mixed
|
||||
public function getTravelData(int $travelId, ?int $hotelId = null): Notification|Travel
|
||||
{
|
||||
$data = [
|
||||
'user' => $this->config['bpn_username'],
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_PRODUCT_DATA),
|
||||
'satz' => ['@typ' => static::TYPE_PRODUCT_DATA],
|
||||
'idprodukt' => $travelId,
|
||||
];
|
||||
|
||||
return $this->sendRequest(static::TYPE_PRODUCT_DATA, $data, ['hotelId' => $hotelId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
private function sendRequest(string $type, array $data, array $additionalArgs = [], bool $debug = false): mixed
|
||||
{
|
||||
$requestId = date(DATE_ATOM).uniqid();
|
||||
|
||||
@@ -320,7 +354,7 @@ class ApiClient
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->responseParser->parseXmlString($type, $xml);
|
||||
return $this->responseParser->parseXmlString($type, $xml, $additionalArgs);
|
||||
} catch (ResponseParserException $e) {
|
||||
$this->dumpXmlToFile('response', $requestId, $xml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user