2014-03-14 15:33:35 -04:00
|
|
|
<?php
|
|
|
|
|
namespace Services\Api\ProcessMaker;
|
|
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cases Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Cases extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases To Do
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url GET
|
|
|
|
|
*/
|
|
|
|
|
public function doGetCasesListToDo($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'todo';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Draft
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url GET /draft
|
|
|
|
|
*/
|
|
|
|
|
public function doGetCasesListDraft($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'draft';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Participated
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /participated
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListParticipated($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'sent';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Unassigned
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /unassigned
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListUnassigned($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'unassigned';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Paused
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /paused
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListPaused($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'paused';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Advanced Search
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /advanced-search
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListAdvancedSearch($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'search';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-17 09:09:29 -04:00
|
|
|
|
|
|
|
|
/**
|
2014-03-20 17:05:04 -04:00
|
|
|
* @url GET /:app_uid
|
2014-03-17 09:09:29 -04:00
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $app_uid {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function doGetCaseInfo($app_uid)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-20 17:05:04 -04:00
|
|
|
$oData = $cases->getCaseInfo($app_uid, $userUid);
|
2014-03-18 11:59:28 -04:00
|
|
|
return $oData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-20 17:05:04 -04:00
|
|
|
* @url GET /:app_uid/current-task
|
2014-03-17 09:09:29 -04:00
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $app_uid {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function doGetTaskCase($app_uid)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-03-20 17:05:04 -04:00
|
|
|
$userUid = $this->getUserId();
|
2014-03-17 09:09:29 -04:00
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-20 17:05:04 -04:00
|
|
|
$oData = $cases->getTaskCase($app_uid, $userUid);
|
2014-03-18 11:59:28 -04:00
|
|
|
return $oData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $pro_uid {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $tas_uid {@from body} {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
* @param array $variables {@from body}
|
|
|
|
|
*
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function doPostCase($pro_uid, $tas_uid, $variables=null)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-20 17:05:04 -04:00
|
|
|
$oData = $cases->addCase($pro_uid, $tas_uid, $userUid, $variables);
|
|
|
|
|
return $oData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST /impersonate
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $pro_uid {@from body} {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
* @param string $usr_uid {@from body} {@min 32}{@max 32}
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $tas_uid {@from body} {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
* @param array $variables {@from body}
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function doPostCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables=null)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-20 17:05:04 -04:00
|
|
|
$oData = $cases->addCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables);
|
|
|
|
|
return $oData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-20 17:05:04 -04:00
|
|
|
* @url PUT /:app_uid/reassign-case
|
2014-03-17 09:09:29 -04:00
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $app_uid {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
* @param string $usr_uid_source {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $usr_uid_target {@from body} {@min 32}{@max 32}
|
2014-03-18 17:05:30 -04:00
|
|
|
* @param string $del_index {@from body}
|
2014-03-17 09:09:29 -04:00
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function doPutReassignCase($app_uid, $usr_uid_source, $usr_uid_target, $del_index = null)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-20 17:05:04 -04:00
|
|
|
$cases->updateReassignCase($app_uid, $userUid, $del_index, $usr_uid_source, $usr_uid_target);
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-20 17:05:04 -04:00
|
|
|
* @url PUT /:app_uid/route-case
|
2014-03-17 09:09:29 -04:00
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $app_uid {@from body} {@min 32}{@max 32}
|
2014-03-17 09:09:29 -04:00
|
|
|
* @param string $del_index {@from body}
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function doPutRouteCase($app_uid, $del_index = null)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-20 17:05:04 -04:00
|
|
|
$cases->updateRouteCase($app_uid, $userUid, $del_index);
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-18 14:37:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cancel Case
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 1}{@max 32}
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url PUT /:cas_uid/cancel-case
|
|
|
|
|
*/
|
|
|
|
|
public function doPutCancelCase($cas_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$cases->putCancelCase($cas_uid, $userUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pause Case
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 1}{@max 32}
|
|
|
|
|
* @param string $unpaused_date {@from body}
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url PUT /:cas_uid/pause-case
|
|
|
|
|
*/
|
|
|
|
|
public function doPutPauseCase($cas_uid, $unpaused_date = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
if ($unpaused_date == null) {
|
|
|
|
|
$cases->putPauseCase($cas_uid, $userUid);
|
|
|
|
|
} else {
|
|
|
|
|
$cases->putPauseCase($cas_uid, $userUid, false, $unpaused_date);
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unpause Case
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 1}{@max 32}
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url PUT /:cas_uid/unpause-case
|
|
|
|
|
*/
|
|
|
|
|
public function doPutUnpauseCase($cas_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$cases->putUnpauseCase($cas_uid, $userUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unpause Case
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 1}{@max 32}
|
|
|
|
|
* @param string $tri_uid {@min 1}{@max 32}
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url PUT /:cas_uid/execute-trigger/:tri_uid
|
|
|
|
|
*/
|
|
|
|
|
public function doPutExecuteTriggerCase($cas_uid, $tri_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$cases->putExecuteTriggerCase($cas_uid, $tri_uid, $userUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete Case
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 1}{@max 32}
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url DELETE /:cas_uid
|
|
|
|
|
*/
|
|
|
|
|
public function doDeleteCase($cas_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$cases->deleteCase($cas_uid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-14 15:33:35 -04:00
|
|
|
}
|
|
|
|
|
|