Skip to content

Commit

Permalink
adds basic open graph methods
Browse files Browse the repository at this point in the history
  • Loading branch information
astevens committed Dec 11, 2012
1 parent 7c5d7d7 commit 0f3ca23
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/yammer/client.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Client < API
require 'yammer/client/search' require 'yammer/client/search'
require 'yammer/client/suggestions' require 'yammer/client/suggestions'
require 'yammer/client/users' require 'yammer/client/users'
require 'yammer/client/opengraph'


alias :api_endpoint :endpoint alias :api_endpoint :endpoint


Expand All @@ -26,5 +27,6 @@ class Client < API
include Yammer::Client::Search include Yammer::Client::Search
include Yammer::Client::Suggestions include Yammer::Client::Suggestions
include Yammer::Client::Users include Yammer::Client::Users
include Yammer::Client::OG
end end
end end
34 changes: 34 additions & 0 deletions lib/yammer/client/opengraph.rb
Original file line number Original file line Diff line number Diff line change
@@ -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.