Class: ContactList::Client
- Inherits:
-
Object
- Object
- ContactList::Client
- Defined in:
- lib/contactlist/client.rb
Defined Under Namespace
Classes: Contact
Class Method Summary collapse
Class Method Details
.fetch(account, password, type) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/contactlist/client.rb', line 16 def self.fetch(account, password, type) response = get_response("account=#{account}&password=#{password}&type=#{type}") contacts = [] data = JSON.parse(response.body) raise ContactListException.new(data['error']) if data['error'] data['contacts'].each do |contact| contacts << Contact.new(contact['username'], contact['email']) end contacts end |