|
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
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
use Exception; |
|
24
|
|
|
|
|
25
|
|
|
class Application extends AbstractApplication |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
public function doRun(InputInterface $input, OutputInterface $output) |
|
29
|
|
|
{ |
|
30
|
|
|
$output->writeln('<bg=green;options=bold>gpupo/netshoes-sdk</>'); |
|
31
|
|
|
$output->writeln('<options=bold>' |
|
32
|
|
|
. "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
|
|
|
."\n" |
|
35
|
|
|
. '</>' |
|
36
|
|
|
."\n" |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
return parent::doRun($input, $output); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
protected $commonParameters = [ |
|
43
|
|
|
[ |
|
44
|
|
|
'key' => 'client_id', |
|
45
|
|
|
], |
|
46
|
|
|
[ |
|
47
|
|
|
'key' => 'access_token', |
|
48
|
|
|
], |
|
49
|
|
|
[ |
|
50
|
|
|
'key' => 'env', |
|
51
|
|
|
'options' => ['sandbox', 'api'], |
|
52
|
|
|
'default' => 'sandbox', |
|
53
|
|
|
'name' => 'Version', |
|
54
|
|
|
], |
|
55
|
|
|
[ |
|
56
|
|
|
'key' => 'sslVersion', |
|
57
|
|
|
'options' => ['SecureTransport', 'TLS'], |
|
58
|
|
|
'default' => 'SecureTransport', |
|
59
|
|
|
'name' => 'SSL Version', |
|
60
|
|
|
], |
|
61
|
|
|
[ |
|
62
|
|
|
'key' => 'registerPath', |
|
63
|
|
|
'default' => false, |
|
64
|
|
|
], |
|
65
|
|
|
]; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @codeCoverageIgnore |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function getLogFilePath() |
|
71
|
|
|
{ |
|
72
|
|
|
return 'var/logs/console.log'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
1 |
|
public function factorySdk(array $options) |
|
76
|
|
|
{ |
|
77
|
1 |
|
return Factory::getInstance()->setup($options, $this->factoryLogger()); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
1 |
|
public function appendCommand($name, $description, array $definition = []) |
|
81
|
|
|
{ |
|
82
|
1 |
|
return $this->register($name) |
|
83
|
1 |
|
->setDescription($description) |
|
84
|
1 |
|
->setDefinition($this->factoryDefinition($definition)); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function showException(Exception $e, OutputInterface $output, $description = 'Erro') |
|
88
|
|
|
{ |
|
89
|
|
|
$output->writeln('<error>'.$description .'</error>'); |
|
90
|
|
|
$output->writeln('Message: <comment>'.$e->getMessage().'</comment>'); |
|
91
|
|
|
$output->writeln('Error Code: <comment>'.$e->getCode().'</comment>'); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|