Class: AddressBook::MailRu

Inherits:
Base
  • Object
show all
Defined in:
lib/address_book/mailru.rb

Constant Summary collapse

LOGIN_URL =
"https://auth.mail.ru/cgi-bin/auth"
ADDRESS_BOOK_URL =
"http://e.mail.ru/cgi-bin/abexport/addressbook.csv"

Instance Attribute Summary

Attributes inherited from Base

#contacts

Instance Method Summary collapse

Methods inherited from Base

#session

Constructor Details

#initialize(login, password) ⇒ MailRu

Returns a new instance of MailRu.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/address_book/mailru.rb', line 10

def initialize(, password)
  response = session.post LOGIN_URL, { :Login => , :Domain => AddressBook.extract_domain(), :Password => password }

  if response.body.index "fail=1"
    raise AuthenticationError, "Username or password are incorrect"
  end

  response = session.post ADDRESS_BOOK_URL, { :confirm => 1, :abtype => 6 }

  self.contacts = CSV.parse(response.body).drop(1).map do |row|
    [row[0], row[4]]
  end
end