<?php

namespace App\Http\Controllers\Client\TypeRoom;

use App\Http\Controllers\Controller;
use App\Http\Helpers\ResponseBuilder;
use App\Http\Helpers\ParamsValidator;
use App\Http\History\HistoryData;
use App\Http\History\HistoryTables;
use App\Modules\Shared\Application\SelectHandler;
use Illuminate\Support\Facades\DB;

class TypeRoomIndexController extends Controller
{
    private $oDomain;
    /** @var HistoryData */
    private $history;

    public function __construct()
    {
        $this->oDomain = "Type Room";
        $this->history = new HistoryData(HistoryTables::TYPE_ROOM);
    }

    public function __invoke($Id)
    {
        $oResponse  = array();

        // VALIDANDO DATOS
        $oResponse = ParamsValidator::Validate_Id($Id, $this->oDomain);

        //  INGRESANDO DATOS
        if ($oResponse["Response_Code"] == 200) {
            $oParam = array($Id);
            $oData = (new SelectHandler())->handle(DB::select('call sp_type_room_index(?)', $oParam));

            $oResponse["Response_Status"] = 200;
            $oResponse["Response_Code"] = 200;
            $oResponse["Response_Domain"] = $this->oDomain;
            $oResponse["Response_Message"] = $this->oDomain . " Index";
            $oResponse["Response_Data"] = $oData;
            $oResponse["Response_Error_Message"] = "";
            $oResponse["Response_Error_Reason"] = "";
        }

        return ResponseBuilder::Response($oResponse);
    }
}
