2013-12-13 10:29:51 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api\Project;
|
2013-12-13 10:29:51 -04:00
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
2014-01-23 11:42:54 -04:00
|
|
|
* Project\Trigger Api Controller
|
2013-12-13 10:29:51 -04:00
|
|
|
*
|
2013-12-13 11:21:11 -04:00
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2013-12-13 10:29:51 -04:00
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Trigger extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @param string $projectUid {@min 1} {@max 32}
|
|
|
|
|
*
|
2013-12-13 11:21:11 -04:00
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
2013-12-13 10:29:51 -04:00
|
|
|
* @url GET /:projectUid/triggers
|
|
|
|
|
*/
|
|
|
|
|
public function doGetTriggers($projectUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$trigger = new \ProcessMaker\BusinessModel\Trigger();
|
2013-12-13 11:21:11 -04:00
|
|
|
$response = $trigger->getTriggers($projectUid);
|
2013-12-13 10:29:51 -04:00
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $projectUid {@min 1} {@max 32}
|
|
|
|
|
* @param string $triggerUid {@min 1} {@max 32}
|
2013-12-13 11:21:11 -04:00
|
|
|
* @return array
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
2013-12-13 10:29:51 -04:00
|
|
|
*
|
|
|
|
|
* @url GET /:projectUid/trigger/:triggerUid
|
|
|
|
|
*/
|
|
|
|
|
public function doGetTrigger($projectUid, $triggerUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$trigger = new \ProcessMaker\BusinessModel\Trigger();
|
2013-12-13 10:29:51 -04:00
|
|
|
$response = $trigger->getDataTrigger($triggerUid);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $projectUid {@min 1} {@max 32}
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
* @param string $tri_title {@from body} {@min 1}
|
|
|
|
|
* @param string $tri_description {@from body}
|
2014-01-23 16:47:38 -04:00
|
|
|
* @param string $tri_type {@from body}
|
2013-12-13 10:29:51 -04:00
|
|
|
* @param string $tri_webbot {@from body}
|
|
|
|
|
* @param string $tri_param {@from body}
|
2013-12-13 11:21:11 -04:00
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
2013-12-13 10:29:51 -04:00
|
|
|
*
|
|
|
|
|
* @url POST /:projectUid/trigger
|
2013-12-16 09:25:32 -04:00
|
|
|
* @status 201
|
2013-12-13 10:29:51 -04:00
|
|
|
*/
|
|
|
|
|
public function doPostTrigger($projectUid, $request_data, $tri_title, $tri_description = '', $tri_type = 'SCRIPT', $tri_webbot = '', $tri_param = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$trigger = new \ProcessMaker\BusinessModel\Trigger();
|
2013-12-13 10:29:51 -04:00
|
|
|
$response = $trigger->saveTrigger($projectUid, $request_data, true);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $projectUid {@min 1} {@max 32}
|
|
|
|
|
* @param string $triggerUid {@min 1} {@max 32}
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
* @param string $tri_title {@from body}
|
|
|
|
|
* @param string $tri_description {@from body}
|
2014-01-23 16:47:38 -04:00
|
|
|
* @param string $tri_type {@from body}
|
2013-12-13 10:29:51 -04:00
|
|
|
* @param string $tri_webbot {@from body}
|
|
|
|
|
* @param string $tri_param {@from body}
|
2013-12-13 11:21:11 -04:00
|
|
|
* @return void
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
2013-12-13 10:29:51 -04:00
|
|
|
*
|
|
|
|
|
* @url PUT /:projectUid/trigger/:triggerUid
|
|
|
|
|
*/
|
|
|
|
|
public function doPutTrigger($projectUid, $triggerUid, $request_data, $tri_title = '', $tri_description = '', $tri_type = 'SCRIPT', $tri_webbot = '', $tri_param = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['tri_uid'] = $triggerUid;
|
2014-04-02 17:02:02 -04:00
|
|
|
$trigger = new \ProcessMaker\BusinessModel\Trigger();
|
2013-12-13 10:29:51 -04:00
|
|
|
$trigger->saveTrigger($projectUid, $request_data, false, $triggerUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $projectUid {@min 1} {@max 32}
|
|
|
|
|
* @param string $triggerUid {@min 1} {@max 32}
|
2013-12-13 11:21:11 -04:00
|
|
|
* @return void
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2013-12-13 10:29:51 -04:00
|
|
|
* @url DELETE /:projectUid/trigger/:triggerUid
|
|
|
|
|
*/
|
|
|
|
|
public function doDeleteTrigger($projectUid, $triggerUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$trigger = new \ProcessMaker\BusinessModel\Trigger();
|
2013-12-13 10:29:51 -04:00
|
|
|
$response = $trigger->deleteTrigger($triggerUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|