Skip to content

Commit

Permalink
adding `me' method for Facebook, Github, Mixi, and Twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
godfat committed Nov 24, 2011
1 parent 573c5ab commit 72abd9c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rest-core/client/facebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def self.missing_token? error
module RestCore::Facebook::Client
include RestCore

def me query={}, opts={}
get('me', query, opts)
end

def access_token
data['access_token'] || data['oauth_token'] if data.kind_of?(Hash)
end
Expand Down
9 changes: 9 additions & 0 deletions lib/rest-core/client/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,14 @@
end
end

module RestCore::Github::Client
include RestCore

def me query={}, opts={}
get('user', query, opts)
end
end

RestCore::Github.send(:include, RestCore::Github::Client)
require 'rest-core/client/github/rails_util' if
Object.const_defined?(:Rails)
4 changes: 4 additions & 0 deletions lib/rest-core/client/mixi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
module RestCore::Mixi::Client
include RestCore

def me query={}, opts={}
get('2/people/@me/@self', query, opts)
end

def access_token
data['access_token'] if data.kind_of?(Hash)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rest-core/client/twitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def self.call env
module RestCore::Twitter::Client
include RestCore

def me query={}, opts={}
get('1/account/verify_credentials.json', query, opts)
end

def tweet status, media=nil, opts={}
if media
post('https://upload.twitter.com/1/statuses/update_with_media.json',
Expand Down

0 comments on commit 72abd9c

Please sign in to comment.