Class: NfePaulistana::Response
- Inherits:
-
Object
- Object
- NfePaulistana::Response
- Defined in:
- lib/nfe-paulistana/response.rb
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.
11 12 13 |
# File 'lib/nfe-paulistana/response.rb', line 11 def initialize( = {}) @options = end |
Instance Method Details
#errors ⇒ Object
31 32 33 34 |
# File 'lib/nfe-paulistana/response.rb', line 31 def errors return unless !success? retorno[:alerta] || retorno[:erro] end |
#nfe_method ⇒ Object
19 20 21 |
# File 'lib/nfe-paulistana/response.rb', line 19 def nfe_method @options[:method] end |
#retorno ⇒ Object
23 24 25 |
# File 'lib/nfe-paulistana/response.rb', line 23 def retorno Nori.new(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }).parse(xml)[("retorno_" + (RETURN_ROOT[@options[:method]] || @options[:method]).to_s).to_sym] end |
#success? ⇒ Boolean
27 28 29 |
# File 'lib/nfe-paulistana/response.rb', line 27 def success? !!retorno[:cabecalho][:sucesso] end |
#xml ⇒ Object
15 16 17 |
# File 'lib/nfe-paulistana/response.rb', line 15 def xml @options[:xml] end |