Module: Rnfse::API::Abrasf10::ClassMethods

Included in:
Rnfse::API::Abrasf10
Defined in:
lib/rnfse/api/abrasf_1_0.rb

Instance Method Summary collapse

Instance Method Details

#cancelar_nfse(hash = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rnfse/api/abrasf_1_0.rb', line 83

def cancelar_nfse(hash = {})
  validate_options(hash)
  xml = xml_builder.build_cancelar_nfse_xml(hash) do |inner_xml|
    inner_xml.sign!(certificate: File.read(self.certificate), key: File.read(self.key))
    inner_xml.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
  end
  response = self.soap_client.call(
    :cancelar_nfse,
    soap_action: 'CancelarNfse',
    message_tag: 'CancelarNfse',
    message: { :'xml!' => "<![CDATA[#{xml}]]>" })
  parse_response(response)
end

#consultar_lote_rps(hash = {}) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/rnfse/api/abrasf_1_0.rb', line 72

def consultar_lote_rps(hash = {})
  validate_options(hash)
  xml = xml_builder.build_consultar_lote_rps_xml(hash)
  response = self.soap_client.call(
    :consultar_lote_rps,
    soap_action: 'ConsultarLoteRps',
    message_tag: 'ConsultarLoteRps',
    message: { :'xml!' => "<![CDATA[#{xml}]]>" })
  parse_response(response)
end

#consultar_nfse(hash = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/rnfse/api/abrasf_1_0.rb', line 61

def consultar_nfse(hash = {})
  validate_options(hash)
  xml = xml_builder.build_consultar_nfse_xml(hash)
  response = self.soap_client.call(
    :consultar_nfse,
    soap_action: 'ConsultarNfse',
    message_tag: 'ConsultarNfse',
    message: { :'xml!' => "<![CDATA[#{xml}]]>" })
  parse_response(response)
end

#consultar_nfse_por_rps(hash = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/rnfse/api/abrasf_1_0.rb', line 50

def consultar_nfse_por_rps(hash = {})
  validate_options(hash)
  xml = xml_builder.build_consultar_nfse_por_rps_xml(hash)
  response = self.soap_client.call(
    :consultar_nfse_por_rps,
    soap_action: 'ConsultarNfsePorRps',
    message_tag: 'ConsultarNfsePorRps',
    message: { :'xml!' => "<![CDATA[#{xml}]]>" })
  parse_response(response)
end

#consultar_situacao_lote_rps(hash = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/rnfse/api/abrasf_1_0.rb', line 39

def consultar_situacao_lote_rps(hash = {})
  validate_options(hash)
  xml = xml_builder.build_consultar_situacao_lote_rps_xml(hash)
  response = self.soap_client.call(
    :consultar_situacao_lote_rps,
    soap_action: 'ConsultarSituacaoLoteRps',
    message_tag: 'ConsultarSituacaoLoteRps',
    message: { :'xml!' => "<![CDATA[#{xml}]]>" })
  parse_response(response)
end

#operationsObject



8
9
10
11
12
# File 'lib/rnfse/api/abrasf_1_0.rb', line 8

def operations()
  [ :recepcionar_lote_rps, :consultar_situacao_lote_rps, 
    :consultar_nfse_por_rps, :consultar_nfse, :consultar_lote_rps,
    :cancelar_nfse ]
end

#recepcionar_lote_rps(hash = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rnfse/api/abrasf_1_0.rb', line 14

def recepcionar_lote_rps(hash = {})
  validate_sign_options
  validate_options(hash)
  xml = xml_builder.build_recepcionar_lote_rps_xml(hash) do |inner_xml|
    regex = /<tc:Rps>.*<\/tc:Rps>/
    plain_xml = inner_xml.to_xml(
      save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
    signed_rps = Nokogiri::XML(
                   plain_xml.match(regex)[0]).
                 sign!(
                   certificate: File.read(self.certificate), 
                   key: File.read(self.key)).
                 to_xml(
                   save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).
                 strip
    plain_xml.gsub(regex, signed_rps)
  end
  response = self.soap_client.call(
    :recepcionar_lote_rps,
    soap_action: 'RecepcionarLoteRps',
    message_tag: 'RecepcionarLoteRps',
    message: { :'xml!' => "<![CDATA[#{xml}]]>" })
  parse_response(response)
end