Sha256: d8683d3fa59f1de34beaf744a1be44b71c11230bf76f5bb0261c86c5426c6c0f

Contents?: true

Size: 1.46 KB

Versions: 35

Compression:

Stored size: 1.46 KB

Contents

require 'databasedotcom/chatter/record'

module Databasedotcom
  module Chatter

    # An item in a Feed.
    class FeedItem < Record

      # Returns a Collection of comments that were posted on this FeedItem instance.
      def comments
        collection = Databasedotcom::Collection.new(self.client, self.raw_hash["comments"]["total"], self.raw_hash["comments"]["nextPageUrl"], nil, self.raw_hash["comments"]["currentPageUrl"])
        collection.concat(self.raw_hash["comments"]["comments"])
      end

      # Returns a Collection of likes for this FeedItem instance.
      def likes
        collection = Databasedotcom::Collection.new(self.client, self.raw_hash["likes"]["total"], self.raw_hash["likes"]["nextPageUrl"], self.raw_hash["likes"]["previousPageUrl"], self.raw_hash["likes"]["currentPageUrl"])
        collection.concat(self.raw_hash["likes"]["likes"])
      end

      # Like this FeedItem.
      def like
        result = self.client.http_post("/services/data/v#{self.client.version}/chatter/feed-items/#{self.id}/likes")
        Like.new(self.client, result.body)
      end

      # Post a Comment on this FeedItem with content _text_.
      def comment(text)
        result = self.client.http_post("/services/data/v#{self.client.version}/chatter/feed-items/#{self.id}/comments", nil, :text => text)
        Comment.new(self.client, result.body)
      end

      protected

      def self.collection_from_response(response)
        response["items"]
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 5 rubygems

Version Path
databasedotcom-1.3.5 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.3.3 lib/databasedotcom/chatter/feed_item.rb
glg-databasedotcom-1.3.2.1 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.3.2 lib/databasedotcom/chatter/feed_item.rb
databasedotcom_emp-1.3.1 lib/databasedotcom/chatter/feed_item.rb
databasedotcom_cloudfuji-1.3.1 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.3.1 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-ejholmes-1.3.5 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-ejholmes-1.3.4 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-ejholmes-1.3.3 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-ejholmes-1.3.2 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.3.0 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.7 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.6 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.5 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.4 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.3 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.2 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.1 lib/databasedotcom/chatter/feed_item.rb
databasedotcom-1.2.0 lib/databasedotcom/chatter/feed_item.rb