wip: submit booking to api
This commit is contained in:
@@ -15,18 +15,18 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
*/
|
||||
class Address
|
||||
{
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
|
||||
public ?string $street = null;
|
||||
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
|
||||
public ?string $postCode = null;
|
||||
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
|
||||
public ?string $city = null;
|
||||
|
||||
public ?string $district = null;
|
||||
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
|
||||
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
|
||||
public ?string $country = null;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
final readonly class Agency
|
||||
{
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public string $name,
|
||||
public string $code,
|
||||
public ?string $street = null,
|
||||
public ?string $postCode = null,
|
||||
public ?string $city = null,
|
||||
public ?string $phone = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
/**
|
||||
* Represents a successful API response from a booking request.
|
||||
*
|
||||
* Response structure for successful requests:
|
||||
* - <buchung>möglich</buchung> = inquiry validation successful
|
||||
* - <buchung>erfolgt</buchung> = booking creation successful
|
||||
*
|
||||
* Error responses return Notification objects instead (typ="HINWEIS").
|
||||
*/
|
||||
class BookingResponse
|
||||
{
|
||||
/**
|
||||
* @param string $status Booking status (möglich|erfolgt)
|
||||
* @param string|null $transactionNumber Transaction number (vorgang)
|
||||
* @param array<int, PriceItem> $priceItems Individual price items from response
|
||||
* @param float|null $totalPrice Total price (gesamtpreis)
|
||||
* @param PaymentTerms|null $paymentTerms Payment terms (anzahlung/restzahlung)
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $status,
|
||||
public readonly ?string $transactionNumber = null,
|
||||
public readonly array $priceItems = [],
|
||||
public readonly ?float $totalPrice = null,
|
||||
public readonly ?PaymentTerms $paymentTerms = null,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the inquiry validation was successful.
|
||||
*/
|
||||
public function isInquiryValid(): bool
|
||||
{
|
||||
return 'möglich' === $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the booking was successfully created.
|
||||
*/
|
||||
public function isBookingSuccessful(): bool
|
||||
{
|
||||
return 'erfolgt' === $this->status;
|
||||
}
|
||||
}
|
||||
@@ -175,4 +175,4 @@ class Insurance
|
||||
|
||||
return array_values(array_unique($urls));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
/**
|
||||
* Represents payment terms from the booking response.
|
||||
*/
|
||||
class PaymentTerms
|
||||
{
|
||||
public function __construct(
|
||||
public readonly ?float $depositAmount = null,
|
||||
public readonly ?string $depositDate = null,
|
||||
public readonly ?float $finalPaymentAmount = null,
|
||||
public readonly ?string $finalPaymentDate = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
/**
|
||||
* Represents a single price item from the booking response.
|
||||
*/
|
||||
class PriceItem
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $position,
|
||||
public readonly string $type,
|
||||
public readonly ?string $subType,
|
||||
public readonly string $label,
|
||||
public readonly ?string $dateFrom,
|
||||
public readonly ?string $dateTo,
|
||||
public readonly int $quantity,
|
||||
public readonly ?string $assignment,
|
||||
public readonly float $unitPrice,
|
||||
public readonly float $totalPrice,
|
||||
public readonly ?string $id,
|
||||
) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user