Files
luos/workflow/engine/src/ProcessMaker/Services/Api/Role.php
Victor Saisa Lopez 98f3ff777c ProcessMaker-BE "Role and User (Endpoints)"
- Se han implementado los siguientes Endpoints:
    GET    /api/1.0/{workspace}/role/{rol_uid}/users?filter={filter}&start={start}&limit={limit}
    GET    /api/1.0/{workspace}/role/{rol_uid}/available-users?filter={filter}&start={start}&limit={limit}
    POST   /api/1.0/{workspace}/role/{rol_uid}/user
    DELETE /api/1.0/{workspace}/role/{rol_uid}/user/{usr_uid}
2014-05-28 15:01:18 -04:00

112 lines
2.5 KiB
PHP

<?php
namespace ProcessMaker\Services\Api;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Role Api Controller
*
* @protected
*/
class Role extends Api
{
private $role;
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
$this->role = new \ProcessMaker\BusinessModel\Role();
$this->role->setFormatFieldNameInUppercase(false);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET
*/
public function index($filter = null, $start = null, $limit = null)
{
try {
$response = $this->role->getRoles(array("filter" => $filter), null, null, $start, $limit);
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET /:rol_uid
*
* @param string $rol_uid {@min 32}{@max 32}
*/
public function doGet($rol_uid)
{
try {
$response = $this->role->getRole($rol_uid);
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url POST
*
* @param array $request_data
*
* @status 201
*/
public function doPost(array $request_data)
{
try {
$arrayData = $this->role->create($request_data);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url PUT /:rol_uid
*
* @param string $rol_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doPut($rol_uid, array $request_data)
{
try {
$arrayData = $this->role->update($rol_uid, $request_data);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url DELETE /:rol_uid
*
* @param string $rol_uid {@min 32}{@max 32}
*/
public function doDelete($rol_uid)
{
try {
$this->role->delete($rol_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}