/**
  * Creates and returns an instance of the \Mibew\API\API class.
  *
  * @return \Mibew\API\API
  */
 protected function getMibewAPIInstance()
 {
     return MibewAPI::getAPI('\\Mibew\\API\\Interaction\\ChatInteraction');
 }
 /**
  * Process request
  *
  * @param array $request 'Requests' array. See Mibew API for details.
  * @param mixed $result_function Control existance of the 'result' function
  *   in request. Use boolean true if 'result' function must exists in
  *   request, boolean false if must not and null if it doesn't matter.
  * @return array Array of requests results.
  */
 protected function processRequest($request, $result_function = null)
 {
     $context = new \Mibew\API\ExecutionContext();
     // Get result functions
     $result_function = $this->mibewAPI->getResultFunction($request['functions'], $result_function);
     // Request contains not only result function
     if (!is_null($result_function) && count($request['functions']) > 1) {
         trigger_error('Request contains not only result function', E_USER_WARNING);
     }
     if (is_null($result_function)) {
         // Execute functions
         foreach ($request['functions'] as $function) {
             if (!$this->processFunction($function, $context)) {
                 // Stop if errorCode is set and not equals to 0
                 break;
             }
         }
         return $context->getResults();
     } else {
         // Return result
         return $result_function['arguments'];
     }
 }