<?php

namespace App\Modules\DefinedService\OfficesBriefing\Application\Index;

use App\Modules\DefinedService\OfficesBriefing\Application\OfficesBriefingResponse;
use App\Modules\DefinedService\OfficesBriefing\Domain\IdBriefingOffice;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class IndexOfficesBriefingQueryHandler implements QueryHandler
{
    public function __construct(private OfficesBriefingIndexer $inserter) {}

    public function __invoke(IndexOfficesBriefingQuery $query): OfficesBriefingResponse
    {
        $model = $this->inserter->__invoke(
            new IdBriefingOffice($query->getId())
        );

        return new OfficesBriefingResponse(
            $model->id()->value(),
            $model->date()->value(),
            $model->dateUpdate()->value(),
            $model->name()->value(),
            $model->status()->value(),
            $model->color()->value(),
            $model->capacity()->value(),
            $model->idParentOffice()->value(),
            $model->idLocation()->value(),
        );
    }
}
