Add getPaymentMethods and getCancelReason API calls to rider API. Add phone_landline to the JO responses. #428
This commit is contained in:
parent
332f9687a2
commit
6473c2e344
4 changed files with 124 additions and 3 deletions
|
|
@ -139,3 +139,13 @@ cmb_rapi_jo_ongoing:
|
||||||
path: /cmbrapi/joongoing
|
path: /cmbrapi/joongoing
|
||||||
controller: App\Controller\CMBRAPIController::getOngoingJobOrder
|
controller: App\Controller\CMBRAPIController::getOngoingJobOrder
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
cmb_rapi_payment_methods:
|
||||||
|
path: /cmbrapi/paymentmethods
|
||||||
|
controller: App\Controller\CMBRAPIController::getPaymentMethods
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
cmb_rapi_cancel_reasons:
|
||||||
|
path: /cmbrapi/cancelreasons
|
||||||
|
controller: App\Controller\CMBRAPIController::getCancelReasons
|
||||||
|
methods: [GET]
|
||||||
|
|
|
||||||
|
|
@ -691,4 +691,52 @@ class CMBRAPIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPaymentMethods(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new NewAPIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->getPaymentMethods($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 getCancelReasons(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$res = new NewAPIResult();
|
||||||
|
|
||||||
|
$data = $rapi_handler->getCancelReasons($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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
src/Ramcar/CMBCancelReason.php
Normal file
22
src/Ramcar/CMBCancelReason.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ramcar;
|
||||||
|
|
||||||
|
class CMBCancelReason extends NameValue
|
||||||
|
{
|
||||||
|
const ACCIDENT = 'accident';
|
||||||
|
const BREAKDOWN = 'breakdown';
|
||||||
|
const FUEL_RUNOUT = 'fuel_runout';
|
||||||
|
const WRONG_BATTERY_SIZE = 'wrong_battery_size';
|
||||||
|
const CUSTOMER_CANCEL = 'customer_cancel';
|
||||||
|
const OTHERS = 'others';
|
||||||
|
|
||||||
|
const COLLECTION = [
|
||||||
|
'accident' => 'Accident',
|
||||||
|
'breakdown' => 'Breakdown',
|
||||||
|
'fuel_runout' => 'Fuel Runout',
|
||||||
|
'wrong_battery_size' => 'Wrong Battery Size',
|
||||||
|
'customer_cancel' => 'Cancelled by Customer',
|
||||||
|
'others' => 'Others'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -11,8 +11,9 @@ use App\Ramcar\TradeInType;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
use App\Ramcar\CMBJOEventType;
|
use App\Ramcar\CMBJOEventType;
|
||||||
use App\Ramcar\InvoiceStatus;
|
use App\Ramcar\InvoiceStatus;
|
||||||
use App\Ramcar\ModeOfPayment;
|
use App\Ramcar\CMBModeOfPayment;
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
|
use App\Ramcar\CMBCancelReason;
|
||||||
|
|
||||||
use App\Service\RiderAPIHandlerInterface;
|
use App\Service\RiderAPIHandlerInterface;
|
||||||
use App\Service\RedisClientProvider;
|
use App\Service\RedisClientProvider;
|
||||||
|
|
@ -426,6 +427,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
'first_name' => $cust->getFirstName(),
|
'first_name' => $cust->getFirstName(),
|
||||||
'last_name' => $cust->getLastName(),
|
'last_name' => $cust->getLastName(),
|
||||||
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
||||||
|
'phone_landline' => $this->country_code . $cust->getPhoneLandline(),
|
||||||
],
|
],
|
||||||
'vehicle' => [
|
'vehicle' => [
|
||||||
'manufacturer' => $v->getManufacturer()->getName(),
|
'manufacturer' => $v->getManufacturer()->getName(),
|
||||||
|
|
@ -563,6 +565,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
'first_name' => $cust->getFirstName(),
|
'first_name' => $cust->getFirstName(),
|
||||||
'last_name' => $cust->getLastName(),
|
'last_name' => $cust->getLastName(),
|
||||||
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
||||||
|
'phone_landline' => $this->country_code . $cust->getPhoneLandline(),
|
||||||
],
|
],
|
||||||
'vehicle' => [
|
'vehicle' => [
|
||||||
'manufacturer' => $v->getManufacturer()->getName(),
|
'manufacturer' => $v->getManufacturer()->getName(),
|
||||||
|
|
@ -673,6 +676,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
'first_name' => $cust->getFirstName(),
|
'first_name' => $cust->getFirstName(),
|
||||||
'last_name' => $cust->getLastName(),
|
'last_name' => $cust->getLastName(),
|
||||||
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
||||||
|
'phone_landline' => $this->country_code . $cust->getPhoneLandline(),
|
||||||
],
|
],
|
||||||
'vehicle' => [
|
'vehicle' => [
|
||||||
'manufacturer' => $v->getManufacturer()->getName(),
|
'manufacturer' => $v->getManufacturer()->getName(),
|
||||||
|
|
@ -1120,8 +1124,8 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
|
|
||||||
// check mode of payment
|
// check mode of payment
|
||||||
$mode = $req->request->get('mode_of_payment');
|
$mode = $req->request->get('mode_of_payment');
|
||||||
if (!ModeOfPayment::validate($mode))
|
if (!CMBModeOfPayment::validate($mode))
|
||||||
$mode = ModeOfPayment::CASH;
|
$mode = CMBModeOfPayment::CASH;
|
||||||
$jo->setModeOfPayment($mode);
|
$jo->setModeOfPayment($mode);
|
||||||
|
|
||||||
// generate new invoice
|
// generate new invoice
|
||||||
|
|
@ -1745,6 +1749,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
'first_name' => $cust->getFirstName(),
|
'first_name' => $cust->getFirstName(),
|
||||||
'last_name' => $cust->getLastName(),
|
'last_name' => $cust->getLastName(),
|
||||||
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
|
||||||
|
'phone_landline' => $this->country_code . $cust->getPhoneLandline(),
|
||||||
],
|
],
|
||||||
'vehicle' => [
|
'vehicle' => [
|
||||||
'manufacturer' => $v->getManufacturer()->getName(),
|
'manufacturer' => $v->getManufacturer()->getName(),
|
||||||
|
|
@ -1778,6 +1783,42 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPaymentMethods(Request $req)
|
||||||
|
{
|
||||||
|
$required_params = [];
|
||||||
|
$data = $this->checkParamsAndKey($req, $required_params);
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$data['title'] = 'Failed Get Payment Methods';
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'payment_methods' => CMBModeOfPayment::getCollection(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCancelReasons(Request $req)
|
||||||
|
{
|
||||||
|
$required_params = [];
|
||||||
|
$data = $this->checkParamsAndKey($req, $required_params);
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$data['title'] = 'Failed Get Cancel Reasons';
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'cancel_reasons' => CMBCancelReason::getCollection(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkMissingParameters(Request $req, $params = [])
|
protected function checkMissingParameters(Request $req, $params = [])
|
||||||
{
|
{
|
||||||
$missing = [];
|
$missing = [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue