Class: Yammer::Client
- Inherits:
-
Object
- Object
- Yammer::Client
- Defined in:
- lib/yammer/client.rb
Instance Method Summary collapse
- #current_user ⇒ Object (also: #me)
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#message(action, params) ⇒ Object
POST or DELETE a message.
-
#messages(action = :all, params = {}) ⇒ Object
TODO: modularize message and user handling.
- #user(id) ⇒ Object
- #users(params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/yammer/client.rb', line 3 def initialize(={}) .assert_has_keys(:consumer, :access) unless .has_key?(:config) yammer_url = .delete(:yammer_host) || "https://www.yammer.com" @api_path = "/api/v1/" if [:config] config = YAML.load(open([:config])) [:consumer] = config['consumer'].symbolize_keys [:access] = config['access'].symbolize_keys end consumer = OAuth::Consumer.new([:consumer][:key], [:consumer][:secret], :site => yammer_url) consumer.http.set_debug_output($stderr) if [:verbose] == true @access_token = OAuth::AccessToken.new(consumer, [:access][:token], [:access][:secret]) end |
Instance Method Details
#current_user ⇒ Object Also known as: me
51 52 53 54 |
# File 'lib/yammer/client.rb', line 51 def current_user u = JSON.parse(yammer_request(:get, {:resource => :users, :action => :current}).body) Yammer::User.new(mash(u), self) end |
#message(action, params) ⇒ Object
POST or DELETE a message
36 37 38 39 |
# File 'lib/yammer/client.rb', line 36 def (action, params) params.merge!(:resource => :messages) yammer_request(action, params) end |
#messages(action = :all, params = {}) ⇒ Object
TODO: modularize message and user handling
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yammer/client.rb', line 22 def (action = :all, params = {}) params.merge!(:resource => :messages) params.merge!(:action => action) unless action == :all parsed_response = JSON.parse(yammer_request(:get, params).body) older_available = parsed_response['meta']['older_available'] ml = parsed_response['messages'].map do |m| mash(m) end Yammer::MessageList.new(ml, older_available, self) end |