Sha256: 93ae95cadc9a22f1e12cb8eaf2a43548af98be336b690106cbb1877487f1505f

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

module NfseGyn
  class Response
    def initialize(payload)
      @payload = payload
    end

    def class_name
      self.class.to_s.split('::')[1]
    end

    def successful?
      !error?
    end

    def error?
      content['ListaMensagemRetorno'].present?
    end

    def error_message
      if error? && content['ListaMensagemRetorno']['MensagemRetorno'].present?
        content['ListaMensagemRetorno']['MensagemRetorno']['Correcao'].try(:strip)
      end
    end

    def output
      response = @payload.body.try(:values).try(:first)
      @output ||= Nori.new.parse(response.try(:values).try(:first) || response)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nfse_gyn-0.1.1 lib/nfse_gyn/response.rb