diff --git a/catalyst/api-bundle/Command/TestCommand.php b/catalyst/api-bundle/Command/TestCommand.php new file mode 100644 index 00000000..d90c7880 --- /dev/null +++ b/catalyst/api-bundle/Command/TestCommand.php @@ -0,0 +1,105 @@ +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 = 'AJ34LJADR12134LKJL5'; + $plate_num = 'XEN918'; + $params = [ + 'serial' => $serial, + 'plate_number' => $plate_num, + 'warranty_class' => 'private', + 'sku' => 'WMEB24CB-CPN00-LX', + 'date_purchase' => '20181001', + 'date_expire' => '20191001', + 'first_name' => 'First', + 'last_name' => 'Last', + 'mobile_number' => '12345678910', + ]; + $api->post('/capi/warranties', $params); + + // get all warranties + $api->get('/capi/warranties'); + + + /* + // warranty find + $api->get('/capi/warranties/' . $serial); + */ + + // warranty claim + $id = 86811; + $serial = 'AJ34LJADR12134LKJL'; + $params = [ + 'serial' => $serial, + ]; + $api->post('/capi/warranties/' . $id . '/claim', $params); + + // add battery + $sku = 'WZMB31QT-CPP00-S'; + $brand_id = '4'; + $size_id = '1'; + $params = [ + 'sku' => $sku, + 'brand_id' => $brand_id, + 'size_id' => $size_id, + ]; + $api->post('/capi/batteries', $params); + + /* + + // plate warranty + $api->get('/capi/plates/' . $plate_num . '/warranties'); + + // battery + $api->get('/capi/battery_brands'); + $api->get('/capi/battery_sizes'); + $api->get('/capi/batteries'); + + // vehicle + // $api->get('/capi/vehicle_manufacturers'); + // $api->get('/capi/vehicles'); + */ + } +} +