70 lines
2.3 KiB
PHP
70 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Catalyst\APIBundle\Command;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
|
|
|
use Catalyst\APIBundle\Connector\Client as APIClient;
|
|
|
|
|
|
class TestCommand extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this->setName('api:test-connector')
|
|
->setDescription('Test API connector.')
|
|
->setHelp('Test API Connector.')
|
|
->addArgument('protocol', InputArgument::REQUIRED, 'protocol')
|
|
->addArgument('server', InputArgument::REQUIRED, 'server')
|
|
->addArgument('api_key', InputArgument::REQUIRED, 'api_key')
|
|
->addArgument('secret_key', InputArgument::REQUIRED, 'secret_key');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$protocol = $input->getArgument('protocol');
|
|
$server = $input->getArgument('server');
|
|
$api_key = $input->getArgument('api_key');
|
|
$secret_key = $input->getArgument('secret_key');
|
|
|
|
// api client
|
|
$api = new APIClient($server, $api_key, $secret_key);
|
|
$api->setProtocol($protocol);
|
|
|
|
// test
|
|
$api->get('/capi/test');
|
|
|
|
// TODO: shift this out of the bundle, since it's project specific
|
|
// warranty register
|
|
$serial = 'AJ34LJADR12134LKJL';
|
|
$params = [
|
|
'serial' => $serial,
|
|
'plate_number' => 'XEN918',
|
|
'warranty_class' => 'private',
|
|
'battery_model_id' => 438,
|
|
'battery_size_id' => 1171,
|
|
'date_purchase' => '20181001',
|
|
'date_expire' => '20191001',
|
|
];
|
|
$api->post('/capi/warranties', $params);
|
|
|
|
// warranty find
|
|
$api->get('/capi/warranties/' . $serial);
|
|
|
|
// warranty claim
|
|
$api->post('/capi/warranties/' . $serial . '/claim');
|
|
|
|
// battery
|
|
// $api->get('/capi/battery_models');
|
|
// $api->get('/capi/battery_sizes');
|
|
|
|
// vehicle
|
|
// $api->get('/capi/vehicle_manufacturers');
|
|
// $api->get('/capi/vehicles');
|
|
}
|
|
}
|