/**
  * Sends request to the API server.
  *
  * @param string                  $method     Request method.
  * @param string                  $url        URL.
  * @param array                   $data       Request data.
  * @param string                  $endpoint   Endpoint.
  * @param AuthenticationInterface $credential Credential.
  * @param boolean                 $is_file    This is a file upload request.
  * @param boolean                 $debug      Debug this request.
  *
  * @return array|string
  */
 public function sendRequest($method, $url, $data = array(), $endpoint, AuthenticationInterface $credential, $is_file = false, $debug = false)
 {
     if ($method == 'GET') {
         $result = $this->getFromCache($url, $data, $endpoint);
         if ($result) {
             // $this->setCache($url, $data, $endpoint, $result);
             return $result;
         }
     }
     $result = $this->client->sendRequest($method, $url, $data, $endpoint, $credential);
     if ($method == 'GET') {
         $this->setCache($url, $data, $endpoint, $result);
     }
     return $result;
 }
 /**
  * Traces a request.
  *
  * @param string                        $method     Request method.
  * @param array                         $data       Request data.
  * @param  AuthenticationInterface|null $credential Credential.
  * @param boolean                       $is_file    This is a file upload request.
  *
  * @return array
  */
 protected function traceRequest($method, $data = array(), AuthenticationInterface $credential = null, $is_file = false)
 {
     if (!isset($credential)) {
         $credential = new Anonymous();
     }
     $path_info_variables = array('http_code' => 200, 'response_mode' => 'trace');
     if (is_array($data)) {
         if (isset($data['http_code'])) {
             $path_info_variables['http_code'] = $data['http_code'];
             unset($data['http_code']);
         }
         if (isset($data['response_mode'])) {
             $path_info_variables['response_mode'] = $data['response_mode'];
             unset($data['response_mode']);
         }
     }
     $path_info = array();
     foreach ($path_info_variables as $variable_name => $variable_value) {
         $path_info[] = $variable_name;
         $path_info[] = $variable_value;
     }
     $result = $this->client->sendRequest($method, '/tests/debug_response.php/' . implode('/', $path_info) . '/', $data, rtrim($_SERVER['REPO_URL'], '/'), $credential, $is_file);
     if ($path_info_variables['response_mode'] === 'trace') {
         return unserialize($result);
     }
     return $result;
 }
 public function downloadAttachment($url)
 {
     $result = $this->client->sendRequest(self::REQUEST_GET, $url, array(), null, $this->authentication, true, false);
     return $result;
 }