<?php

namespace App\Http\Controllers\Owner\CategoryProvider;

use App\Http\Controllers\Controller;
use App\Http\Helpers\ResponseBuilder;
use App\Http\History\HistoryData;
use App\Http\History\HistoryTables;
use App\Modules\CategoryProvider\Application\CategoryProviderResponse;
use App\Modules\CategoryProvider\Application\Index\IndexCategoryProviderQuery;
use App\Modules\Shared\Domain\Bus\Command\CommandBus;
use App\Modules\Shared\Domain\Bus\Query\QueryBus;
use App\Modules\Shared\Validator\Infraestructure\LaravelDTOGenerator;
use Illuminate\Http\Request;

final class CategoryProviderIndexController extends Controller
{
    private $domain;

    public function __construct(
        private CommandBus $commandBus,
        private QueryBus $queryBus,
        private LaravelDTOGenerator $dtoGenerator
    ) {
        $this->domain = "CategoryProvider";
    }

    public function __invoke(Request $request, $Id)
    {
        /** @var CategoryProviderResponse $insert */
        $response = $this->queryBus->ask(new IndexCategoryProviderQuery(
            id: $Id
        ));

        return ResponseBuilder::generate(
            [$response],
            ResponsesCategoryProvider::RESPONSE_INDEX,
            $this->domain
        );
    }
}
