Module: Twitter::REST::FriendsAndFollowers
Overview
Methods for working with friends and followers
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#follow(*args) ⇒ Array<Twitter::User>
(also: #create_friendship)
Follows the specified users unless they are already followed.
-
#follow!(*args) ⇒ Array<Twitter::User>
(also: #create_friendship!)
Follows the specified users.
-
#follower_ids(*args) ⇒ Twitter::Cursor
Returns IDs of users following the specified user.
-
#followers(*args) ⇒ Twitter::Cursor
Returns a collection of users following the specified user.
-
#friend_ids(*args) ⇒ Twitter::Cursor
Returns IDs of users the specified user is following.
-
#friends(*args) ⇒ Twitter::Cursor
(also: #following)
Returns a collection of users the specified user is following.
-
#friendship(source, target, options = {}) ⇒ Twitter::Relationship
(also: #friendship_show, #relationship)
Returns detailed information about the relationship between two users.
-
#friendship?(source, target, options = {}) ⇒ Boolean
Tests for the existence of friendship between two users.
-
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Enables or disables retweets and notifications from the user.
-
#friendships(*args) ⇒ Array<Twitter::User>
Returns the relationship of the authenticating user to the users.
-
#friendships_incoming(options = {}) ⇒ Twitter::Cursor
Returns IDs of users with pending follow requests.
-
#friendships_outgoing(options = {}) ⇒ Twitter::Cursor
Returns IDs of protected users with pending follow requests.
-
#no_retweet_ids(options = {}) ⇒ Array<Integer>
(also: #no_retweets_ids)
Returns IDs of users you don’t want to receive retweets from.
-
#unfollow(*args) ⇒ Array<Twitter::User>
(also: #destroy_friendship)
Unfollows 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
Follows the specified users unless they are already followed
129 130 131 132 133 134 135 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 129 def follow(*args) arguments = Arguments.new(args) existing_friends = friend_ids.to_a new_friends = users(args).collect(&:id) # steep:ignore NoMethod follow!(new_friends - existing_friends, arguments.) end |
#follow!(*users) ⇒ Array<Twitter::User> #follow!(*users, options) ⇒ Array<Twitter::User> Also known as: create_friendship!
Follows the specified users
157 158 159 160 161 162 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 157 def follow!(*args) arguments = Arguments.new(args) pmap(arguments) do |user| perform_post_with_object("/1.1/friendships/create.json", merge_user(arguments., user), User) # steep:ignore ArgumentTypeMismatch end end |
#follower_ids(options = {}) ⇒ Twitter::Cursor #follower_ids(user, options = {}) ⇒ Twitter::Cursor
Returns IDs of users following the specified user
58 59 60 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 58 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 collection of users following the specified user
280 281 282 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 280 def followers(*args) cursor_from_response_with_user(:users, User, "/1.1/followers/list.json", args) end |
#friend_ids(options = {}) ⇒ Twitter::Cursor #friend_ids(user, options = {}) ⇒ Twitter::Cursor
Returns IDs of users the specified user is following
35 36 37 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 35 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 collection of users the specified user is following
307 308 309 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 307 def friends(*args) cursor_from_response_with_user(:users, 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
223 224 225 226 227 228 229 230 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 223 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", , Relationship) end |
#friendship?(source, target, options = {}) ⇒ Boolean
Tests for the existence of friendship between two users
253 254 255 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 253 def friendship?(source, target, = {}) friendship(source, target, ).source.following? end |
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Enables or disables retweets and notifications from the user
205 206 207 208 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 205 def friendship_update(user, = {}) merge_user!(, user) perform_post_with_object("/1.1/friendships/update.json", , Relationship) end |
#friendships(*users) ⇒ Array<Twitter::User> #friendships(*users, options) ⇒ Array<Twitter::User>
Returns the relationship of the authenticating user to the users
77 78 79 80 81 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 77 def friendships(*args) arguments = Arguments.new(args) merge_users!(arguments., arguments) perform_get_with_objects("/1.1/friendships/lookup.json", arguments., User) end |
#friendships_incoming(options = {}) ⇒ Twitter::Cursor
Returns IDs of users with pending follow requests
94 95 96 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 94 def friendships_incoming( = {}) perform_get_with_cursor("/1.1/friendships/incoming.json", , :ids) end |
#friendships_outgoing(options = {}) ⇒ Twitter::Cursor
Returns IDs of protected users with pending follow requests
109 110 111 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 109 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 IDs of users you don’t want to receive retweets from
326 327 328 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 326 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
Unfollows the specified users
183 184 185 |
# File 'lib/twitter/rest/friends_and_followers.rb', line 183 def unfollow(*args) parallel_users_from_response(:post, "/1.1/friendships/destroy.json", args) end |