<?php
namespace Incoviba\Controller\Proyectos\Brokers;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Alias\View;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Exception;
use Incoviba\Service;

class Contracts extends Controller
{
    public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
                         Service\Proyecto\Broker\Contract $contractService,
                         int $broker_rut, int $contract_id): ResponseInterface
    {
        $contract = null;
        try {
            $contract = $contractService->getById($contract_id);
        } catch (Exception\ServiceAction\Read) {}

        return $view->render($response, 'proyectos.brokers.contracts.show', compact('contract'));
    }
}
