Sha256: 31eee16d8bebdf86ec7a5bdc7d50d80c80a257ba8a671e2784216181afa37cc6

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

module Dacom
  class Response
    attr_reader :code, :message, :raw

    SUCCESS_CODE = "0000".freeze

    def initialize(data = {})
      @code = data.fetch("LGD_RESPCODE") { data[:code] }
      @message = data.fetch("LGD_RESPMSG") { data[:message] }
      @raw = data.fetch("LGD_RESPONSE") { [] }
    end

    def data
      @raw.first
    end

    def successful?
      @code == SUCCESS_CODE
    end

    def to_s
      %Q{<Dacom::Response:#{__id__}, code: "#{@code}", message: "#{@message}", successful: #{successful?}>}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dacom-1.0.1 lib/dacom/response.rb
dacom-1.0.0 lib/dacom/response.rb