Class: NfsePrefeituraSp::Services::Sync::ConsultaCnpj
- Inherits:
-
Object
- Object
- NfsePrefeituraSp::Services::Sync::ConsultaCnpj
- Defined in:
- lib/nfse_prefeitura_sp/services/sync/consulta_cnpj.rb
Overview
PedidoConsultaCNPJ
Constant Summary collapse
- OPERATION_REQUEST =
:consulta_cnpj- OPERATION_RESPONSE =
:consulta_cnpj_response
Instance Method Summary collapse
-
#initialize(data, signer) ⇒ ConsultaCnpj
constructor
A new instance of ConsultaCnpj.
- #request_xml ⇒ Object
Constructor Details
#initialize(data, signer) ⇒ ConsultaCnpj
Returns a new instance of ConsultaCnpj.
6 7 8 9 |
# File 'lib/nfse_prefeitura_sp/services/sync/consulta_cnpj.rb', line 6 def initialize(data, signer) @data = data @signer = signer end |
Instance Method Details
#request_xml ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nfse_prefeitura_sp/services/sync/consulta_cnpj.rb', line 11 def request_xml builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.PedidoConsultaCNPJ("xmlns" => "http://www.prefeitura.sp.gov.br/nfe") do xml.Cabecalho('Versao' => '2', 'xmlns' => '') do xml.CPFCNPJRemetente do xml.CNPJ @data[:cnpj_remetente] end end xml.CNPJContribuinte('xmlns' => '') do xml.CNPJ @data[:cnpj_contribuinte] end end end signed_xml = @signer.sign_xml(builder.to_xml) ("<VersaoSchema>#{NfsePrefeituraSp::XSD_VERSION.to_s}</VersaoSchema><MensagemXML>" + "<![CDATA[#{signed_xml}]]>" + "</MensagemXML>").gsub(/\n/,'') end |