<?php

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

use App\Modules\Leads\WebPage\Domain\IdWebPage;
use App\Modules\Leads\WebPage\Domain\WebPageDescription;
use App\Modules\Leads\WebPage\Domain\WebPageDomain;

use App\Modules\Leads\WebPage\Domain\WebPageName;
use App\Modules\Leads\WebPage\Domain\WebPageStatus;
use App\Modules\Leads\WebPage\Domain\WebPageVersion;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class UpdateWebPageQueryHandler implements QueryHandler
{
    public function __construct(private WebPageUpdater $updater) {}

    public function __invoke(UpdateWebPageQuery $query): UpdateWebPageResponse
    {
        $this->updater->__invoke(
            new IdWebPage($query->id()),
            new WebPageName($query->name()),
            new WebPageDomain($query->domain()),
            new WebPageDescription($query->description()),
            new WebPageVersion($query->version()),
            new WebPageStatus($query->status()),
            $query->idAdmin(),
            $query->idLanguage(),
        );
        return new UpdateWebPageResponse();
    }
}
