2014-01-31 13:09:16 -04:00
|
|
|
<?php
|
|
|
|
|
namespace Services\Api\ProcessMaker;
|
|
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class User extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @url GET
|
2014-02-14 17:00:03 -04:00
|
|
|
* @param string $filter
|
|
|
|
|
* @param int $start
|
|
|
|
|
* @param int $limit
|
2014-01-31 13:09:16 -04:00
|
|
|
*/
|
2014-02-07 15:29:23 -04:00
|
|
|
public function doGetUsers($filter = '', $start = null, $limit = null)
|
2014-01-31 13:09:16 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$user = new \BusinessModel\User();
|
2014-02-13 15:56:26 -04:00
|
|
|
$response = $user->getUsers($filter, $start, $limit);
|
2014-01-31 13:09:16 -04:00
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:usr_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $usr_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
2014-02-07 15:29:23 -04:00
|
|
|
public function doGetUser($usr_uid)
|
2014-01-31 13:09:16 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$user = new \BusinessModel\User();
|
|
|
|
|
$response = $user->getUser($usr_uid);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST
|
|
|
|
|
*
|
2014-02-04 16:25:34 -04:00
|
|
|
* @param array $request_data
|
2014-01-31 13:09:16 -04:00
|
|
|
*
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-02-14 09:39:24 -04:00
|
|
|
public function doPostUser($request_data)
|
|
|
|
|
{
|
2014-01-31 13:09:16 -04:00
|
|
|
try {
|
2014-02-04 16:25:34 -04:00
|
|
|
$user = new \BusinessModel\User();
|
|
|
|
|
$arrayData = $user->create($request_data);
|
2014-01-31 13:09:16 -04:00
|
|
|
$response = $arrayData;
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-04 16:25:34 -04:00
|
|
|
* @url PUT /:usr_uid
|
2014-01-31 13:09:16 -04:00
|
|
|
*
|
2014-02-04 16:25:34 -04:00
|
|
|
* @param string $usr_uid {@min 32}{@max 32}
|
2014-01-31 13:09:16 -04:00
|
|
|
* @param array $request_data
|
|
|
|
|
*/
|
2014-02-14 09:39:24 -04:00
|
|
|
public function doPutUser($usr_uid, $request_data)
|
|
|
|
|
{
|
2014-01-31 13:09:16 -04:00
|
|
|
try {
|
2014-02-05 17:03:53 -04:00
|
|
|
$userLoggedUid = $this->getUserId();
|
2014-02-04 16:25:34 -04:00
|
|
|
$user = new \BusinessModel\User();
|
2014-02-05 17:03:53 -04:00
|
|
|
$arrayData = $user->update($usr_uid, $request_data, $userLoggedUid);
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
return $response;
|
2014-01-31 13:09:16 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-04 16:25:34 -04:00
|
|
|
* @url DELETE /:usr_uid
|
2014-01-31 13:09:16 -04:00
|
|
|
*
|
2014-02-04 16:25:34 -04:00
|
|
|
* @param string $usr_uid {@min 32}{@max 32}
|
2014-01-31 13:09:16 -04:00
|
|
|
*/
|
2014-02-07 15:29:23 -04:00
|
|
|
public function doDeleteUser($usr_uid)
|
2014-01-31 13:09:16 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-02-04 16:25:34 -04:00
|
|
|
$user = new \BusinessModel\User();
|
|
|
|
|
$user->delete($usr_uid);
|
2014-01-31 13:09:16 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-18 16:13:57 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $usr_uid {@min 32} {@max 32}
|
|
|
|
|
*
|
2014-02-20 12:36:01 -04:00
|
|
|
* @url POST /:usr_uid/image-upload
|
2014-02-18 16:13:57 -04:00
|
|
|
*/
|
|
|
|
|
public function doPostUserImageUpload($usr_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$user = new \BusinessModel\User();
|
|
|
|
|
$user->uploadImage($usr_uid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-31 13:09:16 -04:00
|
|
|
}
|
|
|
|
|
|