Sha256: 0871e02dbfcf88be5bc8d1985f870bc9ae5b433f2a08259b0e1b9ae854b757b5

Contents?: true

Size: 1.08 KB

Versions: 2

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 = Yammer.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

2 entries across 2 versions & 1 rubygems

Version Path
yammer-client-0.1.2 lib/yammer/thread.rb
yammer-client-0.1.1 lib/yammer/thread.rb