RestService::addActivityInternal: Bitrix method

      
<?php 
//  Bitrix\Bizproc\RestService :: addActivityInternal()
//  /dist/bitrix/modules/bizproc/lib/restservice.php:182

    
private static function addActivityInternal($params$server$isRobot false)
    {
        if(!
$server->getClientId())
        {
            throw new 
AccessException("Application context required");
        }

        
self::checkAdminPermissions();
        
$params self::prepareActivityData($params);

        if (
$isRobot)
            
self::validateRobot($params$server);
        else
            
self::validateActivity($params$server);

        
$params['APP_ID'] = $server->getClientId();
        
$params['INTERNAL_CODE'] = self::generateInternalCode($params);
        
$params['APP_NAME'] = self::getAppName($params['APP_ID']);

        
$iterator RestActivityTable::getList(array(
            
'select' => array('ID'),
            
'filter' => array('=INTERNAL_CODE' => $params['INTERNAL_CODE'])
        ));
        
$result $iterator->fetch();
        if (
$result)
        {
            throw new 
RestException('Activity or Robot already installed!'self::ERROR_ACTIVITY_ALREADY_INSTALLED);
        }

        
$params['AUTH_USER_ID'] = isset($params['AUTH_USER_ID'])? (int) $params['AUTH_USER_ID'] : 0;
        
$params['IS_ROBOT'] = $isRobot 'Y' 'N';
        
$params['USE_PLACEMENT'] = ($params['USE_PLACEMENT'] === 'Y') ? 'Y' 'N';

        
$result RestActivityTable::add($params);

        if (
$result->getErrors())
        {
            throw new 
RestException('Activity save error!'self::ERROR_ACTIVITY_ADD_FAILURE);
        }

        return 
true;
    }