1 require 'databasedotcom/chatter/record'
2
3 module Databasedotcom
4 module Chatter
5 # A private message between two or more Users
6 class Message < Record
7
8 # Send a private message with the content _text_ to each user in the _recipients_ list.
9 def self.send_message(client, recipients, text)
10 url = "/services/data/v#{client.version}/chatter/users/me/messages"
11 recipients = recipients.is_a?(Array) ? recipients : [recipients]
12 response = client.http_post(url, nil, :text => text, :recipients => recipients.join(','))
13 Message.new(client, response.body)
14 end
15
16 # Send a reply to the message identified by _in_reply_to_message_id_ with content _text_.
17 def self.reply(client, in_reply_to_message_id, text)
18 url = "/services/data/v#{client.version}/chatter/users/me/messages"
19 response = client.http_post(url, nil, :text => text, :inReplyTo => in_reply_to_message_id)
20 Message.new(client, response.body)
21 end
22
23 # Send a reply to this Message with content _text_.
24 def reply(text)
25 self.class.reply(self.client, self.id, text)
26 end
27 end
28 end
29 en