Completed
Push — master ( b7e091...1ca564 )
by Gilmar
23:34
created

Application::appendCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
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\Factory;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
use Gpupo\NetshoesSdk\Entity\Order\Order;
22
use Gpupo\NetshoesSdk\Entity\Product\Product;
23
24
/**
25
 * @codeCoverageIgnore
26
 */
27
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>'
33
        .'Atenção! Esta aplicação é apenas uma '
34
        .'ferramenta de apoio ao desenvolvedor e não deve ser usada no ambiente de produção!'
35
        .'</>');
36
37
        return parent::doRun($input, $output);
38
    }
39
40
    protected $commonParameters = [
41
        [
42
            'key' => 'client_id',
43
        ],
44
        [
45
            'key' => 'access_token',
46
        ],
47
        [
48
            'key'     => 'env',
49
            'options' => ['sandbox', 'marketplace'],
50
            'default' => 'sandbox',
51
            'name'    => 'Version',
52
        ],
53
        [
54
            'key'     => 'sslVersion',
55
            'options' => ['SecureTransport', 'TLS'],
56
            'default' => 'SecureTransport',
57
            'name'    => 'SSL Version',
58
        ],
59
        [
60
            'key'     => 'registerPath',
61
            'default' => false,
62
        ],
63
    ];
64
65
    public function factorySdk(array $options, $loggerChannel = 'bin', $verbose = false)
66
    {
67
        return  Factory::getInstance()->setup($options, $this->factoryLogger($loggerChannel, $verbose));
68
    }
69
70
    public function displayOrder(Order $order, OutputInterface $output)
71
    {
72
        $output->writeln('Order #<comment>'.$order->getId().'</comment>');
73
        $this->displayTableResults($output, [$order->toLog()]);
74
        $output->writeln('Shipping - Order #<comment>'.$order->getId().'</comment>');
75
        $this->displayTableResults($output, [$order->getShipping()->toLog()]);
76
77
        $output->writeln('Shipping Items - Order #<comment>'.$order->getId().'</comment>');
78
        $this->displayTableResults($output, $order->getShipping()->getItems()->toLog());
79
    }
80
81
    public function displayProduct(Product $p, OutputInterface $output)
82
    {
83
        $this->displayTableResults($output, [[
84
            'Id'           => $p->getProductId(),
85
            'Brand'        => $p->getBrand(),
86
            'Department'   => $p->getDepartment(),
87
            'Product Type' => $p->getProductType(),
88
        ]]);
89
90
        $output->writeln('<fg=yellow>Skus</>');
91
92
        $this->displayTableResults($output, $p->getSkus());
93
    }
94
}
95