Sha256: c64222b370f62a49b7742c228922d3d74118ae0577839f42824689084736708f

Contents?: true

Size: 504 Bytes

Versions: 3

Compression:

Stored size: 504 Bytes

Contents

module Direct::API::V5
  class Response
    attr_reader :body
    attr_reader :headers

    def initialize(body, headers)
      @body = body
      @headers = headers
    end

    def result
      body[:result]
    end

    def request_id
      @request_id ||= headers[:RequestId]
    end

    def units
      @units ||= Units.new(headers[:Units])
    end

    def error?
      body.key?(:error)
    end

    def error
      return unless error?
      @error ||= Error.new(body[:error])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
direct-api-v5-0.1.2 lib/direct/api/v5/response.rb
direct-api-v5-0.1.1 lib/direct/api/v5/response.rb
direct-api-v5-0.1.0 lib/direct/api/v5/response.rb