<?php

namespace App\Http\Controllers\Owner\BriefingPassenger;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Owner\BriefingPassenger\Dto\BriefingPassengerListDTO;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\DefinedService\BriefingPassenger\Application\List\ListBriefingPassengerQuery;
use App\Modules\DefinedService\BriefingPassenger\Application\BriefingPassengerResponses;
use App\Modules\Shared\Domain\Bus\Query\QueryBus;
use App\Modules\Shared\Validator\Infraestructure\LaravelDTOGenerator;
use Illuminate\Http\Request;

class BriefingPassengerListController extends Controller
{
    private $domain;

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

    public function __invoke(Request $request, $Action)
    {
        /** @var BriefingPassengerListDTO $dto */
        $dto = $this->dtoGenerator->generate($request->all(), $this->domain, BriefingPassengerListDTO::class);

        /** @var BriefingPassengerResponses $response */
        $response = $this->queryBus->ask(new ListBriefingPassengerQuery(
            $dto->type,
            $Action
        ));

        return ResponseBuilder::Response([
            "Response_Status"           => 200,
            "Response_Code"             => 200,
            "Response_Data"             => $response->data(),
            "Response_Domain"           => $this->domain,
            "Response_Message"          => 'Listado de briefings con éxito',
            "Response_Error_Message"    => '',
            "Response_Error_Reason"     => '',
        ]);
    }
}
