Sha256: 7ba3b3d7a536be956d79f0b87193c2e10a256871d6aa9c48b442a50675698b5f

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

module Yammer
  class User < Yammer::Base

    # @!scope class
    def self.create(email)
      result = Yammer.create_user(:email => email)
      return nil unless result.created?
      id = result.headers['Location'].split('/').last.to_i
      new(:id => id)
    end

    # @!scope class
    def self.current
      result = Yammer.current_user
      return nil unless result.success?
      new(result.body)
    end

    attr_accessor_deffered :first_name, :last_name, :full_name, :hire_date, :mugshot, :state,
    :type, :admin, :verified_admin, :expertise, :birth_date, :stats, :show_ask_for_photo, :job_title,
    :web_url, :url, :external_urls, :activated_at, :summary, :department, :previous_companies,
    :follow_general_messages, :schools, :interests, :significant_other, :network_name, :network_id,
    :can_broadcast, :web_preferences, :network_domains, :location, :contact, :kids_names, :guid,
    :name, :mugshot_url, :mugshot_url_template, :settings, :timezone

    def email
      @email ||= begin  
        self.contact[:email_addresses].map do |e|
          e[:address] if e[:type] == 'primary'
        end.first
      end
    end

    def following
      Yammer.users_followed_by(@id)
    end

    def followers
      Yammer.users_following(@id)
    end

    def update!(params)
      Yammer.update_user(@id, params)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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