133 lines
4.2 KiB
PHP
133 lines
4.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use App\Entity\Groups\AccommodationBooking;
|
|
use Symfony\Component\Serializer\Attribute\Context;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|
|
|
final readonly class AccommodationBookingApiResponse
|
|
{
|
|
#[Groups(['api:single'])]
|
|
public string $uuid;
|
|
|
|
#[Groups(['api:single'])]
|
|
public string $status;
|
|
|
|
#[Groups(['api:single'])]
|
|
public string $type;
|
|
|
|
#[Groups(['api:single'])]
|
|
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
|
public ?\DateTimeImmutable $dateFrom;
|
|
|
|
#[Groups(['api:single'])]
|
|
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
|
public ?\DateTimeImmutable $dateTo;
|
|
|
|
#[Groups(['api:single'])]
|
|
public int $nights;
|
|
|
|
#[Groups(['api:single'])]
|
|
public int $paxCount;
|
|
|
|
#[Groups(['api:single'])]
|
|
public int $minorsCount;
|
|
|
|
#[Groups(['api:single'])]
|
|
public int $childrenCount;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?string $groupName;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?\DateTimeImmutable $acceptedAt;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?\DateTimeImmutable $confirmedAt;
|
|
|
|
#[Groups(['api:single'])]
|
|
public AccommodationBookingPersonalData $personalData;
|
|
|
|
#[Groups(['api:single'])]
|
|
public AccommodationBookingHotelInfo $accommodation;
|
|
|
|
#[Groups(['api:single'])]
|
|
public AccommodationBookingBoardServiceInfo $boardService;
|
|
|
|
/**
|
|
* @var list<AccommodationBookingAdditionalServiceItem>
|
|
*/
|
|
#[Groups(['api:single'])]
|
|
public array $additionalServices;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?int $accommodationDiscount;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?int $boardServiceDiscount;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?int $additionalServicesDiscount;
|
|
|
|
/** An absolute amount in minor units, subtracted after the three section discounts above. */
|
|
#[Groups(['api:single'])]
|
|
public ?int $totalDiscountAmount;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?string $totalDiscountLabel;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?int $totalPrice;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?string $pricingCurrency;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?int $pricingVersion;
|
|
|
|
/**
|
|
* @var array<string, mixed>|null
|
|
*/
|
|
#[Groups(['api:single'])]
|
|
public ?array $priceBreakdown;
|
|
|
|
/**
|
|
* @param array<string, mixed>|null $priceBreakdown
|
|
*/
|
|
public function __construct(AccommodationBooking $booking, ?array $priceBreakdown)
|
|
{
|
|
$this->uuid = $booking->getUuid();
|
|
$this->status = $booking->getStatus()->value;
|
|
$this->type = $booking->getOrigin()->value;
|
|
$this->dateFrom = $booking->getDateFrom();
|
|
$this->dateTo = $booking->getDateTo();
|
|
$this->nights = $booking->getNights();
|
|
$this->paxCount = $booking->getPaxCount();
|
|
$this->minorsCount = $booking->getMinorsCount();
|
|
$this->childrenCount = $booking->getChildrenCount();
|
|
$this->groupName = $booking->getGroupName();
|
|
$this->acceptedAt = $booking->getAcceptedAt();
|
|
$this->confirmedAt = $booking->getConfirmedAt();
|
|
$this->personalData = new AccommodationBookingPersonalData($booking);
|
|
$this->accommodation = new AccommodationBookingHotelInfo($booking->getAccommodation());
|
|
$this->boardService = new AccommodationBookingBoardServiceInfo($booking);
|
|
$this->additionalServices = array_map(
|
|
static fn (array $service) => new AccommodationBookingAdditionalServiceItem($service),
|
|
$booking->getAdditionalServices(),
|
|
);
|
|
$this->accommodationDiscount = $booking->getAccommodationDiscount();
|
|
$this->boardServiceDiscount = $booking->getBoardServiceDiscount();
|
|
$this->additionalServicesDiscount = $booking->getAdditionalServicesDiscount();
|
|
$this->totalDiscountAmount = $booking->getTotalDiscountAmount();
|
|
$this->totalDiscountLabel = $booking->getTotalDiscountLabel();
|
|
$this->totalPrice = $booking->getTotalPrice();
|
|
$this->pricingCurrency = $booking->getPricingCurrency();
|
|
$this->pricingVersion = $booking->getPricingVersion();
|
|
$this->priceBreakdown = $priceBreakdown;
|
|
}
|
|
}
|