<?php

namespace App\Http\Controllers\Owner\HtlCampLock;

use App\Http\Controllers\Controller;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\HtlCampLock\Application\HtlCampLockResponse;
use App\Modules\HtlCampLock\Application\Index\IndexHtlCampLockQuery;
use App\Modules\Shared\Domain\Bus\Query\QueryBus;
use App\Modules\Shared\Domain\Transaction;

class HtlCampLockIndexController extends Controller
{
    private $domain;

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

    public function __invoke($Id)
    {
        $this->transaction->begin();
        /** @var HtlCampLockResponse $response */
        $response = $this->queryBus->ask(new IndexHtlCampLockQuery($Id));
        $this->transaction->commit();

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