<?php

namespace App\Modules\LodgingPlace\Application\Update;

use App\Modules\LodgingPlace\Domain\IdLodgingPlace;
use App\Modules\LodgingPlace\Domain\LodgingPlaceDirection;
use App\Modules\LodgingPlace\Domain\LodgingPlaceIcon;
use App\Modules\LodgingPlace\Domain\LodgingPlaceLatitude;
use App\Modules\LodgingPlace\Domain\LodgingPlaceLongitude;
use App\Modules\LodgingPlace\Domain\LodgingPlaceName;
use App\Modules\LodgingPlace\Domain\LodgingPlacePlace;
use App\Modules\LodgingPlace\Domain\LodgingPlaceStatus;
use App\Modules\LodgingPlace\Domain\LodgingPlaceVersion;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class UpdateLodgingPlaceQueryHandler implements QueryHandler
{
    public function __construct(private LodgingPlaceUpdater $updater) {}

    public function __invoke(UpdateLodgingPlaceQuery $query): UpdateLodgingPlaceResponse
    {
        $this->updater->__invoke(
            new IdLodgingPlace($query->id()),
            new LodgingPlaceName($query->name()),
            new LodgingPlaceDirection($query->direction()),
            new LodgingPlaceLongitude($query->longitude()),
            new LodgingPlaceLatitude($query->latitude()),
            new LodgingPlaceVersion($query->version()),
            new LodgingPlaceStatus($query->status()),
            new LodgingPlaceIcon($query->icon()),
            new LodgingPlacePlace($query->place()),
            $query->idAdmin()
        );
        return new UpdateLodgingPlaceResponse();
    }
}
