Module: Legion::Extensions::MicrosoftTeams::Runners::Messages

Includes:
Helpers::Lex, Helpers::Client
Included in:
Client
Defined in:
lib/legion/extensions/microsoft_teams/runners/messages.rb

Instance Method Summary collapse

Methods included from Helpers::Client

#bot_connection, #graph_connection, #oauth_connection, #user_path

Instance Method Details

#get_chat_message(chat_id:, message_id:) ⇒ Object



18
19
20
21
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 18

def get_chat_message(chat_id:, message_id:, **)
  response = graph_connection(**).get("chats/#{chat_id}/messages/#{message_id}")
  { result: response.body }
end

#list_chat_messages(chat_id:, top: 50) ⇒ Object



12
13
14
15
16
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 12

def list_chat_messages(chat_id:, top: 50, **)
  params = { '$top' => top }
  response = graph_connection(**).get("chats/#{chat_id}/messages", params)
  { result: response.body }
end

#list_message_replies(chat_id:, message_id:, top: 50) ⇒ Object



36
37
38
39
40
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 36

def list_message_replies(chat_id:, message_id:, top: 50, **)
  params = { '$top' => top }
  response = graph_connection(**).get("chats/#{chat_id}/messages/#{message_id}/replies", params)
  { result: response.body }
end

#reply_to_chat_message(chat_id:, message_id:, content:, content_type: 'text') ⇒ Object



30
31
32
33
34
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 30

def reply_to_chat_message(chat_id:, message_id:, content:, content_type: 'text', **)
  payload = { body: { contentType: content_type, content: content } }
  response = graph_connection(**).post("chats/#{chat_id}/messages/#{message_id}/replies", payload)
  { result: response.body }
end

#send_chat_message(chat_id:, content:, content_type: 'text', attachments: []) ⇒ Object



23
24
25
26
27
28
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 23

def send_chat_message(chat_id:, content:, content_type: 'text', attachments: [], **)
  payload = { body: { contentType: content_type, content: content } }
  payload[:attachments] = attachments unless attachments.empty?
  response = graph_connection(**).post("chats/#{chat_id}/messages", payload)
  { result: response.body }
end