class Contacts::Gmail

Constants

CONTACTS_FEED
CONTACTS_SCOPE

Public Instance Methods

contacts() click to toggle source
# File lib/contacts/gmail.rb, line 9
def contacts
  return @contacts if @contacts
end
real_connect() click to toggle source
# File lib/contacts/gmail.rb, line 13
def real_connect
  @client = GData::Client::Contacts.new
  @client.clientlogin(@login, @password, @options[:captcha_token], @options[:captcha_response])
  
  feed = @client.get(CONTACTS_FEED).to_xml
  
  @contacts = feed.elements.to_a('entry').collect do |entry|
    title, email = entry.elements['title'].text, nil
    entry.elements.each('gd:email') do |e|
        email = e.attribute('address').value 
    end
    [title, email] unless email.nil?
  end
  @contacts.compact!
rescue GData::Client::AuthorizationError => e
  raise AuthenticationError, "Username or password are incorrect"
end