private function sendRequest($uri, $postData = null)
 {
     try {
         $fullUrl = $this->url . '/v3' . $uri;
         // more info: https://curl.haxx.se/docs/caextract.html
         $verify = __DIR__ . '/../../cacert.pem';
         if (!file_exists($verify)) {
             throw new RuntimeException('cacert.pem not found: ' . $verify);
         }
         $headers = array();
         if ($postData) {
             $stream = \GuzzleHttp\Stream\Stream::factory($postData);
             $res = $this->httpClient->post($fullUrl, ['headers' => $headers, 'body' => $stream, 'auth' => [$this->username, $this->password], 'verify' => $verify]);
         } else {
             $res = $this->httpClient->get($fullUrl, ['headers' => $headers, 'auth' => [$this->username, $this->password], 'verify' => $verify]);
         }
         if ($res->getStatusCode() == 200) {
             return (string) $res->getBody();
         }
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         if (!$e->getResponse()) {
             throw new NoResponseException('NO_RESPONSE', 'No response / connection error requesting ' . $fullUrl);
         }
         ErrorResponseHandler::handle($e->getResponse());
     }
 }
 private function sendRequest($uri, $postData = null)
 {
     try {
         $fullUrl = $this->url . '/v1' . $uri;
         // stripping http(s) because of load-balancer. Hub sees http only
         //$fullUrl = str_replace('https', 'http', $fullUrl);
         $hashSource = $fullUrl . $postData . $this->password;
         //echo "HASHING: $hashSource\n";
         $securityHash = sha1($hashSource);
         //echo "Requesting: $fullUrl\n";
         $headers = ['uuid' => $this->username, 'securityhash' => $securityHash];
         if ($postData) {
             $stream = \GuzzleHttp\Stream\Stream::factory($postData);
             $res = $this->httpClient->post($fullUrl, ['headers' => $headers, 'body' => $stream]);
         } else {
             $res = $this->httpClient->get($fullUrl, ['headers' => $headers]);
         }
         if ($res->getStatusCode() == 200) {
             return $res->getBody();
         }
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         ErrorResponseHandler::handle($e->getResponse());
     }
 }
 private function getResourceDataV3(Source $source, $accept = null)
 {
     $url = $source->getUrl();
     $jwt = $source->getJwt();
     if (!$url) {
         throw new RuntimeException("No source URL to get resource data");
     }
     if (!$jwt) {
         throw new RuntimeException("No source JWT to get resource data");
     }
     if ($jwt) {
         $url .= "?jwt=" . $jwt;
     }
     if ($accept) {
         $url .= '&accept=' . $accept;
     }
     //echo "REQUESTING: $url\n";
     try {
         $res = $this->httpClient->get($url, ['headers' => [], 'verify' => $this->verify]);
         if ($res->getStatusCode() == 200) {
             $res = (string) $res->getBody();
             return $res;
         }
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         ErrorResponseHandler::handle($e->getResponse());
     }
 }