Files
dev-chiefworks 47f4fad75c Added Other AP
2022-04-26 11:30:34 -04:00

68 lines
1.5 KiB
PHP

<?php
class TripOptionsApi extends Api
{
public $apiName = 'tripoptions';
public function indexAction()
{
return $this->response(
array(
'error' => 'Data not found'
), 404);
}
/**
* Method GET
* Get single record (by id)
* http://DOMAIN/trips/1
* @return string
*/
public function viewAction()
{
//id must be the first parameter after /trips/x
$id = array_shift($this->requestUri);
if($id && (int)$id>0){
$db = new Db();
$tripOptions = Trips::getOptionsById($db->getConnect(), (int)$id);
if(is_array($tripOptions) && count($tripOptions)>0){
return $this->response(
array(
'id' => $id,
'count' => count($tripOptions),
'options' => $tripOptions
), 200);
}
}
return $this->response(
array(
'error'=> 'Data not found'
), 404);
}
public function createAction()
{
return $this->response(
array(
"error" => "Saving error"
), 500);
}
public function updateAction()
{
return $this->response(
array(
"error" => "Update error"
), 400);
}
public function deleteAction()
{
return $this->response(
array(
"error" => "Delete error"
), 500);
}
}