<?php
namespace ProVM\KI\Common\Controller\Web;

use Psr\Container\ContainerInterface as Container;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Carbon\Carbon;
use ProVM\KI\Common\Service\Indicadores as Service;

class Indicadores {
  public function get(Request $request, Response $response, Container $container, Service $service, $indicador) {
    $valor = $service->get($indicador, Carbon::today());

    $output = [
      'sim' => $indicador,
      'valor' => $valor,
    ];
    $response->getBody()->write(json_encode($output));
    return $response
      ->withHeader('Content-Type', 'application/json')
      ->withStatus(201);
  }
}
