<?php

namespace App\Http\Controllers\PaxInformationLink\PaxInformationRoom;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Owner\PaxInformationRoom\Dto\PaxInformationRoomIndexDTO;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\PaxInformationRoom\Application\Index\IndexPaxInformationRoomQuery;
use App\Modules\PaxInformationRoom\Application\PaxInformationRoomResponse;
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 PaxInformationRoomIndexController extends Controller
{
    private $domain;

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

    public function __invoke(Request $request, $Id)
    {
        /** @var PaxInformationRoomIndexDTO $dto */
        $dto = $this->dtoGenerator->generate($request->all(), $this->domain, PaxInformationRoomIndexDTO::class);
        /** @var PaxInformationRoomResponse $response */
        $response = $this->queryBus->ask(new IndexPaxInformationRoomQuery($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"     => '',
        ]);
    }
}
