Merge branch '107-changes-for-ios-api' into 'master'
Resolve "Changes for ios api" Closes #107 See merge request jankstudio/resq!93
This commit is contained in:
commit
55bc1b8a01
1 changed files with 19 additions and 5 deletions
|
|
@ -549,6 +549,15 @@ class APIController extends Controller
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
protected function getBatteryImageURL($req, $batt)
|
||||
{
|
||||
// TODO: workaround for now, we get static image of battery based on model name
|
||||
$filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg';
|
||||
$file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename;
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
public function listVehicles(Request $req)
|
||||
{
|
||||
// check required parameters and api key
|
||||
|
|
@ -642,9 +651,6 @@ class APIController extends Controller
|
|||
$batts = $vehicle->getBatteries();
|
||||
foreach ($batts as $batt)
|
||||
{
|
||||
// TODO: workaround for now, we get static image of battery based on model name
|
||||
$filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg';
|
||||
$file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename;
|
||||
$batt_list[] = [
|
||||
'id' => $batt->getID(),
|
||||
'mfg_id' => $batt->getManufacturer()->getID(),
|
||||
|
|
@ -656,7 +662,7 @@ class APIController extends Controller
|
|||
'price' => $batt->getSellingPrice(),
|
||||
'wty_private' => $batt->getWarrantyPrivate(),
|
||||
'wty_commercial' => $batt->getWarrantyCommercial(),
|
||||
'image_url' => $file_path,
|
||||
'image_url' => $this->getBatteryImageURL($req, $batt),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -953,11 +959,19 @@ class APIController extends Controller
|
|||
$items_data = [];
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$items_data[] = [
|
||||
$my_data = [
|
||||
'title' => $item->getTitle(),
|
||||
'qty' => $item->getQuantity() + 0,
|
||||
'price' => $item->getPrice() + 0.0,
|
||||
];
|
||||
|
||||
$item_batt = $item->getBattery();
|
||||
if ($item_batt != null)
|
||||
{
|
||||
$my_data['image_url'] = $this->getBatteryImageURL($req, $batt);
|
||||
}
|
||||
|
||||
$items_data[] = $my_data;
|
||||
}
|
||||
|
||||
$data['items'] = $items_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue