Class: Contacts::Provider::Twitter

Inherits:
OAuth
  • Object
show all
Defined in:
lib/contacts/provider/twitter.rb

Instance Method Summary collapse

Methods inherited from OAuth

#connect!, #consumer, inherited

Methods inherited from Base

all, #attributes, #attributes=, #connect!, #connection, #contacts, #contacts_response, #initialize, #parse_attributes, provider_id, #site_url, #valid_attributes, valid_attributes, valid_attributes=

Constructor Details

This class inherits a constructor from Contacts::Provider::Base

Instance Method Details

#followersObject



21
22
23
# File 'lib/contacts/provider/twitter.rb', line 21

def followers
  @followers ||= parse_response!(followers_response)
end

#followers_responseObject



13
14
15
# File 'lib/contacts/provider/twitter.rb', line 13

def followers_response
  @followers_response ||= connection.get("/1/statuses/followers.json")
end

#followingObject



25
26
27
# File 'lib/contacts/provider/twitter.rb', line 25

def following
  @following ||= parse_response!(following_response)
end

#following_responseObject



17
18
19
# File 'lib/contacts/provider/twitter.rb', line 17

def following_response
  @following_response ||= connection.get("/1/statuses/friends.json")
end

#parse_contacts!Object



9
10
11
# File 'lib/contacts/provider/twitter.rb', line 9

def parse_contacts!
  followers & following
end

#parse_response!(response) ⇒ Object



29
30
31
# File 'lib/contacts/provider/twitter.rb', line 29

def parse_response! response
  MultiJson.decode(response.body).map { |contact| Contacts::Contact::Twitter.parse(contact) }.compact
end

#retrieve_contacts!Object



5
6
7
# File 'lib/contacts/provider/twitter.rb', line 5

def retrieve_contacts!
  {:followers_response => followers_response, :following_response => following_response}
end