Sha256: 9938d0dae799590ddc7812ea7f65e2600cc1fdc2127a38a07203fac487d39fcf

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module Yammer
  class Thread < Yammer::Base

    attr_accessor_deffered :participants, :web_url, :references, :thread_starter_id,
    :type, :privacy, :has_attachments, :attachments_meta, :topics, :url, :attachments,
    :direct_message, :participants_count, :stats

    def first_reply_id
      stats[:first_reply_id]
    end

    def first_reply
      @first_reply ||= first_reply_id ? Yammer::Message.new(:id => first_reply_id) : nil
    end

    def latest_reply_id
      stats[:latest_reply_id]
    end

    def last_reply
      @latest_reply ||= latest_reply_id ? Yammer::Message.new(:id => latest_reply_id) : nil
    end

    def people
      @people ||= begin
        @participants.map do |part|
          next unless part[:type] == 'user'
          Yammer::User.new(:id => part[:id])
        end
      end
      @people
    end

    def messages
      @messages = {}
      result = api_handler.messages_in_thread(self.id)
      msgs = result.body[:messages].each do |message|
        msg = Yammer::Message.new(message)
        @messages["#{msg.id}"] = msg
      end
      @messages
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yammer-client-0.1.8 lib/yammer/thread.rb
yammer-client-0.1.7 lib/yammer/thread.rb
yammer-client-0.1.6 lib/yammer/thread.rb
yammer-client-0.1.5 lib/yammer/thread.rb
yammer-client-0.1.4 lib/yammer/thread.rb
yammer-client-0.1.3 lib/yammer/thread.rb