Skip to content

Commit

Permalink
Cleaning lib Google
Browse files Browse the repository at this point in the history
  • Loading branch information
joel committed Feb 22, 2012
1 parent b945d2a commit 6346d29
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions lib/oauth/contacts/google.rb
Expand Up @@ -10,7 +10,6 @@ def initialize
super
@callback_url = Settings.oauth.contacts.google.callback_url

# GOOGLE
opts = { key: Settings.oauth.contacts.google.key, secret: Settings.oauth.contacts.google.secret,
extra: { site: 'https://accounts.google.com',
authorize_url: '/o/oauth2/auth',
Expand All @@ -27,7 +26,6 @@ def initialize
def authorize_url
scopes = Settings.oauth.contacts.google.scopes

# http://code.google.com/intl/fr-FR/apis/contacts/docs/3.0/developers_guide.html
extra_params = { scope: scopes.join(' '),
redirect_uri: callback_url,
response_type: 'code',
Expand All @@ -38,30 +36,14 @@ def authorize_url
consumer.auth_code.authorize_url( extra_params )
end

# http://code.google.com/intl/fr-FR/apis/contacts/docs/3.0/developers_guide.html
def contacts
token!

request = "https://www.google.com/m8/feeds/contacts/default/full?alt=json"
@contacts = normalize(access_token.get(request, :parse => :json).parsed)
end

class << self
def slim(contacts) #:nodoc:
_contacts = { 'contacts' => [] }

contacts['feed']['entry'].each do |contact|
emails, nickname = [], nil
nickname = contact['title']['$t']

contact['gd$email'].each do |email|
emails << email['address']
end
_contacts['contacts'] << { :email => emails.first, :emails => emails, :name => nickname }
end
_contacts
end
end

private

def token!
Expand Down

0 comments on commit 6346d29

Please sign in to comment.