class Databasedotcom::Chatter::Conversation
A thread of private messages. When calling Conversation.find
or Conversation.all
, you must pass +:user_id => <my_user_id>+ in the parameters
Conversation.all(@client, :user_id => "me") Conversation.find(@client, "conversationId", :user_id => "f80ad89f9d98d89dfd89")
Public Class Methods
Find the Conversation
identified by cid and archive it. Returns the updated Conversation
.
Conversation.archive(@client, "fakeid")
# File lib/databasedotcom/chatter/conversation.rb, line 21 def self.archive(client, cid) url = "/services/data/v#{client.version}/chatter/users/me/conversations/#{cid}" response = client.http_patch(url, nil, :archived => "true") Conversation.new(client, response.body) end
Find the Conversation
identified by cid and mark it as read. Returns the updated Conversation
.
Conversation.mark_read(@client, "fakeid")
# File lib/databasedotcom/chatter/conversation.rb, line 39 def self.mark_read(client, cid) url = "/services/data/v#{client.version}/chatter/users/me/conversations/#{cid}" response = client.http_patch(url, nil, :read => "true") Conversation.new(client, response.body) end
Find the Conversation
identified by cid and mark it as unread. Returns the updated Conversation
.
Conversation.mark_unread(@client, "fakeid")
# File lib/databasedotcom/chatter/conversation.rb, line 48 def self.mark_unread(client, cid) url = "/services/data/v#{client.version}/chatter/users/me/conversations/#{cid}" response = client.http_patch(url, nil, :read => "false") Conversation.new(client, response.body) end
Gets all messages for the Conversation
specified by cid and the User
specified by uid. Returns a Collection
of Message
objects.
# File lib/databasedotcom/chatter/conversation.rb, line 55 def self.messages(client, uid, cid) conversation = self.find(client, cid, :user_id => uid) collection = Databasedotcom::Collection.new(client, nil, conversation.raw_hash["messages"]["nextPageUrl"], conversation.raw_hash["messages"]["previousPageUrl"], conversation.raw_hash["messages"]["currentPageUrl"]) conversation.raw_hash["messages"]["messages"].each do |item| collection << Message.new(client, item) end collection end
Creates a new Conversation
and sets its id
and url
to values obtained from the server response.
# File lib/databasedotcom/chatter/conversation.rb, line 12 def initialize(client, response) super @id ||= @raw_hash["conversationId"] @url ||= @raw_hash["conversationUrl"] end
Find the Conversation
identified by cid and unarchive it. Returns the updated Conversation
.
Conversation.unarchive(@client, "fakeid")
# File lib/databasedotcom/chatter/conversation.rb, line 30 def self.unarchive(client, cid) url = "/services/data/v#{client.version}/chatter/users/me/conversations/#{cid}" response = client.http_patch(url, nil, :archived => "false") Conversation.new(client, response.body) end
Protected Class Methods
# File lib/databasedotcom/chatter/conversation.rb, line 95 def self.search_parameter_name :Q end
Public Instance Methods
Archive this Conversation
.
# File lib/databasedotcom/chatter/conversation.rb, line 65 def archive self.class.archive(self.client, self.id) end
Mark this Conversation
as read.
# File lib/databasedotcom/chatter/conversation.rb, line 75 def mark_read self.class.mark_read(self.client, self.id) end
Mark this Conversation
as unread.
# File lib/databasedotcom/chatter/conversation.rb, line 80 def mark_unread self.class.mark_unread(self.client, self.id) end
Return a Collection
of messages from this Conversation
.
# File lib/databasedotcom/chatter/conversation.rb, line 85 def messages collection = Databasedotcom::Collection.new(client, nil, self.raw_hash["messages"]["nextPageUrl"], self.raw_hash["messages"]["previousPageUrl"], self.raw_hash["messages"]["currentPageUrl"]) self.raw_hash["messages"]["messages"].each do |item| collection << Message.new(client, item) end collection end
Unarchive this Conversation
.
# File lib/databasedotcom/chatter/conversation.rb, line 70 def unarchive self.class.unarchive(self.client, self.id) end