class Databasedotcom::Chatter::User
Defines a User
in your org.
Public Class Methods
Returns a Collection
of conversations that belong to the User
identified by subject_id.
# File lib/databasedotcom/chatter/user.rb, line 72 def self.conversations(client, subject_id) Conversation.all(client, :user_id => subject_id) end
Deletes the status of User
identified by subject_id.
# File lib/databasedotcom/chatter/user.rb, line 61 def self.delete_status(client, subject_id="me") client.http_delete "/services/data/v#{client.version}/chatter/users/#{subject_id}/status" end
Creates and returns a new Subscription
object that represents the User
identified by subject_id following the resource identified by resource_id.
# File lib/databasedotcom/chatter/user.rb, line 66 def self.follow(client, subject_id, resource_id) response = client.http_post("/services/data/v#{client.version}/chatter/users/#{subject_id}/following", nil, :subjectId => resource_id) Subscription.new(client, response.body) end
Returns a Collection
of Subscription
objects that represents all followers of the User
identified by subject_id.
# File lib/databasedotcom/chatter/user.rb, line 11 def self.followers(client, subject_id="me") url = "/services/data/v#{client.version}/chatter/users/#{subject_id}/followers" result = client.http_get(url) response = JSON.parse(result.body) collection = Databasedotcom::Collection.new(client, response["total"], response["nextPageUrl"], response["previousPageUrl"], response["currentPageUrl"]) response["followers"].each do |subscription| collection << Subscription.new(client, subscription) end collection end
Returns a Collection
of Subscription
objects that represent all entities that the User
identified by subject_id is following.
# File lib/databasedotcom/chatter/user.rb, line 23 def self.following(client, subject_id="me") url = "/services/data/v#{client.version}/chatter/users/#{subject_id}/following" result = client.http_get(url) response = JSON.parse(result.body) collection = Databasedotcom::Collection.new(client, response["total"], response["nextPageUrl"], response["previousPageUrl"], response["currentPageUrl"]) response["following"].each do |subscription| collection << Subscription.new(client, subscription) end collection end
Returns a Collection
of Group
objects that represent all the groups that the User
identified by subject_id is a part of.
# File lib/databasedotcom/chatter/user.rb, line 35 def self.groups(client, subject_id="me") url = "/services/data/v#{client.version}/chatter/users/#{subject_id}/groups" result = client.http_get(url) response = JSON.parse(result.body) collection = Databasedotcom::Collection.new(client, response["total"], response["nextPageUrl"], response["previousPageUrl"], response["currentPageUrl"]) response["groups"].each do |group| collection << Group.new(client, group) end collection end
Returns a Collection
of private messages that belong to the User
identified by subject_id.
# File lib/databasedotcom/chatter/user.rb, line 77 def self.messages(client, subject_id) Message.all(client, :user_id => subject_id) end
Posts a status update as the User
identified by subject_id with content text.
# File lib/databasedotcom/chatter/user.rb, line 54 def self.post_status(client, subject_id, text) url = "/services/data/v#{client.version}/chatter/users/#{subject_id}/status" result = client.http_post(url, nil, :text => text) JSON.parse(result.body) end
Returns the current status of the User
identified by subject_id.
# File lib/databasedotcom/chatter/user.rb, line 47 def self.status(client, subject_id="me") url = "/services/data/v#{client.version}/chatter/users/#{subject_id}/status" result = client.http_get(url) JSON.parse(result.body) end
Public Instance Methods
Get a Collection
of Conversation
objects that represents the conversations for this User
. Returns cached data if it has been called before.
# File lib/databasedotcom/chatter/user.rb, line 138 def conversations @conversations ||= conversations! end
Get a Collection
of Conversation
objects that represents the conversations for this User
. Always makes a call to the server.
# File lib/databasedotcom/chatter/user.rb, line 133 def conversations! self.class.conversations(self.client, self.id) end
Deletes the current status of this User
. Returns the deleted status.
# File lib/databasedotcom/chatter/user.rb, line 112 def delete_status self.class.delete_status(self.client, self.id) status end
Creates a new Subscription
that represents this User
following the resource with id record_id.
# File lib/databasedotcom/chatter/user.rb, line 128 def follow(record_id) self.class.follow(self.client, self.id, record_id) end
Get a Collection
of Subscription
objects for this User
. Returns cached data if it has been called before.
# File lib/databasedotcom/chatter/user.rb, line 87 def followers @followers ||= followers! end
Get a Collection
of Subscription
objects for this User
. Always makes a call to the server.
# File lib/databasedotcom/chatter/user.rb, line 82 def followers! self.class.followers(self.client, self.id) end
Get a Collection
of Subscription
objects that represents all resources that this User
is following. Returns cached data if it has been called before.
# File lib/databasedotcom/chatter/user.rb, line 97 def following @following ||= following! end
Get a Collection
of Subscription
objects that represents all resources that this User
is following. Always makes a call to the server.
# File lib/databasedotcom/chatter/user.rb, line 92 def following! self.class.following(self.client, self.id) end
Get a Collection
of Group
objects that represents all groups that this User
is in. Returns cached data if it has been called before.
# File lib/databasedotcom/chatter/user.rb, line 123 def groups @groups ||= groups! end
Get a Collection
of Group
objects that represents all groups that this User
is in. Always makes a call to the server.
# File lib/databasedotcom/chatter/user.rb, line 118 def groups! self.class.groups(self.client, self.id) end
Get a Collection
of Message
objects that represents the messages for this User
. Returns cached data if it has been called before.
# File lib/databasedotcom/chatter/user.rb, line 148 def messages @messages ||= messages! end
Get a Collection
of Message
objects that represents the messages for this User
. Always makes a call to the server.
# File lib/databasedotcom/chatter/user.rb, line 143 def messages! self.class.messages(self.client, self.id) end
Posts a new status with content text for this User
.
# File lib/databasedotcom/chatter/user.rb, line 107 def post_status(text) self.class.post_status(self.client, self.id, text) end
Returns this current status of this User
.
# File lib/databasedotcom/chatter/user.rb, line 102 def status self.raw_hash["currentStatus"] end