Class: Contacts::Provider::Twitter
- Inherits:
-
OAuth
- Object
- Base
- OAuth
- Contacts::Provider::Twitter
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=
Instance Method Details
#followers ⇒ Object
21
22
23
|
# File 'lib/contacts/provider/twitter.rb', line 21
def followers
@followers ||= parse_response!(followers_response)
end
|
#followers_response ⇒ Object
13
14
15
|
# File 'lib/contacts/provider/twitter.rb', line 13
def followers_response
@followers_response ||= connection.get("/1/statuses/followers.json")
end
|
#following ⇒ Object
25
26
27
|
# File 'lib/contacts/provider/twitter.rb', line 25
def following
@following ||= parse_response!(following_response)
end
|
#following_response ⇒ Object
17
18
19
|
# File 'lib/contacts/provider/twitter.rb', line 17
def following_response
@following_response ||= connection.get("/1/statuses/friends.json")
end
|
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::.parse(contact) }.compact
end
|
5
6
7
|
# File 'lib/contacts/provider/twitter.rb', line 5
def retrieve_contacts!
{:followers_response => followers_response, :following_response => following_response}
end
|