Class: AddressBook::Yandex
Constant Summary collapse
- LOGIN_URL =
"http://passport.yandex.ru/passport?mode=auth"- ADDRESS_BOOK_URL =
"https://mail.yandex.ru/neo2/handlers/handlers.jsx"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(login, password) ⇒ Yandex
constructor
A new instance of Yandex.
Methods inherited from Base
Constructor Details
#initialize(login, password) ⇒ Yandex
Returns a new instance of Yandex.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/address_book/yandex.rb', line 8 def initialize(login, password) response = session.post LOGIN_URL, { :login => login, :passwd => password } if response.body.index "b-login-error" raise AuthenticationError, "Username or password are incorrect" end response = session.post ADDRESS_BOOK_URL, { :_handlers => "abook-contacts", :all => "yes" } self.contacts = Nokogiri::XML.parse(response.body).css("contact").map do |contact| name = contact.at_css "name" email = contact.at_css "email" [name.values.join(" "), email.content] end end |