quick api test command

This commit is contained in:
Nabeel Shahzad 2017-12-30 11:56:38 -06:00
parent 4a1d7c59fb
commit 2bfaa9e584
3 changed files with 30 additions and 0 deletions

View File

@ -29,6 +29,7 @@ class DevCommands extends BaseCommand
$commands = [ $commands = [
'clear-acars' => 'clearAcars', 'clear-acars' => 'clearAcars',
'compile-assets' => 'compileAssets', 'compile-assets' => 'compileAssets',
'test-api' => 'testApi',
]; ];
if(!array_key_exists($command, $commands)) { if(!array_key_exists($command, $commands)) {

View File

@ -0,0 +1,28 @@
<?php
namespace App\Console\Commands;
use GuzzleHttp\Client;
use App\Console\BaseCommand;
class TestApi extends BaseCommand
{
protected $signature = 'phpvms:test-api {apikey} {url}';
protected $httpClient;
/**
* Run dev related commands
*/
public function handle()
{
$this->httpClient = new Client([
'headers' => [
'Authorization' => $this->argument('apikey'),
]
]);
$result = $this->httpClient->get($this->argument('url'));
print_r(\GuzzleHttp\json_decode($result->getBody()));
}
}

View File

@ -19,6 +19,7 @@ class Kernel extends ConsoleKernel
Commands\ImportCommand::class, Commands\ImportCommand::class,
Commands\Install::class, Commands\Install::class,
Commands\NavdataCommand::class, Commands\NavdataCommand::class,
Commands\TestApi::class,
]; ];
/** /**