Add RAPIController for CMB. #420
This commit is contained in:
parent
711082cf23
commit
ce2b838ff7
5 changed files with 388 additions and 5 deletions
|
|
@ -12,6 +12,7 @@ parameters:
|
||||||
app_access_key: 'access_keys'
|
app_access_key: 'access_keys'
|
||||||
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||||
country_code: "%env(COUNTRY_CODE)%"
|
country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
api_version: "%env(API_VERSION)%"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
|
|
@ -73,6 +74,7 @@ services:
|
||||||
$pass: "%env(RT_PASS)%"
|
$pass: "%env(RT_PASS)%"
|
||||||
$usage_type: "%env(RT_USAGE_TYPE)%"
|
$usage_type: "%env(RT_USAGE_TYPE)%"
|
||||||
$shortcode: "%env(RT_SHORTCODE)%"
|
$shortcode: "%env(RT_SHORTCODE)%"
|
||||||
|
$dr_url: "https://resqaws.jankstudio.com/sms/delivery_receipt"
|
||||||
|
|
||||||
App\Service\MQTTClient:
|
App\Service\MQTTClient:
|
||||||
arguments:
|
arguments:
|
||||||
|
|
@ -167,7 +169,7 @@ services:
|
||||||
# job order generator
|
# job order generator
|
||||||
App\Service\JobOrderHandler\CMBJobOrderHandler:
|
App\Service\JobOrderHandler\CMBJobOrderHandler:
|
||||||
arguments:
|
arguments:
|
||||||
$country_code: "%env(COUNTRY_CODE)%"
|
$country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
|
||||||
#job order generator interface
|
#job order generator interface
|
||||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
|
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
|
||||||
|
|
@ -187,13 +189,12 @@ services:
|
||||||
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\CMBRiderAssignmentHandler"
|
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\CMBRiderAssignmentHandler"
|
||||||
|
|
||||||
# rider API service
|
# rider API service
|
||||||
App\Service\RiderAPIHandler\CMBRiderAPIHandler:
|
App\Service\RiderAPIHandler\CMBRiderAPIHandler:
|
||||||
arguments:
|
arguments:
|
||||||
$country_code: "%env(COUNTRY_CODE)%"
|
$country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
|
||||||
# rider API interface
|
|
||||||
App\Service\RiderAPIHandlerInterface: "@App\\Service\\RiderAPIHandler\\CMBRiderAPIHandler"
|
App\Service\RiderAPIHandlerInterface: "@App\\Service\\RiderAPIHandler\\CMBRiderAPIHandler"
|
||||||
|
|
||||||
# map manager
|
# map manager
|
||||||
#App\Service\GISManager\Bing: ~
|
#App\Service\GISManager\Bing: ~
|
||||||
App\Service\GISManager\OpenStreet: ~
|
App\Service\GISManager\OpenStreet: ~
|
||||||
|
|
@ -229,6 +230,14 @@ services:
|
||||||
$loc_key: "%env(LOCATION_RIDER_ACTIVE_KEY)%"
|
$loc_key: "%env(LOCATION_RIDER_ACTIVE_KEY)%"
|
||||||
$status_key: "%env(STATUS_RIDER_KEY)%"
|
$status_key: "%env(STATUS_RIDER_KEY)%"
|
||||||
|
|
||||||
|
# inventory manager
|
||||||
|
App\Service\InventoryManager:
|
||||||
|
arguments:
|
||||||
|
$api_url: "%env(INVENTORY_API_URL)%"
|
||||||
|
$api_ocp_key: "%env(INVENTORY_API_OCP)%"
|
||||||
|
$api_auth_prefix: "%env(INVENTORY_API_AUTH_TOKEN_PREFIX)%"
|
||||||
|
$api_auth_token: "%env(INVENTORY_API_AUTH_TOKEN)%"
|
||||||
|
|
||||||
# API logging
|
# API logging
|
||||||
App\EventSubscriber\LogSubscriber:
|
App\EventSubscriber\LogSubscriber:
|
||||||
arguments:
|
arguments:
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,10 @@ security:
|
||||||
provider: api_key_user_provider
|
provider: api_key_user_provider
|
||||||
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||||
|
|
||||||
|
cmb_rider_api:
|
||||||
|
pattern: ^\/cmbrapi\/
|
||||||
|
security: false
|
||||||
|
|
||||||
main:
|
main:
|
||||||
provider: user_provider
|
provider: user_provider
|
||||||
form_login:
|
form_login:
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ services:
|
||||||
$pass: "%env(RT_PASS)%"
|
$pass: "%env(RT_PASS)%"
|
||||||
$usage_type: "%env(RT_USAGE_TYPE)%"
|
$usage_type: "%env(RT_USAGE_TYPE)%"
|
||||||
$shortcode: "%env(RT_SHORTCODE)%"
|
$shortcode: "%env(RT_SHORTCODE)%"
|
||||||
|
$dr_url: "https://resqaws.jankstudio.com/sms/delivery_receipt"
|
||||||
|
|
||||||
App\Service\MQTTClient:
|
App\Service\MQTTClient:
|
||||||
arguments:
|
arguments:
|
||||||
|
|
|
||||||
66
config/routes/cmb_rider_api.yaml
Normal file
66
config/routes/cmb_rider_api.yaml
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
# rider app api
|
||||||
|
|
||||||
|
cmb_rapi_register:
|
||||||
|
path: /cmbrapi/register
|
||||||
|
controller: App\Controller\CMBRAPIController::register
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_login:
|
||||||
|
path: /cmbrapi/login
|
||||||
|
controller: App\Controller\CMBRAPIController::login
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_logout:
|
||||||
|
path: /cmbrapi/logout
|
||||||
|
controller: App\Controller\CMBRAPIController::logout
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_jo_get:
|
||||||
|
path: /cmbrapi/joborder
|
||||||
|
controller: App\Controller\CMBRAPIController::getJobOrder
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
cmb_rapi_jo_accept:
|
||||||
|
path: /cmbrapi/accept
|
||||||
|
controller: App\Controller\CMBRAPIController::acceptJobOrder
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_jo_cancel:
|
||||||
|
path: /cmbrapi/cancel
|
||||||
|
controller: App\Controller\CMBRAPIController::cancelJobOrder
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_arrive:
|
||||||
|
path: /cmbrapi/arrive
|
||||||
|
controller: App\Controller\CMBRAPIController::arrive
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_payment:
|
||||||
|
path: /cmbrapi/payment
|
||||||
|
controller: App\Controller\CMBRAPIController::payment
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_hub_arrive:
|
||||||
|
path: /cmbrapi/hub_arrive
|
||||||
|
controller: App\Controller\CMBRAPIController::hubArrive
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_promos:
|
||||||
|
path: /cmbrapi/promos
|
||||||
|
controller: App\Controller\CMBRAPIController::getPromos
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
cmb_rapi_batteries:
|
||||||
|
path: /cmbrapi/batteries
|
||||||
|
controller: App\Controller\CMBRAPIController::getBatteries
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
cmb_rapi_change_service:
|
||||||
|
path: /cmbrapi/service
|
||||||
|
controller: App\Controller\CMBRAPIController::changeService
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_available:
|
||||||
|
path: /cmbrapi/available
|
||||||
|
controller: App\Controller\CMBRAPIController::available
|
||||||
|
methods: [POST]
|
||||||
303
src/Controller/CMBRAPIController.php
Normal file
303
src/Controller/CMBRAPIController.php
Normal file
|
|
@ -0,0 +1,303 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
|
use App\Ramcar\APIResult;
|
||||||
|
|
||||||
|
use App\Service\RiderAPIHandlerInterface;
|
||||||
|
|
||||||
|
// Rider API controller for CMB
|
||||||
|
class CMBRAPIController extends Controller
|
||||||
|
{
|
||||||
|
public function register(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->register($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->login($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->logout($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->getJobOrder($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function acceptJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->acceptJobOrder($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->cancelJobOrder($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function arrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->arrive($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hubArrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->hubArrive($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function payment(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->payment($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function available(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->available($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPromos(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->getPromos($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBatteries(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->getBatteries($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function changeService(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->changeService($req);
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue