Version produccion
This commit is contained in:
40
common/Controller/API/UF/Value.php
Normal file
40
common/Controller/API/UF/Value.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Aldarien\Money\Common\Controller\API\UF;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Carbon\Carbon;
|
||||
use Aldarien\Money\UF\Handler as UFHandler;
|
||||
|
||||
class Value {
|
||||
public function __invoke(Request $request, Response $response, UFHandler $handler): Response {
|
||||
$fecha = Carbon::today();
|
||||
$valor = $handler->get($fecha);
|
||||
$output = [
|
||||
'uf' => [
|
||||
'date' => $fecha->format('Y-m-d'),
|
||||
'value' => $valor
|
||||
],
|
||||
'total' => 1
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
public function fecha(Request $request, Response $response, UFHandler $handler, $fecha): Response {
|
||||
$fecha = Carbon::parse($fecha);
|
||||
$valor = $handler->get($fecha);
|
||||
$output = [
|
||||
'uf' => [
|
||||
'date' => $fecha->format('Y-m-d'),
|
||||
'value' => $valor
|
||||
],
|
||||
'total' => 1
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
}
|
16
common/Controller/Web/Base.php
Normal file
16
common/Controller/Web/Base.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Aldarien\Money\Common\Controller\Web;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Carbon\Carbon;
|
||||
use Slim\Views\Blade as View;
|
||||
use Aldarien\Money\UF\Handler as UFHandler;
|
||||
|
||||
class Base {
|
||||
public function __invoke(Request $request, Response $response, View $view, UFHandler $handler): Response {
|
||||
$fecha = Carbon::today('America/Santiago');
|
||||
$valor = $handler->get($fecha);
|
||||
return $view->render($response, 'home', compact('fecha', 'valor'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user