@@ 8-56 (lines=49) @@ | ||
5 | use Bytesfield\KeyManager\KeyManagerInterface; |
|
6 | use Illuminate\Console\Command; |
|
7 | ||
8 | class ChangeKeysCommand extends Command |
|
9 | { |
|
10 | /** |
|
11 | * The name and signature of the console command. |
|
12 | * |
|
13 | * @var string |
|
14 | */ |
|
15 | protected $signature = 'client:changekey {clientId}'; |
|
16 | ||
17 | /** |
|
18 | * The console command description. |
|
19 | * |
|
20 | * @var string |
|
21 | */ |
|
22 | protected $description = 'Command to change client public/private keys'; |
|
23 | ||
24 | /** |
|
25 | * The KeyManagerInterface. |
|
26 | * |
|
27 | * @var KeyManagerInterface |
|
28 | */ |
|
29 | private $manager; |
|
30 | ||
31 | /** |
|
32 | * @param KeyManagerInterface $manager |
|
33 | * @return void |
|
34 | */ |
|
35 | public function __construct(KeyManagerInterface $manager) |
|
36 | { |
|
37 | $this->manager = $manager; |
|
38 | ||
39 | parent::__construct(); |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * Execute the console command. |
|
44 | * |
|
45 | * @return void |
|
46 | */ |
|
47 | public function handle(): void |
|
48 | { |
|
49 | $key = $this->manager->changeKeys($this->argument('clientId')); |
|
50 | $this->info($key->getData()->status == true ? 'Success' : 'Failed'); |
|
51 | ||
52 | $this->info($key->getData()->message); |
|
53 | ||
54 | $this->info($key->getData()->data->key); |
|
55 | } |
|
56 | } |
|
57 |
@@ 8-56 (lines=49) @@ | ||
5 | use Bytesfield\KeyManager\KeyManagerInterface; |
|
6 | use Illuminate\Console\Command; |
|
7 | ||
8 | class GetApiKeyCommand extends Command |
|
9 | { |
|
10 | /** |
|
11 | * The name and signature of the console command. |
|
12 | * |
|
13 | * @var string |
|
14 | */ |
|
15 | protected $signature = 'client:getkey {clientId}'; |
|
16 | ||
17 | /** |
|
18 | * The console command description. |
|
19 | * |
|
20 | * @var string |
|
21 | */ |
|
22 | protected $description = 'Command to get clients private key'; |
|
23 | ||
24 | /** |
|
25 | * The KeyManagerInterface. |
|
26 | * |
|
27 | * @var KeyManagerInterface |
|
28 | */ |
|
29 | private $manager; |
|
30 | ||
31 | /** |
|
32 | * @param KeyManagerInterface $manager |
|
33 | * @return void |
|
34 | */ |
|
35 | public function __construct(KeyManagerInterface $manager) |
|
36 | { |
|
37 | $this->manager = $manager; |
|
38 | parent::__construct(); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Execute the console command. |
|
43 | * |
|
44 | * @return void |
|
45 | */ |
|
46 | public function handle(): void |
|
47 | { |
|
48 | $key = $this->manager->getPrivateKey($this->argument('clientId')); |
|
49 | ||
50 | $this->info($key->getData()->status == true ? 'Success' : 'Failed'); |
|
51 | ||
52 | $this->info($key->getData()->message); |
|
53 | ||
54 | $this->info($key->getData()->data->key); |
|
55 | } |
|
56 | } |
|
57 |