Class: Nfse::ConsultaLote

Inherits:
Base
  • Object
show all
Defined in:
lib/nfse/consultalote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#get_wsdl

Constructor Details

#initialize(code_ibge, cnpj, inscricao_municipal, protocolo) ⇒ ConsultaLote

Returns a new instance of ConsultaLote.



7
8
9
10
11
12
13
14
# File 'lib/nfse/consultalote.rb', line 7

def initialize(code_ibge, cnpj, inscricao_municipal, protocolo)
    self.template_path = File.expand_path("../../templates/", __FILE__)
    
    @code_ibge = code_ibge
    @cnpj = cnpj
    @inscricao_municipal = inscricao_municipal
    @protocolo = protocolo
end

Instance Attribute Details

#cnpjObject

Returns the value of attribute cnpj.



4
5
6
# File 'lib/nfse/consultalote.rb', line 4

def cnpj
  @cnpj
end

#code_ibgeObject

Returns the value of attribute code_ibge.



4
5
6
# File 'lib/nfse/consultalote.rb', line 4

def code_ibge
  @code_ibge
end

#inscricao_municipalObject

Returns the value of attribute inscricao_municipal.



4
5
6
# File 'lib/nfse/consultalote.rb', line 4

def inscricao_municipal
  @inscricao_municipal
end

#protocoloObject

Returns the value of attribute protocolo.



4
5
6
# File 'lib/nfse/consultalote.rb', line 4

def protocolo
  @protocolo
end

Instance Method Details

#consultarObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nfse/consultalote.rb', line 16

def consultar()
    wsdl = get_wsdl[@code_ibge]
    client = Savon.client(wsdl: wsdl)            
    xml = self.render
    response = client.call(:consultar_lote_rps, xml: xml)
    data = response.body
    data = data[:consultar_lote_rps_response][:consultar_lote_rps_result]            

    xml_doc = Nokogiri::XML(data)
    return xml_doc.xpath("//MensagemRetorno").text()
end