<?php

namespace App\Modules\Leads\WebChannel\Application\Index;

use App\Modules\Leads\WebChannel\Application\WebChannelResponse;
use App\Modules\Leads\WebChannel\Domain\IdWebChannel;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class IndexWebChannelQueryHandler implements QueryHandler
{
    public function __construct(private WebChannelIndexer $inserter) {}

    public function __invoke(IndexWebChannelQuery $query): WebChannelResponse
    {
        $model = $this->inserter->__invoke(new IdWebChannel($query->getId()));
        return new WebChannelResponse(
            $model->id()->value(),
            $model->date()->value(),
            $model->dateUpdate()->value(),
            $model->name()->value(),
            $model->icon()->value(),
            $model->iconThumb()->value(),
            $model->version()->value(),
            $model->status()->value(),
            $model->bookingType()->value(),
            $model->order()->value()
        );
    }
}
