/**
  * Makes request to remote server using cURL
  *
  * @param Paysera_WalletApi_Http_Request $request
  *
  * @return Paysera_WalletApi_Http_Response
  *
  * @throws Paysera_WalletApi_Exception_HttpException
  * @throws Paysera_WalletApi_Exception_ConfigurationException
  */
 public function makeRequest(Paysera_WalletApi_Http_Request $request)
 {
     $curl = $this->getCurl();
     curl_setopt($curl, CURLOPT_URL, $request->getFullUri());
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getMethod());
     curl_setopt($curl, CURLOPT_HTTPHEADER, array_merge($request->getFormattedHeaders(), array('Expect:')));
     curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getContent());
     $clientCertificate = $request->getClientCertificate();
     if ($clientCertificate !== null) {
         if ($clientCertificate->getCertificatePath() === null || $clientCertificate->getPrivateKeyPath() === null) {
             throw new Paysera_WalletApi_Exception_ConfigurationException('If client certificate is provided, both certificate path and private key path must be set');
         }
         curl_setopt($curl, CURLOPT_SSLCERT, $clientCertificate->getCertificatePath());
         curl_setopt($curl, CURLOPT_SSLCERTTYPE, $clientCertificate->getCertificateType());
         curl_setopt($curl, CURLOPT_SSLKEY, $clientCertificate->getPrivateKeyPath());
         curl_setopt($curl, CURLOPT_SSLKEYTYPE, $clientCertificate->getPrivateKeyType());
         if ($clientCertificate->getCertificatePassword() !== null) {
             curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $clientCertificate->getCertificatePassword());
         }
         if ($clientCertificate->getPrivateKeyPassword() !== null) {
             curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $clientCertificate->getPrivateKeyPassword());
         }
     }
     $result = curl_exec($curl);
     if ($result === false) {
         $exception = new Paysera_WalletApi_Exception_HttpException(curl_error($curl), curl_errno($curl));
         curl_close($curl);
         throw $exception;
     }
     $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     $parts = explode("\r\n\r\n", $result, 2);
     $headers = explode("\r\n", $parts[0]);
     unset($headers[0]);
     // remove status code
     $content = isset($parts[1]) ? $parts[1] : '';
     curl_close($curl);
     return new Paysera_WalletApi_Http_Response($statusCode, $headers, $content);
 }