Class: NfseGyn::GerarNfse::Response

Inherits:
Response
  • Object
show all
Defined in:
lib/nfse_gyn/gerar_nfse.rb

Direct Known Subclasses

MockGerarNfseResponse

Instance Method Summary collapse

Methods inherited from Response

#class_name, #error_message, #initialize, #output, #successful?

Constructor Details

This class inherits a constructor from NfseGyn::Response

Instance Method Details

#contentObject



25
26
27
# File 'lib/nfse_gyn/gerar_nfse.rb', line 25

def content
  @content ||= output['GerarNfseResposta']
end

#error?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/nfse_gyn/gerar_nfse.rb', line 37

def error?
  !content['ListaNfse'] || content['ListaMensagemRetorno']['MensagemRetorno']['Codigo'] != 'L000'
end

#errorsObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/nfse_gyn/gerar_nfse.rb', line 41

def errors
  if error?
    message = content['ListaMensagemRetorno']['MensagemRetorno']
    message = [message] if message.is_a?(Hash)

    message
  end
rescue StandardError
  content
end

#numberObject



29
30
31
# File 'lib/nfse_gyn/gerar_nfse.rb', line 29

def number
  content['ListaNfse']['CompNfse']['Nfse']['InfNfse']['Numero'] if successful?
end

#verification_codeObject



33
34
35
# File 'lib/nfse_gyn/gerar_nfse.rb', line 33

def verification_code
  content['ListaNfse']['CompNfse']['Nfse']['InfNfse']['CodigoVerificacao'] if successful?
end