6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/email-spy/gmail.rb', line 6
def self.fetch invitor_email_address,invitor_email_password
client = GData::Client::Contacts.new
client.clientlogin(invitor_email_address, invitor_email_password)
response = client.get(Contacts_API_URL).to_xml
response.elements.to_a('entry').map do |entry|
title, email = entry.elements['title'].text, nil
entry.elements.each('gd:email') do |e|
email = e.attribute('address').value if e.attribute('primary')
end
Contact.new(title,email) unless email.nil?
end.compact
rescue GData::Client::AuthorizationError => e
raise AuthenticationError
end
|