Updating use of Api::STAT_APP_EXCEPTION const
This commit is contained in:
@@ -6,7 +6,8 @@ class Api
|
||||
private static $workspace;
|
||||
private static $userId;
|
||||
|
||||
const SYSTEM_EXCEPTION_STATUS = 500;
|
||||
const STAT_CREATED = 201;
|
||||
const STAT_APP_EXCEPTION = 400;
|
||||
|
||||
public function __costruct()
|
||||
{
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker;
|
||||
|
||||
class Application extends \ProcessMaker\Api
|
||||
{
|
||||
/**
|
||||
* Sample api protected with OAuth2
|
||||
*
|
||||
* For testing the oAuth token
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
$data = array(
|
||||
'USSER_LOGGED' => $this->getUserId(),
|
||||
"APP_UID" => $id,
|
||||
"PRO_UID" => "13885168416038181883131343548151",
|
||||
"DUMMY" => "sample data",
|
||||
"WS" => $this->getWorkspace()
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function post($requestData = null)
|
||||
{
|
||||
$requestData['processed'] = true;
|
||||
|
||||
return $requestData;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,10 @@ namespace Services\Api\ProcessMaker;
|
||||
use \ProcessMaker\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
//TODO we need Refactor this class
|
||||
|
||||
/**
|
||||
*
|
||||
* Process Api Controller
|
||||
*
|
||||
* @protected
|
||||
@@ -36,7 +39,7 @@ class Process extends Api
|
||||
return $response;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ class Process extends Api
|
||||
$response["message"] = "Process load successfully";
|
||||
$response["data"] = $data;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
return $response;
|
||||
@@ -71,7 +74,7 @@ class Process extends Api
|
||||
return $process->createProcess($userUid, $request_data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +93,7 @@ class Process extends Api
|
||||
$response["message"] = "Process updated successfully";
|
||||
$response["data"] = $data;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
return $response;
|
||||
@@ -109,7 +112,7 @@ class Process extends Api
|
||||
$response["success"] = true;
|
||||
$response["message"] = "Process was deleted successfully";
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
@@ -38,7 +38,7 @@ class Activity extends Api
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Activity extends Api
|
||||
$task = new \BusinessModel\Task();
|
||||
$properties = $task->updateProperties($activityUid, $projectUid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class Activity extends Api
|
||||
$task = new \BusinessModel\Task();
|
||||
$task->deleteTask($activityUid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker;
|
||||
|
||||
use \ProcessMaker\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* ProjectActivity Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class ProjectActivity extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET /:projectUid/activity/:activityUid
|
||||
*/
|
||||
public function doGetProjectActivity($projectUid, $activityUid, $filter = '')
|
||||
{
|
||||
try {
|
||||
$definition = array();
|
||||
$properties = array();
|
||||
|
||||
if ($filter == '' || $filter == 'definition') {
|
||||
// DEFINITION
|
||||
$definition = array();
|
||||
}
|
||||
|
||||
if ($filter == '' || $filter == 'properties') {
|
||||
// PROPERTIES
|
||||
$task = new \BusinessModel\Task();
|
||||
$properties = $task->getProperties($activityUid, true, false);
|
||||
}
|
||||
|
||||
$response = array(
|
||||
'definition' => $definition,
|
||||
'properties' => $properties
|
||||
);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @url PUT /:projectUid/activity/:activityUid
|
||||
*/
|
||||
public function doPutProjectActivity($projectUid, $activityUid, $request_data = array())
|
||||
{
|
||||
try {
|
||||
$task = new \BusinessModel\Task();
|
||||
$properties = $task->updateProperties($activityUid, $projectUid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @url DELETE /:projectUid/activity/:activityUid
|
||||
*/
|
||||
public function doDeleteProjectActivity($projectUid, $activityUid)
|
||||
{
|
||||
try {
|
||||
$task = new \BusinessModel\Task();
|
||||
$task->deleteTask($activityUid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::SYSTEM_EXCEPTION_STATUS, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user