Module: Twitter::Client::FriendsAndFollowers
- Included in:
- Twitter::Client
- Defined in:
- lib/twitter/client/friends_and_followers.rb
Overview
Defines methods related to friends and followers
Instance Method Summary collapse
-
#accept(user, options = {}) ⇒ Twitter::User
Allows the authenticating user to accept the specified user's follow request.
-
#deny(user, options = {}) ⇒ Twitter::User
Allows the authenticating user to deny the specified user's follow request.
-
#follow(user, options = {}) ⇒ Twitter::User
(also: #friendship_create)
Allows the authenticating user to follow the specified user.
- #follower_ids(*args) ⇒ Object
- #friend_ids(*args) ⇒ Object
-
#friendship(source, target, options = {}) ⇒ Twitter::Relationship
(also: #friendship_show, #relationship)
Returns detailed information about the relationship between two users.
-
#friendship?(user_a, user_b, 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(*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.
-
#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>
Returns an array of user_ids that the currently authenticated user does not want to see retweets from.
-
#unfollow(user, options = {}) ⇒ Twitter::User
(also: #friendship_destroy)
Allows the authenticating user to unfollow the specified user.
Instance Method Details
#accept(user, options = {}) ⇒ Twitter::User
Undocumented
Allows the authenticating user to accept the specified user's follow request
268 269 270 271 272 |
# File 'lib/twitter/client/friends_and_followers.rb', line 268 def accept(user, ={}) .merge_user!(user) user = post("/1/friendships/accept.json", ) Twitter::User.new(user) end |
#deny(user, options = {}) ⇒ Twitter::User
Undocumented
Allows the authenticating user to deny the specified user's follow request
285 286 287 288 289 |
# File 'lib/twitter/client/friends_and_followers.rb', line 285 def deny(user, ={}) .merge_user!(user) user = post("/1/friendships/deny.json", ) Twitter::User.new(user) end |
#follow(user, options = {}) ⇒ Twitter::User Also known as: friendship_create
Allows the authenticating user to follow the specified user
167 168 169 170 171 172 173 174 |
# File 'lib/twitter/client/friends_and_followers.rb', line 167 def follow(user, ={}) .merge_user!(user) # Twitter always turns on notifications if the "follow" option is present, even if it's set to false # so only send follow if it's true .merge!(:follow => true) if .delete(:follow) user = post("/1/friendships/create.json", ) Twitter::User.new(user) end |
#follower_ids(options = {}) ⇒ Twitter::Cursor #follower_ids(user, options = {}) ⇒ Twitter::Cursor
34 35 36 37 38 39 40 41 |
# File 'lib/twitter/client/friends_and_followers.rb', line 34 def follower_ids(*args) = {:cursor => -1} .merge!(args.last.is_a?(Hash) ? args.pop : {}) user = args.first .merge_user!(user) cursor = get("/1/followers/ids.json", ) Twitter::Cursor.new(cursor, 'ids') end |
#friend_ids(options = {}) ⇒ Twitter::Cursor #friend_ids(user, options = {}) ⇒ Twitter::Cursor
66 67 68 69 70 71 72 73 |
# File 'lib/twitter/client/friends_and_followers.rb', line 66 def friend_ids(*args) = {:cursor => -1} .merge!(args.last.is_a?(Hash) ? args.pop : {}) user = args.first .merge_user!(user) cursor = get("/1/friends/ids.json", ) Twitter::Cursor.new(cursor, 'ids') end |
#friendship(source, target, options = {}) ⇒ Twitter::Relationship Also known as: friendship_show, relationship
Returns detailed information about the relationship between two users
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/twitter/client/friends_and_followers.rb', line 135 def friendship(source, target, ={}) case source when Integer [:source_id] = source when String [:source_screen_name] = source end case target when Integer [:target_id] = target when String [:target_screen_name] = target end relationship = get("/1/friendships/show.json", )['relationship'] Twitter::Relationship.new(relationship) end |
#friendship?(user_a, user_b, options = {}) ⇒ Boolean
Consider using #friendship instead of this method.
Test for the existence of friendship between two users
87 88 89 |
# File 'lib/twitter/client/friends_and_followers.rb', line 87 def friendship?(user_a, user_b, ={}) get("/1/friendships/exists.json", .merge(:user_a => user_a, :user_b => user_b)) end |
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Allows one to enable or disable retweets and device notifications from the specified user.
235 236 237 238 239 |
# File 'lib/twitter/client/friends_and_followers.rb', line 235 def friendship_update(user, ={}) .merge_user!(user) relationship = post("/1/friendships/update.json", )['relationship'] Twitter::Relationship.new(relationship) end |
#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.
213 214 215 216 217 218 219 220 |
# File 'lib/twitter/client/friends_and_followers.rb', line 213 def friendships(*args) = args.last.is_a?(Hash) ? args.pop : {} users = args .merge_users!(Array(users)) get("/1/friendships/lookup.json", ).map do |user| Twitter::User.new(user) end 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
102 103 104 105 106 |
# File 'lib/twitter/client/friends_and_followers.rb', line 102 def friendships_incoming(={}) = {:cursor => -1}.merge() cursor = get("/1/friendships/incoming.json", ) Twitter::Cursor.new(cursor, '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
119 120 121 122 123 |
# File 'lib/twitter/client/friends_and_followers.rb', line 119 def friendships_outgoing(={}) = {:cursor => -1}.merge() cursor = get("/1/friendships/outgoing.json", ) Twitter::Cursor.new(cursor, 'ids') end |
#no_retweet_ids(options = {}) ⇒ Array<Integer>
Returns an array of user_ids that the currently authenticated user does not want to see retweets from.
253 254 255 |
# File 'lib/twitter/client/friends_and_followers.rb', line 253 def no_retweet_ids(={}) get("/1/friendships/no_retweet_ids.json", , :phoenix => true) end |
#unfollow(user, options = {}) ⇒ Twitter::User Also known as: friendship_destroy
Allows the authenticating user to unfollow the specified user
189 190 191 192 193 |
# File 'lib/twitter/client/friends_and_followers.rb', line 189 def unfollow(user, ={}) .merge_user!(user) user = delete("/1/friendships/destroy.json", ) Twitter::User.new(user) end |