Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1.4 KB
Raw Blame
<?php

namespace HiEvents\Services\Application\Handlers\CheckInList;

use HiEvents\DomainObjects\CheckInListDomainObject;
use HiEvents\Services\Application\Handlers\CheckInList\DTO\UpsertCheckInListDTO;
use HiEvents\Services\Domain\CheckInList\UpdateCheckInListService;
use HiEvents\Services\Domain\Product\Exception\UnrecognizedProductIdException;

class UpdateCheckInlistHandler
{
    public function __construct(
        private readonly UpdateCheckInListService $updateCheckInlistService,
    ) {}

    /**
     * @throws UnrecognizedProductIdException
     */
    public function handle(UpsertCheckInListDTO $data): CheckInListDomainObject
    {
        $checkInList = (new CheckInListDomainObject)
            ->setId($data->id)
            ->setName($data->name)
            ->setDescription($data->description)
            ->setEventId($data->eventId)
            ->setExpiresAt($data->expiresAt)
            ->setActivatesAt($data->activatesAt)
            ->setEventOccurrenceId($data->eventOccurrenceId)
            ->setPublicShowAttendeeNotes($data->publicShowAttendeeNotes)
            ->setPublicShowQuestionAnswers($data->publicShowQuestionAnswers)
            ->setPublicShowOrderDetails($data->publicShowOrderDetails);

        return $this->updateCheckInlistService->updateCheckInlist(
            checkInList: $checkInList,
            productIds: $data->productIds
        );
    }
}