Permalink
Browse files

adds basic open graph methods

  • Loading branch information...
1 parent 7c5d7d7 commit 0f3ca23a8aa25737cc677ca409520b13edb300f4 @astevens astevens committed Dec 11, 2012
Showing with 36 additions and 0 deletions.
  1. +2 −0 lib/yammer/client.rb
  2. +34 −0 lib/yammer/client/opengraph.rb
View
@@ -15,6 +15,7 @@ class Client < API
require 'yammer/client/search'
require 'yammer/client/suggestions'
require 'yammer/client/users'
+ require 'yammer/client/opengraph'
alias :api_endpoint :endpoint
@@ -26,5 +27,6 @@ class Client < API
include Yammer::Client::Search
include Yammer::Client::Suggestions
include Yammer::Client::Users
+ include Yammer::Client::OG
end
end
@@ -0,0 +1,34 @@
+module Yammer
+ class Client
+ # Defines methods related to manipulating opengraph objects
+ module OG
+ def og_activity(og_json)
+ post('activity', og_json)
+ end
+
+ def og_payload(activity, options = {})
+ raise(ArgumentError.new, "You need to call acts_as_opengraph on your #{obj.class} model") unless activity.respond_to?(:opengraph_data)
+ options = {action: "update", notify_users: [], private: true, message: ""}.merge(options)
+ {
+ activity: {
+ actor: {
+ name: options[:user].name,
+ email: options[:user].email
+ },
+ action: options[:action],
+ object: {
+ url: options[:url] || activity.opengraph_url,
+ type: 'page',
+ title: activity.opengraph_title,
+ image: activity.opengraph_image
+ }
+ },
+ private: options[:private],
+ message: options[:message],
+ users: []
+ }
+ end
+
+ end
+ end
+end

0 comments on commit 0f3ca23

Please sign in to comment.