<?php

// ----------------WebPage----------------------
namespace App\Http\Controllers\Owner\WebPage;

use App\Http\Controllers\Controller;
use App\Http\Helpers\ResponseBuilder;
use App\Modules\Leads\WebPage\Application\List\ListWebPageQuery;
use App\Modules\Leads\WebPage\Application\WebPageResponses;
use App\Modules\Shared\Domain\Bus\Query\QueryBus;
use App\Modules\Shared\Domain\Transaction;
use App\Providers\StorageProvider;

class WebPageListController extends Controller
{
    private $domain;

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

    public function __invoke($Action)
    {
        $this->transaction->begin();
        /** @var WebPageResponses $response */
        $response = $this->queryBus->ask(new ListWebPageQuery($Action));
        $this->transaction->commit();
        return ResponseBuilder::Response([
            "Response_Status"           => 200,
            "Response_Code"             => 200,
            "Response_Data"             => $response->data(),
            "Response_Domain"           => $this->domain,
            "Response_Message"          => 'Listado con éxito',
            "Response_Error_Message"    => '',
            "Response_Error_Reason"     => '',
        ]);
    }
}
