<?php

namespace App\Http\Controllers\Owner\PaxInformationRoomPassenger;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Owner\c_Admin_Session;
use App\Http\Controllers\Owner\PaxInformationRoomPassenger\Dto\PaxInformationRoomPassengerUpdateDTO;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\PaxInformationRoomPassenger\Application\Update\UpdatePaxInformationRoomPassengerQuery;
use App\Modules\Shared\Domain\Bus\Query\QueryBus;
use App\Modules\Shared\Validator\Infraestructure\LaravelDTOGenerator;
use Illuminate\Http\Request;

class PaxInformationRoomPassengerUpdateController extends Controller
{

    private string $domain = 'PaxInformationRoomPassenger';

    public function __construct(
        private QueryBus $queryBus,
        private LaravelDTOGenerator $dtoGenerator
    ) {}

    public function __invoke(Request $request)
    {
        /** @var PaxInformationRoomPassengerUpdateDTO $dto */
        $dto = $this->dtoGenerator->generate($request->all(), $this->domain, PaxInformationRoomPassengerUpdateDTO::class);
        $adminSession = c_Admin_Session::check($request);
        $this->queryBus->ask(new UpdatePaxInformationRoomPassengerQuery(
            $dto->Id_PaxInformationRoomPassenger,
            1, //$dto->PaxInformationRoomPassenger_Version,
            $dto->PaxInformationRoomPassenger_Status,
            $adminSession['Id_Admin']
        ));

        return ResponseBuilder::Response([
            "Response_Status"           => 200,
            "Response_Code"             => 200,
            "Response_Data"             => [],
            "Response_Domain"           => $this->domain,
            "Response_Message"          => 'Pasajero de habitación actualizado con éxito',
            "Response_Error_Message"    => '',
            "Response_Error_Reason"     => ''
        ]);
    }
}
