Class: Databasedotcom::Chatter::Message

Inherits:
Record
  • Object
show all
Defined in:
lib/databasedotcom/chatter/message.rb

Overview

A private message between two or more Users

Instance Attribute Summary

Attributes inherited from Record

#client, #id, #name, #raw_hash, #type, #url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

all, delete, #delete, find, #initialize, #parent, #reload, resource_name, search, #user

Constructor Details

This class inherits a constructor from Databasedotcom::Chatter::Record

Class Method Details

.reply(client, in_reply_to_message_id, text) ⇒ Object

Send a reply to the message identified by in_reply_to_message_id with content text.



17
18
19
20
21
# File 'lib/databasedotcom/chatter/message.rb', line 17

def self.reply(client, in_reply_to_message_id, text)
  url = "/services/data/v#{client.version}/chatter/users/me/messages"
  response = client.http_post(url, nil, :text => text, :inReplyTo => in_reply_to_message_id)
  Message.new(client, response.body)
end

.send_message(client, recipients, text) ⇒ Object

Send a private message with the content text to each user in the recipients list.



9
10
11
12
13
14
# File 'lib/databasedotcom/chatter/message.rb', line 9

def self.send_message(client, recipients, text)
  url = "/services/data/v#{client.version}/chatter/users/me/messages"
  recipients = recipients.is_a?(Array) ? recipients : [recipients]
  response = client.http_post(url, nil, :text => text, :recipients => recipients.join(','))
  Message.new(client, response.body)
end

Instance Method Details

#reply(text) ⇒ Object

Send a reply to this Message with content text.



24
25
26
# File 'lib/databasedotcom/chatter/message.rb', line 24

def reply(text)
  self.class.reply(self.client, self.id, text)
end