/**
  * Creates a new request, sends and receives the data, uses caching if defined by the user.
  * @param string $uri The uri this request is sent to.
  * @param string $method The method (GET,PUT,POST,DELETE)
  * @param array $customHeader A customHeader to be sent
  * @param array $data The data to be sent as array
  * @return EActiveResourceResponse The response object
  */
 public function sendRequest($uri, $method, $data = null, $customHeader = null, $contentType = 'application/json', $acceptType = 'application/json')
 {
     ///LOOK FOR CACHED RESPONSES FIRST
     if ($this->queryCachingCount > 0 && $this->queryCachingDuration > 0 && $this->queryCacheID !== false && ($cache = Yii::app()->getComponent($this->queryCacheID)) !== null) {
         $this->queryCachingCount--;
         $cacheKey = 'yii:eactiveresourcerequest:' . $uri . ':' . $method . ':' . $this->recursiveImplode('-', $customHeader);
         $cacheKey .= ':' . $this->recursiveImplode('#', $data);
         if (($result = $cache->get($cacheKey)) !== false) {
             Yii::trace('Respone found in cache', 'ext.EActiveResource.EActiveResourceConnection');
             return $result;
         }
     }
     $request = new EActiveResourceRequest();
     $request->setUri($uri);
     $request->setMethod($method);
     $request->setData($data);
     $request->setContentType($contentType);
     $request->setAcceptType($acceptType);
     $request->setCustomHeader($customHeader);
     $response = $request->run();
     //CACHE RESULT IF CACHE IS SET
     if (isset($cache, $cacheKey)) {
         $cache->set($cacheKey, $response, $this->queryCachingDuration, $this->queryCachingDependency);
     }
     return $response;
 }
 /**
  * Manipulate data with a request. execute requests like DELETE, PUT, POST requests can't be cached.
  * @param EActiveResourceRequest $request The request object
  * @return EActiveResourceResponse The response object
  */
 public function execute(EActiveResourceRequest $request)
 {
     //set connection component specific options
     $request->setCurlHandle($this->_ch);
     $request->setContentType($this->contentType);
     $request->setAcceptType($this->acceptType);
     //AUTH STUFF
     if (isset($this->auth)) {
         $request->setHttpLogin($this->auth['username'], $this->auth['password'], $this->auth['type']);
     }
     //API KEY STUFF
     if (isset($this->apiKey)) {
         $request->setApiKey($this->apiKey['value'], $this->apiKey['name']);
     }
     //SSL STUFF
     if (isset($this->ssl)) {
         $request->setSSL($this->ssl['verifyPeer'], $this->ssl['verifyHost'], $this->ssl['pathToCert']);
     }
     $response = $request->run();
     if ($response->hasErrors()) {
         $response->throwError();
     }
     return $response;
 }