Class: Nfcom::Webservices::Autorizacao

Inherits:
Base
  • Object
show all
Defined in:
lib/nfcom/webservices/autorizacao.rb

Instance Attribute Summary

Attributes inherited from Base

#certificate, #configuration

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Nfcom::Webservices::Base

Instance Method Details

#enviar(xml_assinado) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/nfcom/webservices/autorizacao.rb', line 6

def enviar(xml_assinado)
  url = configuration.webservice_url(:recepcao)
  unless url
    raise Errors::ConfigurationError,
          "URL de recepção não configurada para #{configuration.estado}"
  end

  xml_limpo = Utils::XmlCleaner.clean(xml_assinado)
  configuration.logger&.debug("XML da nota:\n#{xml_limpo}") if configuration.log_level == :debug

  xml_comprimido = Utils::Compressor.gzip_base64(xml_limpo)

  body_xml = build_nfcom_body(xml_comprimido)
  envelope = montar_envelope(body_xml)

  action = 'http://www.portalfiscal.inf.br/nfcom/wsdl/NFComRecepcao/nfcomRecepcao'
  post_soap(url: url, action: action, xml: envelope)
end