/**
  * 
  * @return ConnectorResponse
  */
 public function sendInvoiceBasedOnProforma()
 {
     $this->_setProperAccountancyMonth();
     $requestUrl = sprintf("%s%s.%s", self::API_GET_INVOICE_PROFORMA_ADD_URL, InvoiceAbstract::filterNumber($this->_invoice->{InvoiceProformaResponse::KEY_PELNY_NUMER}), self::DEFAULT_CONNECTION_FILE_TYPE);
     $this->_initCurrentCurl($requestUrl);
     $key = Utils::hexToStr($this->_getConfig()->{ConnectorConfig::API_KEY_INVOICE});
     $messageHash = Utils::hmac($key, sprintf("%s%s%s", $requestUrl, $this->_getConfig()->{ConnectorConfig::API_LOGIN}, ConnectorConfig::API_KEY_INVOICE_NAME));
     $this->_setCurlGetOptions($requestUrl, $this->_getRequestHeaders($messageHash));
     return ConnectorResponse::factory(curl_exec($this->_currentCurl));
 }
 /**
  * @return ConnectorResponse
  */
 public function send()
 {
     $this->_setProperAccountancyMonth();
     $content = $this->_invoice->toJson();
     $this->_initCurrentCurl(self::API_INVOICE_SEND_URL);
     $key = Utils::hexToStr($this->_getConfig()->{ConnectorConfig::API_KEY_INVOICE});
     $messageHash = Utils::hmac($key, sprintf("%s%s%s%s", self::API_INVOICE_SEND_URL, $this->_getConfig()->{ConnectorConfig::API_LOGIN}, ConnectorConfig::API_KEY_INVOICE_NAME, $content));
     $this->_setCurlPostOptions(self::API_INVOICE_SEND_URL, $this->_getRequestHeaders($messageHash), $content);
     return ConnectorResponse::factory(curl_exec($this->_currentCurl));
 }
 /**
  * 
  * @param array $data
  * @throws IfirmaException
  */
 private function _checkResponseBeforePopulatingInvoice($data)
 {
     if (!isset($data[ConnectorResponse::KEY_RESPONSE_CONTAINER])) {
         throw new IfirmaException(sprintf("Unable to create object. Missing \"%s\" container in json response.", ConnectorResponse::KEY_RESPONSE_CONTAINER));
     }
     if (isset($data[ConnectorResponse::KEY_RESPONSE_CONTAINER]) && isset($data[ConnectorResponse::KEY_RESPONSE_CONTAINER][ConnectorResponse::KEY_CODE]) && !ConnectorResponse::isResponseCodeOk($data[ConnectorResponse::KEY_RESPONSE_CONTAINER][ConnectorResponse::KEY_CODE])) {
         throw new IfirmaException(isset($data[ConnectorResponse::KEY_RESPONSE_CONTAINER][ConnectorResponse::KEY_INFORMATION]) ? $data[ConnectorResponse::KEY_RESPONSE_CONTAINER][ConnectorResponse::KEY_INFORMATION] : "Invalid response.");
     }
 }