quick api test command
This commit is contained in:
parent
4a1d7c59fb
commit
2bfaa9e584
@ -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)) {
|
||||||
|
28
app/Console/Commands/TestApi.php
Normal file
28
app/Console/Commands/TestApi.php
Normal 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()));
|
||||||
|
}
|
||||||
|
}
|
@ -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,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user