Module: Legion::Extensions::MicrosoftTeams::Runners::Chats
- Extended by:
- Definitions
- Includes:
- Helpers::Lex, Helpers::Client
- Included in:
- Client
- Defined in:
- lib/legion/extensions/microsoft_teams/runners/chats.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#bot_connection, #graph_connection, #oauth_connection, #user_path
Class Method Details
.trigger_words ⇒ Object
13
14
15
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 13
def self.trigger_words
%w[chat chats conversation conversations dm direct]
end
|
Instance Method Details
#add_chat_member(chat_id:, user_id:, roles: ['owner']) ⇒ Object
95
96
97
98
99
100
101
102
103
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 95
def add_chat_member(chat_id:, user_id:, roles: ['owner'], **)
payload = {
'@odata.type' => '#microsoft.graph.aadUserConversationMember',
'roles' => roles,
'user@odata.bind' => "https://graph.microsoft.com/v1.0/users('#{user_id}')"
}
response = graph_connection(**).post("chats/#{chat_id}/members", payload)
{ result: response.body }
end
|
#create_chat(members:, chat_type: 'oneOnOne', topic: nil) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 62
def create_chat(members:, chat_type: 'oneOnOne', topic: nil, **)
payload = { chatType: chat_type, members: members }
payload[:topic] = topic if topic
response = graph_connection(**).post('chats', payload)
{ result: response.body }
end
|
#get_chat(chat_id:) ⇒ Object
43
44
45
46
47
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 43
def get_chat(chat_id:, **)
log.debug("get_chat(chat_id: #{chat_id}, **)")
response = graph_connection(**).get("chats/#{chat_id}")
{ result: response.body }
end
|
#list_chat_members(chat_id:) ⇒ Object
78
79
80
81
82
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 78
def list_chat_members(chat_id:, **)
log.debug "list_chat_members(chat_id: #{chat_id})"
response = graph_connection(**).get("chats/#{chat_id}/members")
{ result: response.body }
end
|
#list_chats(user_id: 'me', top: 50) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 25
def list_chats(user_id: 'me', top: 50, **)
log.debug "list_chats(user_id: #{user_id}, top: #{top})"
params = { '$top' => top }
response = graph_connection(**).get("#{user_path(user_id)}/chats", params)
{ result: response.body }
end
|