/**
  *
  * @param RealestateCoNz_Api_Http_Response $response
  * @param RealestateCoNz_Api_Client $client
  * @return mixed
  */
 public function parseResponse(RealestateCoNz_Api_Http_Response $response, $client)
 {
     return json_decode($response->getBody(), true);
 }
 /**
  * Send request to the remote server
  *
  * @throws RealestateCoNz_Api_Http_Adapter_Exception
  * @param string        $method
  * @param string        $url
  * @param array         $headers
  * @param string        $body
  * @return string Request as text
  */
 public function write($method, $url, $headers = array(), $body = null)
 {
     // ensure correct method name
     $method = strtoupper($method);
     // set URL
     curl_setopt($this->curl, CURLOPT_URL, $url);
     $curlValue = true;
     switch ($method) {
         case 'GET':
             $curlMethod = CURLOPT_HTTPGET;
             break;
         case 'POST':
             $curlMethod = CURLOPT_POST;
             break;
         case 'PUT':
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "PUT";
             break;
         case 'DELETE':
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "DELETE";
             break;
         default:
             // Unsupported method
             throw new RealestateCoNz_Api_Http_Adapter_Exception("Method not supported: " . $method);
     }
     curl_setopt($this->curl, $curlMethod, $curlValue);
     // don't return headers
     curl_setopt($this->curl, CURLOPT_HEADER, true);
     // ensure actual response is returned
     curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
     // set headers
     curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
     //
     curl_setopt($this->curl, CURLINFO_HEADER_OUT, true);
     // set request body
     if (null !== $body) {
         if ($method == 'POST' || $method == 'PUT' || $method == 'DELETE') {
             curl_setopt($this->curl, CURLOPT_POSTFIELDS, $body);
         }
     }
     // send the request
     $response_body = curl_exec($this->curl);
     // check for connection errors
     if (false === $response_body) {
         throw new RealestateCoNz_Api_Http_Adapter_Exception("Error occured while executing request: " . curl_error($this->curl), curl_errno($this->curl));
     }
     $response_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
     $this->response = new RealestateCoNz_Api_Http_Response($response_code, RealestateCoNz_Api_Http_Response::extractHeaders($response_body), RealestateCoNz_Api_Http_Response::extractBody($response_body));
     $request = array();
     $request['uri'] = $url;
     $request['method'] = $method;
     $request['headers'] = curl_getinfo($this->curl, CURLINFO_HEADER_OUT);
     $request['body'] = $body;
     return $request;
 }