Module: Easemob::Chatrooms

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

Instance Method Summary collapse

Instance Method Details

#chatroom_add_users(chatroom_id, usernames:) ⇒ Object



41
42
43
# File 'lib/easemob/chatrooms.rb', line 41

def chatroom_add_users(chatroom_id, usernames:)
  request :post, "chatrooms/#{chatroom_id}/users", json: { usernames: [*usernames] }
end

#chatroom_remove_users(chatroom_id, usernames:) ⇒ Object



45
46
47
# File 'lib/easemob/chatrooms.rb', line 45

def chatroom_remove_users(chatroom_id, usernames:)
  request :delete, "chatrooms/#{chatroom_id}/users/#{[*usernames].join(',')}"
end

#create_chatroom(chatroom_name, description, owner, maxusers: 200, members: nil) ⇒ Object



3
4
5
6
7
# File 'lib/easemob/chatrooms.rb', line 3

def create_chatroom(chatroom_name, description, owner, maxusers: 200, members: nil)
  jd = { name: chatroom_name, description: description, owner: owner, maxusers: maxusers }
  jd[:members] = members unless members.nil?
  request :post, 'chatrooms', json: jd
end

#delete_chatroom(chatroom_id) ⇒ Object



21
22
23
# File 'lib/easemob/chatrooms.rb', line 21

def delete_chatroom(chatroom_id)
  request :delete, "chatrooms/#{chatroom_id}"
end

#get_chatroom(chatroom_id) ⇒ Object



9
10
11
# File 'lib/easemob/chatrooms.rb', line 9

def get_chatroom(chatroom_id)
  request :get, "chatrooms/#{chatroom_id}"
end

#modify_chatroom(chatroom_id, chatroom_name: nil, description: nil, maxusers: nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/easemob/chatrooms.rb', line 25

def modify_chatroom(chatroom_id, chatroom_name: nil, description: nil, maxusers: nil)
  jd = {}
  jd[:name] = chatroom_name unless chatroom_name.nil?
  jd[:description] = description unless description.nil?
  jd[:maxusers] = maxusers unless maxusers.nil?
  request :put, "chatrooms/#{chatroom_id}", json: jd
end

#query_chatroomsObject



13
14
15
# File 'lib/easemob/chatrooms.rb', line 13

def query_chatrooms
  request :get, 'chatrooms'
end

#user_join_chatroom(chatroom_id, username:) ⇒ Object



33
34
35
# File 'lib/easemob/chatrooms.rb', line 33

def user_join_chatroom(chatroom_id, username:)
  request :post, "chatrooms/#{chatroom_id}/users/#{username}"
end

#user_joined_chatrooms(username) ⇒ Object



17
18
19
# File 'lib/easemob/chatrooms.rb', line 17

def user_joined_chatrooms(username)
  request :get, "users/#{username}/joined_chatrooms"
end

#user_leave_chatroom(chatroom_id, username:) ⇒ Object



37
38
39
# File 'lib/easemob/chatrooms.rb', line 37

def user_leave_chatroom(chatroom_id, username:)
  request :delete, "chatrooms/#{chatroom_id}/users/#{username}"
end