Added Other AP

This commit is contained in:
dev-chiefworks
2022-04-26 11:30:34 -04:00
parent 5e006a6a21
commit 47f4fad75c
251 changed files with 29298 additions and 4 deletions
@@ -0,0 +1,67 @@
<?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);
}
}