class Databasedotcom::Chatter::User

Defines a User in your org.

Public Class Methods

conversations(client, subject_id) click to toggle source

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
delete_status(client, subject_id="me") click to toggle source

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
follow(client, subject_id, resource_id) click to toggle source

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
followers(client, subject_id="me") click to toggle source

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
following(client, subject_id="me") click to toggle source

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
groups(client, subject_id="me") click to toggle source

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
messages(client, subject_id) click to toggle source

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
post_status(client, subject_id, text) click to toggle source

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
status(client, subject_id="me") click to toggle source

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

conversations() click to toggle source

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
conversations!() click to toggle source

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
delete_status() click to toggle source

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
follow(record_id) click to toggle source

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
followers() click to toggle source

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
followers!() click to toggle source

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
following() click to toggle source

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
following!() click to toggle source

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
groups() click to toggle source

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
groups!() click to toggle source

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
messages() click to toggle source

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
messages!() click to toggle source

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
post_status(text) click to toggle source

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
status() click to toggle source

Returns this current status of this User.

# File lib/databasedotcom/chatter/user.rb, line 102
def status
  self.raw_hash["currentStatus"]
end