Merged in feature/PMC-10 (pull request #6688)

PMC-10

Approved-by: Rodrigo Quelca <rockoinfo@yahoo.com>
Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2018-11-22 15:46:22 +00:00
committed by Julio Cesar Laura Avendaño
5 changed files with 343 additions and 11 deletions

View File

@@ -1393,4 +1393,38 @@ class Cases extends Api
}
}
/**
* Upload attachment related to the case, it does not need docUid
* Upload document related to the case, it does need docUid
*
* @url POST /:app_uid/upload/:var_name
* @url POST /:app_uid/upload/:var_name/:doc_uid
* @url POST /:app_uid/upload/:var_name/:doc_uid/:app_doc_uid
*
* @param string $app_uid
* @param string $var_name
* @param string $doc_uid
* @param string $app_doc_uid
*
* @return array
* @throws RestException
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function uploadDocumentToCase($app_uid, $var_name, $doc_uid = '-1', $app_doc_uid = null)
{
try {
$userUid = $this->getUserId();
$case = new BmCases();
$response = $case->uploadFiles($userUid, $app_uid, $var_name, $doc_uid, $app_doc_uid);
} catch (ExceptionRestApi $e) {
throw new RestException($e->getCode(), $e->getMessage());
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
return $response;
}
}