Class: Nfcom::Parsers::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/nfcom/parsers/status.rb

Instance Attribute Summary

Attributes inherited from Base

#document

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Nfcom::Parsers::Base

Instance Method Details

#parseObject

Raises:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nfcom/parsers/status.rb', line 6

def parse
  ret = find('//nfcom:retConsStatServNFCom')
  raise Errors::SefazError, 'Resposta de status inválida' unless ret

  codigo = xpath(ret, './/nfcom:cStat')
  motivo = xpath(ret, './/nfcom:xMotivo')

  {
    online: codigo.to_s == '107',
    codigo: codigo,
    motivo: motivo,
    tempo_medio: xpath(ret, './/nfcom:tMed'),
    data_hora: xpath(ret, './/nfcom:dhRecbto')
  }
end