Sha256: fe7071a707c9448f25474c005ebdfc595d7712541ff3bef58a45d02bab7f33a5

Contents?: true

Size: 714 Bytes

Versions: 2

Compression:

Stored size: 714 Bytes

Contents

module NfePaulistana
  class Response
    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,
    }
    def initialize(options = {})
      @options = options
    end

    def xml
      @options[:xml]
    end

    def retorno
      Nori.parse(xml)[("retorno_" + (RETURN_ROOT[@options[:method]] || @options[:method]).to_s).to_sym]
    end

    def success?
      !!retorno[:cabecalho][:sucesso]
    end

    def errors
      return unless !success?
      retorno[:alerta] || retorno[:erro]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nfe-paulistana-1.0.1 lib/nfe-paulistana/response.rb
nfe-paulistana-1.0.0 lib/nfe-paulistana/response.rb