<?php

namespace App\Http\Controllers\PaxInformationLink\PaxInformationRoomPassenger;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Owner\PaxInformationRoomPassenger\Dto\PaxInformationRoomPassengerIndexDTO;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\PaxInformationRoomPassenger\Application\Index\IndexPaxInformationRoomPassengerQuery;
use App\Modules\PaxInformationRoomPassenger\Application\PaxInformationRoomPassengerResponse;
use App\Modules\Shared\Domain\Bus\Query\QueryBus;
use App\Modules\Shared\Domain\Transaction;
use App\Modules\Shared\Validator\Infraestructure\LaravelDTOGenerator;
use Illuminate\Http\Request;

class PaxInformationRoomPassengerIndexController extends Controller
{
    private $domain;

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

    public function __invoke(Request $request, $Id)
    {
        /** @var PaxInformationRoomPassengerIndexDTO $dto */
        $dto = $this->dtoGenerator->generate($request->all(), $this->domain, PaxInformationRoomPassengerIndexDTO::class);
        /** @var PaxInformationRoomPassengerResponse $response */
        $response = $this->queryBus->ask(new IndexPaxInformationRoomPassengerQuery($Id, $dto->Populate));

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