Module: Easemob::Chatlog

Included in:
Easemob
Defined in:
lib/easemob/chatlog.rb

Instance Method Summary collapse

Instance Method Details

#chatmessages(after: nil, before: nil, limit: 10, cursor: nil) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
# File 'lib/easemob/chatlog.rb', line 3

def chatmessages(after: nil, before: nil, limit: 10, cursor: nil)
  raise ArgumentError, 'Either give after or before, not both when call chatmessages' if after && before
  params = { limit: limit }
  params[:cursor] = cursor unless cursor.nil?
  params[:ql] = "select * where timestamp>#{after.to_i}" unless after.nil?
  params[:ql] = "select * where timestamp<#{before.to_i}" unless before.nil?
  request :get, 'chatmessages', params: params
end