Class: RocketChat::Messages::Chat
- Inherits:
-
Object
- Object
- RocketChat::Messages::Chat
- Includes:
- RoomSupport
- Defined in:
- lib/rocket_chat/messages/chat.rb
Overview
Rocket.Chat Chat messages
Instance Method Summary collapse
-
#delete(room_id: nil, name: nil, msg_id: nil, as_user: nil) ⇒ Boolean
chat.delete REST API.
-
#get_message(msg_id: nil) ⇒ RocketChat::Message
chat.getMessage REST API.
-
#initialize(session) ⇒ Chat
constructor
A new instance of Chat.
-
#post_message(room_id: nil, name: nil, channel: nil, **params) ⇒ RocketChat::Message
chat.postMessage REST API.
-
#update(room_id: nil, name: nil, msg_id: nil, text: nil) ⇒ RocketChat::Message
chat.update REST API.
Methods included from RoomSupport
#room_params, #room_query_params
Constructor Details
#initialize(session) ⇒ Chat
Returns a new instance of Chat.
14 15 16 |
# File 'lib/rocket_chat/messages/chat.rb', line 14 def initialize(session) @session = session end |
Instance Method Details
#delete(room_id: nil, name: nil, msg_id: nil, as_user: nil) ⇒ Boolean
chat.delete REST API
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rocket_chat/messages/chat.rb', line 27 def delete(room_id: nil, name: nil, msg_id: nil, as_user: nil) session.request_json( '/api/v1/chat.delete', method: :post, body: room_params(room_id, name).tap do |h| h[:msgId] = msg_id h[:asUser] = as_user unless as_user.nil? end )['success'] end |
#get_message(msg_id: nil) ⇒ RocketChat::Message
chat.getMessage REST API
45 46 47 48 49 50 51 |
# File 'lib/rocket_chat/messages/chat.rb', line 45 def (msg_id: nil) response = session.request_json( '/api/v1/chat.getMessage', body: { msgId: msg_id } ) RocketChat::Message.new response['message'] if response['success'] end |
#post_message(room_id: nil, name: nil, channel: nil, **params) ⇒ RocketChat::Message
chat.postMessage REST API
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rocket_chat/messages/chat.rb', line 62 def (room_id: nil, name: nil, channel: nil, **params) response = session.request_json( '/api/v1/chat.postMessage', method: :post, body: room_params(room_id, name) .merge(channel: channel) .merge(Util.slice_hash(params, :text, :alias, :tmid, :emoji, :avatar, :attachments)) ) RocketChat::Message.new response['message'] if response['success'] end |
#update(room_id: nil, name: nil, msg_id: nil, text: nil) ⇒ RocketChat::Message
chat.update REST API
82 83 84 85 86 87 88 89 |
# File 'lib/rocket_chat/messages/chat.rb', line 82 def update(room_id: nil, name: nil, msg_id: nil, text: nil) response = session.request_json( '/api/v1/chat.update', method: :post, body: room_params(room_id, name).merge(msgId: msg_id, text: text) ) RocketChat::Message.new response['message'] if response['success'] end |