<?php

namespace App\Modules\DefinedService\Location\Application\Update;

use App\Modules\DefinedService\Location\Domain\IdLocation;
use App\Modules\DefinedService\Location\Domain\LocationAbrv;
use App\Modules\DefinedService\Location\Domain\LocationLatitude;
use App\Modules\DefinedService\Location\Domain\LocationLongitude;
use App\Modules\DefinedService\Location\Domain\LocationName;
use App\Modules\DefinedService\Location\Domain\LocationStatus;
use App\Modules\DefinedService\Location\Domain\LocationVersion;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class UpdateLocationQueryHandler implements QueryHandler
{
    public function __construct(private LocationUpdater $updater) {}

    public function __invoke(UpdateLocationQuery $query): UpdateLocationResponse
    {
        $this->updater->__invoke(
            new IdLocation($query->id()),
            new LocationName($query->name()),
            new LocationAbrv($query->abrv()),
            new LocationLatitude($query->latitude()),
            new LocationLongitude($query->longitude()),
            new LocationVersion($query->version()),
            new LocationStatus($query->status()),
            $query->idAdmin()
        );
        return new UpdateLocationResponse();
    }
}
