Merge branch '424-cmb-release' into '425-cmb-use-cmb-service-type'
# Conflicts: # src/Service/RiderAPIHandler/CMBRiderAPIHandler.php
This commit is contained in:
commit
bd0cf0ad1d
9 changed files with 1062 additions and 4 deletions
|
|
@ -5,6 +5,7 @@ parameters:
|
|||
latitude: 14.6091
|
||||
longitude: 121.0223
|
||||
image_upload_directory: '%kernel.project_dir%/public/uploads'
|
||||
jo_extra_upload_directory: '%kernel.project_dir%/public/uploads/jo_extra'
|
||||
job_order_refresh_interval: 300000
|
||||
api_acl_file: 'api_acl.yaml'
|
||||
api_access_key: 'api_access_keys'
|
||||
|
|
@ -12,6 +13,7 @@ parameters:
|
|||
app_access_key: 'access_keys'
|
||||
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||
country_code: "%env(COUNTRY_CODE)%"
|
||||
api_version: "%env(API_VERSION)%"
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
|
|
@ -73,6 +75,7 @@ services:
|
|||
$pass: "%env(RT_PASS)%"
|
||||
$usage_type: "%env(RT_USAGE_TYPE)%"
|
||||
$shortcode: "%env(RT_SHORTCODE)%"
|
||||
$dr_url: "https://resqaws.jankstudio.com/sms/delivery_receipt"
|
||||
|
||||
App\Service\MQTTClient:
|
||||
arguments:
|
||||
|
|
@ -167,7 +170,7 @@ services:
|
|||
# job order generator
|
||||
App\Service\JobOrderHandler\CMBJobOrderHandler:
|
||||
arguments:
|
||||
$country_code: "%env(COUNTRY_CODE)%"
|
||||
$country_code: "%env(COUNTRY_CODE)%"
|
||||
|
||||
#job order generator interface
|
||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
|
||||
|
|
@ -187,13 +190,13 @@ services:
|
|||
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\CMBRiderAssignmentHandler"
|
||||
|
||||
# rider API service
|
||||
App\Service\RiderAPIHandler\CMBRiderAPIHandler:
|
||||
App\Service\RiderAPIHandler\CMBRiderAPIHandler:
|
||||
arguments:
|
||||
$country_code: "%env(COUNTRY_CODE)%"
|
||||
$upload_dir: "%jo_extra_upload_directory%"
|
||||
|
||||
# rider API interface
|
||||
App\Service\RiderAPIHandlerInterface: "@App\\Service\\RiderAPIHandler\\CMBRiderAPIHandler"
|
||||
|
||||
|
||||
# map manager
|
||||
#App\Service\GISManager\Bing: ~
|
||||
App\Service\GISManager\OpenStreet: ~
|
||||
|
|
@ -229,6 +232,14 @@ services:
|
|||
$loc_key: "%env(LOCATION_RIDER_ACTIVE_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
|
||||
App\EventSubscriber\LogSubscriber:
|
||||
arguments:
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ security:
|
|||
provider: api_key_user_provider
|
||||
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||
|
||||
cmb_rider_api:
|
||||
pattern: ^\/cmbrapi\/
|
||||
security: false
|
||||
|
||||
main:
|
||||
provider: user_provider
|
||||
form_login:
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ services:
|
|||
$pass: "%env(RT_PASS)%"
|
||||
$usage_type: "%env(RT_USAGE_TYPE)%"
|
||||
$shortcode: "%env(RT_SHORTCODE)%"
|
||||
$dr_url: "https://resqaws.jankstudio.com/sms/delivery_receipt"
|
||||
|
||||
App\Service\MQTTClient:
|
||||
arguments:
|
||||
|
|
|
|||
131
config/routes/cmb_rider_api.yaml
Normal file
131
config/routes/cmb_rider_api.yaml
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
# 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/joaccept
|
||||
controller: App\Controller\CMBRAPIController::acceptJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_cancel:
|
||||
path: /cmbrapi/jocancel
|
||||
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/jopayment
|
||||
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]
|
||||
|
||||
cmb_rapi_jo_history:
|
||||
path: /cmbrapi/johistory/{period}
|
||||
controller: App\Controller\CMBRAPIController::getJobOrderHistory
|
||||
methods: [GET]
|
||||
|
||||
cmb_rapi_assigned_jo_get:
|
||||
path: /cmbrapi/assignedjos
|
||||
controller: App\Controller\CMBRAPIController::getAssignedJobOrders
|
||||
methods: [GET]
|
||||
|
||||
cmb_rapi_jo_in_transit:
|
||||
path: /cmbrapi/jotransit
|
||||
controller: App\Controller\CMBRAPIController::setJobOrderInTransit
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_invoice_generate:
|
||||
path: /cmbrapi/generateinvoice
|
||||
controller: App\Controller\CMBRAPIController::generateInvoice
|
||||
methods: [GET]
|
||||
|
||||
cmb_rapi_online:
|
||||
path: /cmbrapi/online
|
||||
controller: App\Controller\CMBRAPIController::goOnline
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_offline:
|
||||
path: /cmbrapi/offline
|
||||
controller: App\Controller\CMBRAPIController::goOffline
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_start:
|
||||
path: /cmbrapi/jostart
|
||||
controller: App\Controller\CMBRAPIController::startJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_complete:
|
||||
path: /cmbrapi/jocomplete
|
||||
controller: App\Controller\CMBRAPIController::completeJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_set_active:
|
||||
path: /cmbrapi/joactive
|
||||
controller: App\Controller\CMBRAPIController::setActiveJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_reject:
|
||||
path: /cmbrapi/joreject
|
||||
controller: App\Controller\CMBRAPIController::rejectJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_odometer:
|
||||
path: /cmbrapi/odometer
|
||||
controller: App\Controller\CMBRAPIController::setOdometer
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_arrive_photos_upload:
|
||||
path: /cmbrapi/uploadarrivephotos
|
||||
controller: App\Controller\CMBRAPIController::uploadArrivePhotos
|
||||
methods: [POST]
|
||||
|
||||
cmb_rapi_jo_finish_photos_upload:
|
||||
path: /cmbrapi/uploadfinishphotos
|
||||
controller: App\Controller\CMBRAPIController::uploadFinishPhotos
|
||||
methods: [POST]
|
||||
645
src/Controller/CMBRAPIController.php
Normal file
645
src/Controller/CMBRAPIController.php
Normal file
|
|
@ -0,0 +1,645 @@
|
|||
<?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\NewAPIResult;
|
||||
|
||||
use App\Service\RiderAPIHandlerInterface;
|
||||
|
||||
// Rider API controller for CMB
|
||||
class CMBRAPIController extends Controller
|
||||
{
|
||||
public function register(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->register($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function login(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->login($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function logout(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->logout($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->getJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function acceptJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->acceptJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function cancelJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->cancelJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
|
||||
}
|
||||
|
||||
public function arrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->arrive($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function hubArrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->hubArrive($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function payment(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->payment($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function available(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->available($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getPromos(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->getPromos($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getBatteries(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->getBatteries($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function changeService(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->changeService($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getJobOrderHistory(Request $req, $period, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->getJobOrderHistory($req, $period);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
|
||||
}
|
||||
|
||||
public function getAssignedJobOrders(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->getAssignedJobOrders($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
|
||||
}
|
||||
|
||||
public function setJobOrderInTransit(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->setJobOrderInTransit($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
|
||||
}
|
||||
|
||||
public function generateInvoice(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->generateInvoice($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
|
||||
}
|
||||
|
||||
public function goOnline(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->goOnline($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function goOffline(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->goOffline($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function startJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->startJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function completeJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->completeJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function setActiveJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->setActiveJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function rejectJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->rejectJobOrder($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function setOdometer(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->setOdometer($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function uploadArrivePhotos(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->uploadArrivePhotos($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function uploadFinishPhotos(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
||||
$data = $rapi_handler->uploadFinishPhotos($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
$title = $data['title'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorTitle($title)
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
122
src/Entity/JOExtra.php
Normal file
122
src/Entity/JOExtra.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="jo_extra")
|
||||
*/
|
||||
class JOExtra
|
||||
{
|
||||
// unique id
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $before_speed_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $before_plate_num_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $before_batt_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $after_speed_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $after_plate_num_image_filename;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $after_batt_image_filename;
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setBeforeSpeedImageFilename($image_filename)
|
||||
{
|
||||
$this->before_speed_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBeforeSpeedImageFilename($image_filename)
|
||||
{
|
||||
return $this->before_speed_image_filename;
|
||||
}
|
||||
|
||||
public function setBeforePlateNumImageFilename($image_filename)
|
||||
{
|
||||
$this->before_plate_num_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBeforePlateNumImageFilename($image_filename)
|
||||
{
|
||||
return $this->before_plate_num_image_filename;
|
||||
}
|
||||
|
||||
public function setBeforeBattImageFilename($image_filename)
|
||||
{
|
||||
$this->before_batt_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBeforeBattImageFilename($image_filename)
|
||||
{
|
||||
return $this->before_batt_image_filename;
|
||||
}
|
||||
public function setAfterSpeedImageFilename($image_filename)
|
||||
{
|
||||
$this->after_speed_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAfterSpeedImageFilename($image_filename)
|
||||
{
|
||||
return $this->after_speed_image_filename;
|
||||
}
|
||||
|
||||
public function setAfterPlateNumImageFilename($image_filename)
|
||||
{
|
||||
$this->after_plate_num_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAfterPlateNumImageFilename($image_filename)
|
||||
{
|
||||
return $this->after_plate_num_image_filename;
|
||||
}
|
||||
|
||||
public function setAfterBattImageFilename($image_filename)
|
||||
{
|
||||
$this->after_batt_image_filename = $image_filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAfterBattImageFilename($image_filename)
|
||||
{
|
||||
return $this->after_batt_image_filename;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -334,6 +334,12 @@ class JobOrder
|
|||
*/
|
||||
protected $phone_mobile;
|
||||
|
||||
// link to JOExtra
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="JOExtra")
|
||||
*/
|
||||
protected $jo_extra;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date_create = new DateTime();
|
||||
|
|
@ -962,5 +968,15 @@ class JobOrder
|
|||
return $this->phone_mobile;
|
||||
}
|
||||
|
||||
public function setJOExtra(JOExtra $jo_extra)
|
||||
{
|
||||
$this->jo_extra = $jo_extra;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getJOExtra()
|
||||
{
|
||||
return $this->jo_extra;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
36
src/Ramcar/CMBJOEventType.php
Normal file
36
src/Ramcar/CMBJOEventType.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class CMBJOEventType extends NameValue
|
||||
{
|
||||
const CREATE = 'create';
|
||||
const HUB_ASSIGN = 'hub_assign';
|
||||
const RIDER_ASSIGN = 'rider_assign';
|
||||
const CANCEL = 'cancel';
|
||||
const FULFILL = 'fulfill';
|
||||
const OPEN_EDIT = 'open_edit';
|
||||
const REQUEUE = 'requeue';
|
||||
const RIDER_ACCEPT = 'accept';
|
||||
const RIDER_IN_TRANSIT = 'rider_in_transit';
|
||||
const RIDER_ARRIVE = 'arrive';
|
||||
const RIDER_START = 'rider_start';
|
||||
const RIDER_EDIT = 'rider_edit';
|
||||
const PAID = 'paid';
|
||||
|
||||
const COLLECTION = [
|
||||
'create' => 'Created',
|
||||
'hub_assign' => 'Assigned to Hub',
|
||||
'rider_assign' => 'Assigned Rider',
|
||||
'cancel' => 'Cancelled',
|
||||
'fulfill' => 'Fulfilled',
|
||||
'open_edit' => 'Open Edit',
|
||||
'requeue' => 'Requeue',
|
||||
'accept' => 'Rider Accept',
|
||||
'rider_in_transit' => 'Rider in Transit',
|
||||
'arrive' => 'Rider Arrive',
|
||||
'rider_start' => 'Rider Start',
|
||||
'rider_edit' => 'Rider Edit',
|
||||
'paid' => 'Paid',
|
||||
];
|
||||
}
|
||||
92
src/Ramcar/NewAPIResult.php
Normal file
92
src/Ramcar/NewAPIResult.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class NewAPIResult
|
||||
{
|
||||
protected $err_title;
|
||||
protected $err_flag;
|
||||
protected $err_message;
|
||||
protected $data;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->err_title = '';
|
||||
$this->err_flag = false;
|
||||
$this->err_message = '';
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
public function setError($flag = true)
|
||||
{
|
||||
$this->err_flag = $flag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isError()
|
||||
{
|
||||
return $this->err_flag;
|
||||
}
|
||||
|
||||
public function setErrorMessage($message)
|
||||
{
|
||||
$this->err_message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return $this->err_message;
|
||||
}
|
||||
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function setErrorTitle($title)
|
||||
{
|
||||
$this->err_title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getErrorTitle()
|
||||
{
|
||||
return $this->err_title;
|
||||
}
|
||||
|
||||
|
||||
public function getReturnResponse()
|
||||
{
|
||||
if ($this->isError())
|
||||
$status = 'error';
|
||||
else
|
||||
$status = 'success';
|
||||
|
||||
if (count($this->data) == 0)
|
||||
$this->data = new \stdClass();
|
||||
|
||||
$return_data = [
|
||||
'error' => [
|
||||
'title' => $this->err_title,
|
||||
'status' => $status,
|
||||
'message' => $this->err_message
|
||||
],
|
||||
'data' => $this->data
|
||||
];
|
||||
|
||||
// $json_data = json_encode($return_data, JSON_NUMERIC_CHECK);
|
||||
$json_data = json_encode($return_data);
|
||||
$json = new Response($json_data);
|
||||
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue