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
92
93
94
95
96
97
98
99
100
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 92
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
60
61
62
63
64
65
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 60
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
42
43
44
45
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 42
def get_chat(chat_id:, **)
response = graph_connection(**).get("chats/#{chat_id}")
{ result: response.body }
end
|
#list_chat_members(chat_id:) ⇒ Object
76
77
78
79
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 76
def list_chat_members(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
|
# File 'lib/legion/extensions/microsoft_teams/runners/chats.rb', line 25
def list_chats(user_id: 'me', top: 50, **)
params = { '$top' => top }
response = graph_connection(**).get("#{user_path(user_id)}/chats", params)
{ result: response.body }
end
|