Module: Foursquare2::Users
- Included in:
- Client
- Defined in:
- lib/foursquare2/users.rb
Instance Method Summary collapse
-
#check_name(user, query) ⇒ Object
check if the first last name of user match the query.
-
#leaderboard(options = {}) ⇒ Object
Get user’s leaderboard details.
-
#search_users(options = {}) ⇒ Object
Search for users.
-
#search_users_by_tip(options = {}) ⇒ Object
Search for users by tip.
-
#user(user_id) ⇒ Object
Get information about a user.
-
#user_approve_friend(user_id) ⇒ Object
Approve friendship with a user.
-
#user_badges(user_id) ⇒ Object
Get all badges for a given user.
-
#user_checkins(options = {}) ⇒ Object
Get checkins for the authenticated user.
-
#user_deny_friend(user_id) ⇒ Object
Deny friendship with a user.
-
#user_friend_request(user_id) ⇒ Object
Request friendship with a user.
-
#user_friends(user_id, options = {}) ⇒ Object
Get all friends for a given user.
-
#user_lists(user_id, options = {}) ⇒ Object
Get the lists for a given user.
-
#user_mayorships(user_id) ⇒ Object
Get the mayorships for a given user.
- #user_photos(options = {}) ⇒ Object
-
#user_requests ⇒ Object
Get all pending friend requests for the authenticated user.
-
#user_set_friend_pings(user_id, value) ⇒ Object
Set pings for a friend.
-
#user_tips(user_id, options = {}) ⇒ Object
Get all tips for a given user, optionally filtering by text.
- #user_todos(user_id, options = {}) ⇒ Object
-
#user_unfriend(user_id) ⇒ Object
Unfriend a user.
- #user_venue_history(options = {}) ⇒ Object
-
#venuestats(user_id = "self", options = {}) ⇒ Object
Summary of venues visited by a user optional @param [String] user_id - The user to get venue stats for.
Instance Method Details
#check_name(user, query) ⇒ Object
check if the first last name of user match the query
63 64 65 |
# File 'lib/foursquare2/users.rb', line 63 def check_name user, query user.firstName.downcase.match(query.downcase) end |
#leaderboard(options = {}) ⇒ Object
Get user’s leaderboard details
9 10 11 12 13 14 |
# File 'lib/foursquare2/users.rb', line 9 def leaderboard(={}) response = connection.get do |req| req.url "users/leaderboard", end return_error_or_body(response, response.body.response) end |
#search_users(options = {}) ⇒ Object
Search for users
34 35 36 37 38 39 |
# File 'lib/foursquare2/users.rb', line 34 def search_users(={}) response = connection.get do |req| req.url "users/search", end return_error_or_body(response, response.body.response) end |
#search_users_by_tip(options = {}) ⇒ Object
Search for users by tip
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/foursquare2/users.rb', line 50 def search_users_by_tip(={}) name = .delete(:name) [:limit] = 500 tips = search_tips() user = [] tips.each do |tip| user << tip['user'] if check_name(tip['user'], name) end user.uniq end |
#user(user_id) ⇒ Object
Get information about a user
20 21 22 23 |
# File 'lib/foursquare2/users.rb', line 20 def user(user_id) response = connection.get("users/#{user_id}") return_error_or_body(response, response.body.response.user) end |
#user_approve_friend(user_id) ⇒ Object
Approve friendship with a user.
224 225 226 227 228 229 |
# File 'lib/foursquare2/users.rb', line 224 def user_approve_friend(user_id) response = connection.post do |req| req.url "users/#{user_id}/approve" end return_error_or_body(response, response.body.response) end |
#user_badges(user_id) ⇒ Object
Get all badges for a given user.
77 78 79 80 |
# File 'lib/foursquare2/users.rb', line 77 def user_badges(user_id) response = connection.get("users/#{user_id}/badges") return_error_or_body(response, response.body.response) end |
#user_checkins(options = {}) ⇒ Object
Get checkins for the authenticated user
90 91 92 93 94 95 |
# File 'lib/foursquare2/users.rb', line 90 def user_checkins(={}) response = connection.get do |req| req.url "users/self/checkins", end return_error_or_body(response, response.body.response.checkins) end |
#user_deny_friend(user_id) ⇒ Object
Deny friendship with a user.
235 236 237 238 239 240 |
# File 'lib/foursquare2/users.rb', line 235 def user_deny_friend(user_id) response = connection.post do |req| req.url "users/#{user_id}/deny" end return_error_or_body(response, response.body.response) end |
#user_friend_request(user_id) ⇒ Object
Request friendship with a user
202 203 204 205 206 207 |
# File 'lib/foursquare2/users.rb', line 202 def user_friend_request(user_id) response = connection.post do |req| req.url "users/#{user_id}/request" end return_error_or_body(response, response.body.response) end |
#user_friends(user_id, options = {}) ⇒ Object
Get all friends for a given user.
104 105 106 107 108 109 |
# File 'lib/foursquare2/users.rb', line 104 def user_friends(user_id, ={}) response = connection.get do |req| req.url "users/#{user_id}/friends", end return_error_or_body(response, response.body.response.friends) end |
#user_lists(user_id, options = {}) ⇒ Object
Get the lists for a given user.
191 192 193 194 195 196 |
# File 'lib/foursquare2/users.rb', line 191 def user_lists(user_id, ={}) response = connection.get do |req| req.url "users/#{user_id}/lists", end return_error_or_body(response, response.body.response.lists) end |
#user_mayorships(user_id) ⇒ Object
Get the mayorships for a given user.
177 178 179 180 181 182 |
# File 'lib/foursquare2/users.rb', line 177 def user_mayorships(user_id) response = connection.get do |req| req.url "users/#{user_id}/mayorships" end return_error_or_body(response, response.body.response.mayorships) end |
#user_photos(options = {}) ⇒ Object
152 153 154 155 156 157 |
# File 'lib/foursquare2/users.rb', line 152 def user_photos(={}) response = connection.get do |req| req.url "users/self/photos", end return_error_or_body(response, response.body.response.photos) end |
#user_requests ⇒ Object
Get all pending friend requests for the authenticated user
68 69 70 71 |
# File 'lib/foursquare2/users.rb', line 68 def user_requests response = connection.get("users/requests") return_error_or_body(response, response.body.response.requests) end |
#user_set_friend_pings(user_id, value) ⇒ Object
Set pings for a friend
247 248 249 250 251 252 |
# File 'lib/foursquare2/users.rb', line 247 def user_set_friend_pings(user_id, value) response = connection.post do |req| req.url "users/#{user_id}/setpings", value end return_error_or_body(response, response.body.response) end |
#user_tips(user_id, options = {}) ⇒ Object
Get all tips for a given user, optionally filtering by text.
121 122 123 124 125 126 127 128 |
# File 'lib/foursquare2/users.rb', line 121 def user_tips(user_id, ={}) response = connection.get do |req| req.url "users/#{user_id}/tips", end tips = return_error_or_body(response, response.body.response.tips) tips = Foursquare2.filter(tips, [:query]) if .has_key? :query tips end |
#user_todos(user_id, options = {}) ⇒ Object
138 139 140 141 142 143 |
# File 'lib/foursquare2/users.rb', line 138 def user_todos(user_id, ={}) response = connection.get do |req| req.url "users/#{user_id}/todos", end return_error_or_body(response, response.body.response.todos) end |
#user_unfriend(user_id) ⇒ Object
Unfriend a user
213 214 215 216 217 218 |
# File 'lib/foursquare2/users.rb', line 213 def user_unfriend(user_id) response = connection.post do |req| req.url "users/#{user_id}/unfriend" end return_error_or_body(response, response.body.response) end |
#user_venue_history(options = {}) ⇒ Object
166 167 168 169 170 171 |
# File 'lib/foursquare2/users.rb', line 166 def user_venue_history(={}) response = connection.get do |req| req.url "users/self/venuehistory", end return_error_or_body(response, response.body.response.venues) end |
#venuestats(user_id = "self", options = {}) ⇒ Object
Summary of venues visited by a user optional @param [String] user_id - The user to get venue stats for.
259 260 261 262 263 264 |
# File 'lib/foursquare2/users.rb', line 259 def venuestats(user_id="self", ={}) response = connection.get do |req| req.url "users/#{user_id}/venuestats", end return_error_or_body(response, response.body.response) end |