<?php

namespace App\Modules\Leads\WebPage\Application\Find;

use App\Modules\Leads\WebPage\Application\WebPageResponse;
use App\Modules\Leads\WebPage\Domain\IdWebPage;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class FindWebPageQueryHandler implements QueryHandler
{
    public function __construct(private WebPageFinder $finder) {}

    public function __invoke(FindWebPageQuery $query): WebPageResponse
    {
        $model = $this->finder->__invoke(new IdWebPage($query->getId()), true);
        return new WebPageResponse(
            $model->id()->value(),
            $model->name()->value(),
            $model->domain()->value(),
            $model->description()->value(),
            $model->version()->value(),
            $model->status()->value(),
            $model->idLanguage()->value(),
        );
    }
}
