Add data to responses. #591
This commit is contained in:
parent
8c53b9ba75
commit
e162de9021
2 changed files with 37 additions and 5 deletions
|
|
@ -238,7 +238,6 @@ class RiderController extends APIController
|
||||||
// add rider rating
|
// add rider rating
|
||||||
$rating_num = $req->request->get('rating', -1);
|
$rating_num = $req->request->get('rating', -1);
|
||||||
|
|
||||||
$data = [];
|
|
||||||
// if rating is -1
|
// if rating is -1
|
||||||
if ($rating_num == -1)
|
if ($rating_num == -1)
|
||||||
{
|
{
|
||||||
|
|
@ -266,6 +265,11 @@ class RiderController extends APIController
|
||||||
$em->persist($rating);
|
$em->persist($rating);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'rating' => $rating->getRating(),
|
||||||
|
'comment' => $rating->getComment(),
|
||||||
|
];
|
||||||
|
|
||||||
// TODO: set average rating in rider entity
|
// TODO: set average rating in rider entity
|
||||||
|
|
||||||
return new APIResponse(true, 'Rider rating added', $data);
|
return new APIResponse(true, 'Rider rating added', $data);
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,7 @@ class WarrantyController extends APIController
|
||||||
return $serial . '/' . $filename;
|
return $serial . '/' . $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updateWarranty($data, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null,
|
protected function updateWarranty(&$data, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null,
|
||||||
$logger, $log_data, $user_id, $action, $source, $mobile_user)
|
$logger, $log_data, $user_id, $action, $source, $mobile_user)
|
||||||
{
|
{
|
||||||
// get serial
|
// get serial
|
||||||
|
|
@ -478,15 +478,13 @@ class WarrantyController extends APIController
|
||||||
|
|
||||||
// TODO: check if we need to do anything else
|
// TODO: check if we need to do anything else
|
||||||
// TODO: put warranty data into data
|
// TODO: put warranty data into data
|
||||||
$data = [];
|
$data = $this->generateWarrantyData($warr);
|
||||||
|
|
||||||
$logger->logWarrantyInfo($log_data, '', $user_id, $action, $source);
|
$logger->logWarrantyInfo($log_data, '', $user_id, $action, $source);
|
||||||
|
|
||||||
// send sms
|
// send sms
|
||||||
error_log('sending sms to - ' . $mobile_user->getPhoneNumber());
|
error_log('sending sms to - ' . $mobile_user->getPhoneNumber());
|
||||||
$rt->sendSMS($mobile_user->getPhoneNumber(), 'MOTOLITE', $sms_msg);
|
$rt->sendSMS($mobile_user->getPhoneNumber(), 'MOTOLITE', $sms_msg);
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findCustomerVehicle($em, $customer, $plate_number)
|
protected function findCustomerVehicle($em, $customer, $plate_number)
|
||||||
|
|
@ -530,4 +528,34 @@ class WarrantyController extends APIController
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function generateWarrantyData($warranty)
|
||||||
|
{
|
||||||
|
$sap_bty_name = '';
|
||||||
|
if ($warranty->getSAPBAttery() != null)
|
||||||
|
$sap_bty_name = $warranty->getSAPBattery()->getID();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'serial' => $warranty->getSerial(),
|
||||||
|
'first_name' => $warranty->getFirstName(),
|
||||||
|
'last_name' => $warranty->getLastName(),
|
||||||
|
'email' => $warranty->getEmail() ?? '',
|
||||||
|
'plate_number' => $warranty->getPlateNumber(),
|
||||||
|
'date_purchase' => $warranty->getDatePurchase()->format('Y-m-d'),
|
||||||
|
'sap_battery' => $sap_bty_name,
|
||||||
|
'mobile_number' => $warranty->getMobileNumber() ?? '',
|
||||||
|
'activated' => (boolean) $warranty->isActivated(),
|
||||||
|
'invoice_file' => $warranty->getFileInvoice() ?? '',
|
||||||
|
'warranty_card_file' => $warranty->getFileWarrantyCard() ?? '',
|
||||||
|
'odometer' => $warranty->getOdometer() ?? 0,
|
||||||
|
'date_purchase_customer' => $warranty->getDatePurchaseCustomer()->format('Y-m-d'),
|
||||||
|
'contact_number' => $warranty->getContactNumber() ?? '',
|
||||||
|
'customer_address' => $warranty->getCustomerAddress() ?? '',
|
||||||
|
'dealer_name' => $warranty->getDealerName() ?? '',
|
||||||
|
'dealer_address' => $warranty->getDealerAddress() ?? '',
|
||||||
|
'validated' => (boolean) $warranty->isValidated(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue