<?php
namespace Incoviba\Controller\API;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Service;

class Informes
{
    use withJson;

    public function diario(ServerRequestInterface $request, ResponseInterface $response, Service\Informes\Diario $diarioService): ResponseInterface
    {
        $body = $request->getParsedBody();
        $output = [
            'input' => $body,
            'data' => []
        ];
        try {
            $file = $request->getUploadedFiles()['file'];
            $output['data'] = $diarioService->process($file);
        } catch (\Error) {}
        return $this->withJson($response, $output);
    }
}
