Arreglo y correcion del api para Events
This commit is contained in:
@@ -93,14 +93,28 @@ class Event
|
||||
if ( ($sProcessUID == '') || (count($dataEvent) == 0) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->processExists($sProcessUID))) {
|
||||
throw (new \Exception( 'This process doesn\'t exist!' ));
|
||||
}
|
||||
|
||||
$dataEvent = array_change_key_case($dataEvent, CASE_UPPER);
|
||||
|
||||
$this->validateProcess($sProcessUID);
|
||||
|
||||
if ($dataEvent['EVN_RELATED_TO'] == 'SINGLE') {
|
||||
if (empty($dataEvent['TAS_UID'])) {
|
||||
throw (new \Exception('The field "tas_uid" is required!'));
|
||||
}
|
||||
$this->validateTask($dataEvent['TAS_UID']);
|
||||
} else {
|
||||
if (empty($dataEvent['EVN_TAS_UID_FROM'])) {
|
||||
throw (new \Exception('The field "evn_tas_uid_from" is required!'));
|
||||
}
|
||||
$this->validateTask($dataEvent['EVN_TAS_UID_FROM']);
|
||||
|
||||
if (empty($dataEvent['EVN_TAS_UID_TO'])) {
|
||||
throw (new \Exception('The field "evn_tas_uid_to" is required!'));
|
||||
}
|
||||
$this->validateTask($dataEvent['EVN_TAS_UID_TO']);
|
||||
}
|
||||
|
||||
$this->validateTrigger($dataEvent['TRI_UID']);
|
||||
if ( $create && (isset($dataEvent['ENV_UID'])) ) {
|
||||
unset($dataEvent['ENV_UID']);
|
||||
}
|
||||
@@ -139,5 +153,47 @@ class Event
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function validateProcess($proUid) {
|
||||
$proUid = trim($proUid);
|
||||
if ($proUid == '') {
|
||||
throw (new \Exception('This process doesn\'t exist!'));
|
||||
}
|
||||
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->processExists($proUid))) {
|
||||
throw (new \Exception('This process doesn\'t exist!'));
|
||||
}
|
||||
|
||||
return $proUid;
|
||||
}
|
||||
|
||||
public function validateTask($taskUid) {
|
||||
$taskUid = trim($taskUid);
|
||||
if ($taskUid == '') {
|
||||
throw (new \Exception('This task doesn\'t exist!'));
|
||||
}
|
||||
|
||||
$oTask = new \Task();
|
||||
if (!($oTask->taskExists($taskUid))) {
|
||||
throw (new \Exception('This task doesn\'t exist!'));
|
||||
}
|
||||
|
||||
return $taskUid;
|
||||
}
|
||||
|
||||
public function validateTrigger($triUid) {
|
||||
$triUid = trim($triUid);
|
||||
if ($triUid == '') {
|
||||
throw (new \Exception('This trigger doesn\'t exist!'));
|
||||
}
|
||||
|
||||
$oTriggers = new \Triggers();
|
||||
if (!($oTriggers->TriggerExists($triUid))) {
|
||||
throw (new \Exception('This trigger doesn\'t exist!'));
|
||||
}
|
||||
|
||||
return $triUid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,13 +85,13 @@ class Event extends Api
|
||||
* @param string $evn_status {@from body} {@choice ACTIVE,INACTIVE}
|
||||
* @param string $evn_action {@from body} {@choice SEND_MESSAGE,EXECUTE_CONDITIONAL_TRIGGER,EXECUTE_TRIGGER}
|
||||
* @param string $evn_related_to {@from body} {@choice SINGLE,MULTIPLE}
|
||||
* @param string $tas_uid {@from body} {@min 1}
|
||||
* @param string $evn_tas_uid_from {@from body} {@min 1}
|
||||
* @param string $evn_tas_estimated_duration {@from body} {@min 1}
|
||||
* @param string $evn_time_unit {@from body} {@choice DAYS,HOURS}
|
||||
* @param string $evn_when {@from body} {@type float}
|
||||
* @param string $evn_when_occurs {@from body} {@choice AFTER_TIME,TASK_STARTED}
|
||||
* @param string $tri_uid {@from body} {@min 1}
|
||||
* @param string $tas_uid {@from body}
|
||||
* @param string $evn_tas_uid_from {@from body}
|
||||
* @param string $evn_tas_uid_to {@from body}
|
||||
* @param string $evn_conditions {@from body}
|
||||
*
|
||||
@@ -111,13 +111,13 @@ class Event extends Api
|
||||
$evn_status,
|
||||
$evn_action,
|
||||
$evn_related_to,
|
||||
$tas_uid,
|
||||
$evn_tas_uid_from,
|
||||
$evn_tas_estimated_duration,
|
||||
$evn_time_unit,
|
||||
$evn_when,
|
||||
$evn_when_occurs,
|
||||
$tri_uid,
|
||||
$tas_uid = '',
|
||||
$evn_tas_uid_from = '',
|
||||
$evn_tas_uid_to = '',
|
||||
$evn_conditions = ''
|
||||
) {
|
||||
@@ -146,13 +146,13 @@ class Event extends Api
|
||||
* @param string $evn_status {@from body} {@choice ACTIVE,INACTIVE}
|
||||
* @param string $evn_action {@from body} {@choice SEND_MESSAGE,EXECUTE_CONDITIONAL_TRIGGER,EXECUTE_TRIGGER}
|
||||
* @param string $evn_related_to {@from body} {@choice SINGLE,MULTIPLE}
|
||||
* @param string $tas_uid {@from body} {@min 1}
|
||||
* @param string $evn_tas_uid_from {@from body} {@min 1}
|
||||
* @param string $evn_tas_estimated_duration {@from body} {@min 1}
|
||||
* @param string $evn_time_unit {@from body} {@choice DAYS,HOURS}
|
||||
* @param string $evn_when {@from body} {@type float}
|
||||
* @param string $evn_when_occurs {@from body} {@choice AFTER_TIME,TASK_STARTED}
|
||||
* @param string $tri_uid {@from body} {@min 1}
|
||||
* @param string $tas_uid {@from body}
|
||||
* @param string $evn_tas_uid_from {@from body}
|
||||
* @param string $evn_tas_uid_to {@from body}
|
||||
* @param string $evn_conditions {@from body}
|
||||
*
|
||||
@@ -172,13 +172,13 @@ class Event extends Api
|
||||
$evn_status,
|
||||
$evn_action,
|
||||
$evn_related_to,
|
||||
$tas_uid,
|
||||
$evn_tas_uid_from,
|
||||
$evn_tas_estimated_duration,
|
||||
$evn_time_unit,
|
||||
$evn_when,
|
||||
$evn_when_occurs,
|
||||
$tri_uid,
|
||||
$tas_uid = '',
|
||||
$evn_tas_uid_from = '',
|
||||
$evn_tas_uid_to = '',
|
||||
$evn_conditions = ''
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user