<?php

namespace App\Modules\DefinedService\Route\Application\Insert;

use App\Modules\DefinedService\Location\Domain\IdLocation;
use App\Modules\DefinedService\Route\Domain\IdRoute;
use App\Modules\DefinedService\Route\Domain\RouteDate;
use App\Modules\DefinedService\Route\Domain\RouteDateUpdate;
use App\Modules\DefinedService\Route\Domain\RouteDescription;
use App\Modules\DefinedService\Route\Domain\RouteStatus;
use App\Modules\DefinedService\Route\Domain\RouteVersion;
use App\Modules\DefinedService\TypeDefinedService\Domain\IdTypeDefinedService;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class InsertRouteQueryHandler implements QueryHandler
{
    public function __construct(private RouteInserter $inserter) {}

    public function __invoke(InsertRouteQuery $query): InsertRouteResponse
    {
        return new InsertRouteResponse($this->inserter->__invoke(
            new IdRoute(0),
            new RouteDate($query->date()),
            new RouteDateUpdate($query->dateUpdate()),
            new RouteVersion(1),
            new RouteStatus($query->status()),
            new IdLocation($query->idLocationStart()),
            new IdLocation($query->idLocationEnd()),
            new IdTypeDefinedService($query->idTypeDefinedService()),
            $query->idAdmin()
        ));
    }
}
