/**
  * @return boolean
  */
 public function execute()
 {
     $this->curl = new Curl();
     $this->curl->setOpt(CURLOPT_ENCODING, 'gzip');
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $this->curl->setOpt(CURLOPT_HTTPHEADER, array('Accept: application/xml'));
     $this->prepareRequest();
     if (!$this->xmlRequest) {
         $this->lastError = new Exception('Request XML is not defined.');
         return false;
     }
     if (!isset(static::$API_METHOD) || !static::$API_METHOD) {
         $this->lastError = new Exception('API method is not defined.');
         return false;
     }
     $url = rtrim(static::ENDPOINT, '/') . '/' . static::ENDPOINT_VERSION . '/' . static::$API_METHOD;
     $data = array();
     if (static::$HTTP_METHOD === EANFacade::HTTP_METHOD_POST) {
         $data['xml'] = XMLUtils::SXEasXML($this->xmlRequest);
         $url .= '?' . Utils::httpBuildQuery3986($this->params);
     } else {
         $data = array_merge($this->params, array('xml' => XMLUtils::SXEasXML($this->xmlRequest)));
     }
     if (static::$HTTP_METHOD === EANFacade::HTTP_METHOD_GET) {
         $this->curl->get($url, $data);
         $this->curl->close();
     } else {
         if (static::$HTTP_METHOD === EANFacade::HTTP_METHOD_POST) {
             $this->curl->post($url, $data);
             $this->curl->close();
         } else {
             $this->lastError = new Exception('Invalid method for API call.');
             return false;
         }
     }
     if ($this->curl->error) {
         $this->lastError = new Exception($this->curl->errorMessage);
         return false;
     }
     try {
         if ($this->curl->response instanceof SimpleXMLElement) {
             $this->xmlResponse = $this->curl->response;
         } else {
             $this->xmlResponse = new SimpleXMLElement($this->curl->response);
         }
     } catch (Exception $e) {
         $this->lastError = $e;
         return false;
     }
     $this->lastError = null;
     $this->prepareResponse();
     return true;
 }
 /**
  * @return string
  */
 public function asXML()
 {
     return XMLUtils::SXEasXML($this->xml);
 }