Completed
Push — master ( 24f6ce...c3efa2 )
by Guilherme
05:36
created

DefaultController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 2
lcom 0
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 19 1
A gcsInterfaceAction() 0 16 1
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PROCERGS\LoginCidadao\AccountingBundle\Controller;
12
13
use PROCERGS\LoginCidadao\AccountingBundle\Service\AccountingService;
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
16
use Symfony\Component\HttpFoundation\JsonResponse;
17
use Symfony\Component\HttpFoundation\Response;
18
19
/**
20
 * @codeCoverageIgnore
21
 */
22
class DefaultController extends Controller
23
{
24
    /**
25
     * @Route("/api/v1/accounting.{_format}", name="lc_accounting_data", defaults={"_format": "json"})
26
     */
27
    public function indexAction()
28
    {
29
        $start = new \DateTime('-1 month');
30
        $end = new \DateTime();
31
32
        /** @var AccountingService $accountingService */
33
        $accountingService = $this->get('procergs.lc.accounting');
34
        $data = $accountingService->getAccounting($start, $end);
35
36
        $response = [
37
            'date_interval' => [
38
                'start' => $start->format('c'),
39
                'end' => $end->format('c'),
40
            ],
41
            'accounting' => $data,
42
        ];
43
44
        return new JsonResponse($response);
45
    }
46
47
    /**
48
     * @Route("/api/v1/accounting/gcs-interface.{_format}", name="lc_accounting_gcs_interface", defaults={"_format": "json"})
49
     */
50
    public function gcsInterfaceAction()
51
    {
52
        /** @var AccountingService $accountingService */
53
        $accountingService = $this->get('procergs.lc.accounting');
54
55
        $gcsInterface = $accountingService->getGcsInterface(
56
            'LOGCIDADAO',
57
            new \DateTime("first day of previous month"),
58
            new \DateTime("last day of previous month")
59
        );
60
61
        $response = new Response($gcsInterface);
62
        $response->headers->set('Content-Type', 'text/plain');
63
64
        return $response;
65
    }
66
}
67