Class: NfsePrefeituraSp::Response
- Inherits:
-
Object
- Object
- NfsePrefeituraSp::Response
- Defined in:
- lib/nfse_prefeitura_sp/response.rb
Overview
Based on https://github.com/iugu/nfe-paulistana in order to keep as consistent as possible.
Constant Summary collapse
- RETURN_ROOT =
{ teste_envio_lote_rps: :envio_lote_rps, consulta_n_fe: :consulta, consulta_n_fe_emitidas: :consulta, consulta_n_fe_recebidas: :consulta, consulta_lote: :consulta, consulta_informacoes_lote: :informacoes_lote, }
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(options = {}) ⇒ Response
constructor
A new instance of Response.
- #nfe_method ⇒ Object
- #retorno ⇒ Object
- #success? ⇒ Boolean
- #xml ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Response
Returns a new instance of Response.
13 14 15 |
# File 'lib/nfse_prefeitura_sp/response.rb', line 13 def initialize( = {}) @options = end |
Instance Method Details
#errors ⇒ Object
33 34 35 36 |
# File 'lib/nfse_prefeitura_sp/response.rb', line 33 def errors return if success? retorno[:alerta] || retorno[:erro] end |
#nfe_method ⇒ Object
21 22 23 |
# File 'lib/nfse_prefeitura_sp/response.rb', line 21 def nfe_method @options[:method] end |
#retorno ⇒ Object
25 26 27 |
# File 'lib/nfse_prefeitura_sp/response.rb', line 25 def retorno Hash.from_xml(Nokogiri::XML(xml).to_s).deep_transform_keys { |key| key.to_s.underscore.to_sym }[("retorno_" + (RETURN_ROOT[@options[:method]] || @options[:method]).to_s).to_sym] end |
#success? ⇒ Boolean
29 30 31 |
# File 'lib/nfse_prefeitura_sp/response.rb', line 29 def success? retorno[:cabecalho][:sucesso] == 'true' end |
#xml ⇒ Object
17 18 19 |
# File 'lib/nfse_prefeitura_sp/response.rb', line 17 def xml @options[:xml] end |