Module: Twitter::REST::FriendsAndFollowers
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#follow(*args) ⇒ Array<Twitter::User>
(also: #create_friendship)
Allows the authenticating user to follow the specified users, unless they are already followed.
-
#follow!(*args) ⇒ Array<Twitter::User>
(also: #create_friendship!)
Allows the authenticating user to follow the specified users.
- #follower_ids(*args) ⇒ Twitter::Cursor
-
#followers(*args) ⇒ Twitter::Cursor
Returns a cursored collection of user objects for users following the specified user.
- #friend_ids(*args) ⇒ Twitter::Cursor
-
#friends(*args) ⇒ Twitter::Cursor
(also: #following)
Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
-
#friendship(source, target, options = {}) ⇒ Twitter::Relationship
(also: #friendship_show, #relationship)
Returns detailed information about the relationship between two users.
-
#friendship?(source, target, options = {}) ⇒ Boolean
Test for the existence of friendship between two users.
-
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Allows one to enable or disable retweets and device notifications from the specified user.
-
#friendships(*args) ⇒ Array<Twitter::User>
Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided.
-
#friendships_incoming(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user.
-
#friendships_outgoing(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request.
-
#no_retweet_ids(options = {}) ⇒ Array<Integer>
(also: #no_retweets_ids)
Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
-
#unfollow(*args) ⇒ Array<Twitter::User>
(also: #destroy_friendship)
Allows the authenticating user to unfollow the specified users.
Methods included from Utils
Instance Method Details
#follow(*users) ⇒ Array<Twitter::User> #follow(*users, options) ⇒ Array<Twitter::User> Also known as: create_friendship
Allows the authenticating user to follow the specified users, unless they are already followed
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 106 def follow(*args) arguments = Twitter::Arguments.new(args) existing_friends = Thread.new do friend_ids.to_a end new_friends = Thread.new do users(args).collect(&:id) end follow!(new_friends.value - existing_friends.value, arguments.) end |
#follow!(*users) ⇒ Array<Twitter::User> #follow!(*users, options) ⇒ Array<Twitter::User> Also known as: create_friendship!
Allows the authenticating user to follow the specified users
131 132 133 134 135 136 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 131 def follow!(*args) arguments = Twitter::Arguments.new(args) pmap(arguments) do |user| perform_post_with_object("/1.1/friendships/create.json", merge_user(arguments., user), Twitter::User) end.compact end |
#follower_ids(options = {}) ⇒ Twitter::Cursor #follower_ids(user, options = {}) ⇒ Twitter::Cursor
47 48 49 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 47 def follower_ids(*args) cursor_from_response_with_user(:ids, nil, "/1.1/followers/ids.json", args) end |
#followers(options = {}) ⇒ Twitter::Cursor #followers(user, options = {}) ⇒ Twitter::Cursor
Returns a cursored collection of user objects for users following the specified user.
227 228 229 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 227 def followers(*args) cursor_from_response_with_user(:users, Twitter::User, "/1.1/followers/list.json", args) end |
#friend_ids(options = {}) ⇒ Twitter::Cursor #friend_ids(user, options = {}) ⇒ Twitter::Cursor
29 30 31 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 29 def friend_ids(*args) cursor_from_response_with_user(:ids, nil, "/1.1/friends/ids.json", args) end |
#friends(options = {}) ⇒ Twitter::Cursor #friends(user, options = {}) ⇒ Twitter::Cursor Also known as: following
Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
251 252 253 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 251 def friends(*args) cursor_from_response_with_user(:users, Twitter::User, "/1.1/friends/list.json", args) end |
#friendship(source, target, options = {}) ⇒ Twitter::Relationship Also known as: friendship_show, relationship
Returns detailed information about the relationship between two users
182 183 184 185 186 187 188 189 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 182 def friendship(source, target, = {}) = .dup merge_user!(, source, "source") [:source_id] = .delete(:source_user_id) unless [:source_user_id].nil? merge_user!(, target, "target") [:target_id] = .delete(:target_user_id) unless [:target_user_id].nil? perform_get_with_object("/1.1/friendships/show.json", , Twitter::Relationship) end |
#friendship?(source, target, options = {}) ⇒ Boolean
Test for the existence of friendship between two users
203 204 205 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 203 def friendship?(source, target, = {}) friendship(source, target, ).source.following? end |
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Allows one to enable or disable retweets and device notifications from the specified user.
167 168 169 170 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 167 def friendship_update(user, = {}) merge_user!(, user) perform_post_with_object("/1.1/friendships/update.json", , Twitter::Relationship) end |
#friendships(*users) ⇒ Array<Twitter::User> #friendships(*users, options) ⇒ Array<Twitter::User>
Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none.
63 64 65 66 67 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 63 def friendships(*args) arguments = Twitter::Arguments.new(args) merge_users!(arguments., arguments) perform_get_with_objects("/1.1/friendships/lookup.json", arguments., Twitter::User) end |
#friendships_incoming(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
77 78 79 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 77 def friendships_incoming( = {}) perform_get_with_cursor("/1.1/friendships/incoming.json", , :ids) end |
#friendships_outgoing(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
89 90 91 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 89 def friendships_outgoing( = {}) perform_get_with_cursor("/1.1/friendships/outgoing.json", , :ids) end |
#no_retweet_ids(options = {}) ⇒ Array<Integer> Also known as: no_retweets_ids
Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
263 264 265 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 263 def no_retweet_ids( = {}) perform_get("/1.1/friendships/no_retweets/ids.json", ).collect(&:to_i) end |
#unfollow(*users) ⇒ Array<Twitter::User> #unfollow(*users, options) ⇒ Array<Twitter::User> Also known as: destroy_friendship
Allows the authenticating user to unfollow the specified users
151 152 153 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 151 def unfollow(*args) parallel_users_from_response(:post, "/1.1/friendships/destroy.json", args) end |