Completed
Push — master ( d15f5b...9b96d8 )
by Gilmar
26:33
created

Application::jsonLoadFromFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of gpupo/netshoes-sdk
5
 * Created by Gilmar Pupo <[email protected]>
6
 * For the information of copyright and license you should read the file
7
 * LICENSE which is distributed with this source code.
8
 * Para a informação dos direitos autorais e de licença você deve ler o arquivo
9
 * LICENSE que é distribuído com este código-fonte.
10
 * Para obtener la información de los derechos de autor y la licencia debe leer
11
 * el archivo LICENSE que se distribuye con el código fuente.
12
 * For more information, see <http://www.g1mr.com/>.
13
 */
14
15
namespace Gpupo\NetshoesSdk\Console;
16
17
use Gpupo\CommonSdk\Console\AbstractApplication;
18
use Gpupo\NetshoesSdk\Entity\Order\Order;
19
use Gpupo\NetshoesSdk\Entity\Product\Product;
20
use Gpupo\NetshoesSdk\Factory;
21
use Symfony\Component\Console\Input\InputInterface;
22
use Symfony\Component\Console\Output\OutputInterface;
23
24
/**
25
 * @codeCoverageIgnore
26
 */
27
final class Application extends AbstractApplication
28
{
29
    public function doRun(InputInterface $input, OutputInterface $output)
30
    {
31
        $output->writeln('<bg=green;options=bold>gpupo/netshoes-sdk</>');
32
        $output->writeln('<options=bold>Atenção! Esta aplicação é apenas uma '
33
        .'ferramenta de apoio ao desenvolvedor e não deve ser usada no ambiente de produção!'
34
        .'</>');
35
36
        return parent::doRun($input, $output);
37
    }
38
39
    protected $commonParameters = [
40
        [
41
            'key' => 'client_id',
42
        ],
43
        [
44
            'key' => 'access_token',
45
        ],
46
        [
47
            'key'     => 'env',
48
            'options' => ['sandbox', 'marketplace'],
49
            'default' => 'sandbox',
50
            'name'    => 'Version',
51
        ],
52
        [
53
            'key'     => 'sslVersion',
54
            'options' => ['SecureTransport', 'TLS'],
55
            'default' => 'SecureTransport',
56
            'name'    => 'SSL Version',
57
        ],
58
        [
59
            'key'     => 'registerPath',
60
            'default' => false,
61
        ],
62
    ];
63
64
    public function factorySdk(array $options, $loggerChannel = 'bin', $verbose = false)
65
    {
66
        return  Factory::getInstance()->setup($options, $this->factoryLogger($loggerChannel, $verbose));
67
    }
68
69
    public function displayOrder(Order $order, OutputInterface $output)
70
    {
71
        $output->writeln('Order #<comment>'.$order->getId().'</comment>');
72
        $this->displayTableResults($output, [$order->toLog()]);
73
        $this->displayTableResults($output, $order->getShipping()->getCustomer()->toLog());
74
        $this->displayTableResults($output, [$order->getShipping()->getInvoice()->toArray()]);
75
        $this->displayTableResults($output, [$order->getShipping()->getTransport()->toArray()]);
76
        $this->displayTableResults($output, $order->getShipping()->getItems()->toLog());
77
    }
78
79
    public function displayProduct(Product $p, OutputInterface $output)
80
    {
81
        $this->displayTableResults($output, [[
82
            'Id'           => $p->getProductId(),
83
            'Brand'        => $p->getBrand(),
84
            'Department'   => $p->getDepartment(),
85
            'Product Type' => $p->getProductType(),
86
        ]]);
87
88
        $output->writeln('<fg=yellow>Skus</>');
89
        $this->displayTableResults($output, $p->getSkus());
90
    }
91
}
92