2018-04-11 19:49:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Grocy\Controllers;
|
|
|
|
|
2018-04-12 21:13:38 +02:00
|
|
|
use \Grocy\Services\BatteriesService;
|
2018-04-11 19:49:35 +02:00
|
|
|
|
|
|
|
class BatteriesApiController extends BaseApiController
|
|
|
|
{
|
|
|
|
public function __construct(\Slim\Container $container)
|
|
|
|
{
|
|
|
|
parent::__construct($container);
|
|
|
|
$this->BatteriesService = new BatteriesService();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected $BatteriesService;
|
|
|
|
|
2018-04-12 21:13:38 +02:00
|
|
|
public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
2018-04-11 19:49:35 +02:00
|
|
|
{
|
|
|
|
$trackedTime = date('Y-m-d H:i:s');
|
|
|
|
if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time']))
|
|
|
|
{
|
|
|
|
$trackedTime = $request->getQueryParams()['tracked_time'];
|
|
|
|
}
|
|
|
|
|
2018-04-12 21:13:38 +02:00
|
|
|
return $this->ApiResponse(array('success' => $this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime)));
|
2018-04-11 19:49:35 +02:00
|
|
|
}
|
|
|
|
|
2018-04-12 21:13:38 +02:00
|
|
|
public function BatteryDetails(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
2018-04-11 19:49:35 +02:00
|
|
|
{
|
2018-04-12 21:13:38 +02:00
|
|
|
return $this->ApiResponse($this->BatteriesService->GetBatteryDetails($args['batteryId']));
|
2018-04-11 19:49:35 +02:00
|
|
|
}
|
|
|
|
}
|