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, options = {}) ⇒ Object
Get information about a user.
-
#user_approve_friend(user_id, options = {}) ⇒ Object
Approve friendship with a user.
-
#user_badges(user_id, options = {}) ⇒ Object
Get all badges for a given user.
-
#user_checkins(options = {}) ⇒ Object
Get checkins for the authenticated user.
-
#user_deny_friend(user_id, options = {}) ⇒ Object
Deny friendship with a user.
-
#user_friend_request(user_id, options = {}) ⇒ 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, options = {}) ⇒ Object
Get the mayorships for a given user.
- #user_photos(options = {}) ⇒ Object
-
#user_requests(options = {}) ⇒ 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, options = {}) ⇒ 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
65 66 67 |
# File 'lib/foursquare2/users.rb', line 65 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
36 37 38 39 40 41 |
# File 'lib/foursquare2/users.rb', line 36 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
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/foursquare2/users.rb', line 52 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, options = {}) ⇒ Object
Get information about a user
20 21 22 23 24 25 |
# File 'lib/foursquare2/users.rb', line 20 def user(user_id, ={}) response = connection.get do |req| req.url "users/#{user_id}", end return_error_or_body(response, response.body.response.user) end |
#user_approve_friend(user_id, options = {}) ⇒ Object
Approve friendship with a user.
230 231 232 233 234 235 |
# File 'lib/foursquare2/users.rb', line 230 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, options = {}) ⇒ Object
Get all badges for a given user.
81 82 83 84 85 86 |
# File 'lib/foursquare2/users.rb', line 81 def user_badges(user_id, ={}) response = connection.get do |req| req.url "users/#{user_id}/badges", end return_error_or_body(response, response.body.response) end |
#user_checkins(options = {}) ⇒ Object
Get checkins for the authenticated user
96 97 98 99 100 101 |
# File 'lib/foursquare2/users.rb', line 96 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, options = {}) ⇒ Object
Deny friendship with a user.
241 242 243 244 245 246 |
# File 'lib/foursquare2/users.rb', line 241 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, options = {}) ⇒ Object
Request friendship with a user
208 209 210 211 212 213 |
# File 'lib/foursquare2/users.rb', line 208 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.
110 111 112 113 114 115 |
# File 'lib/foursquare2/users.rb', line 110 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.
197 198 199 200 201 202 |
# File 'lib/foursquare2/users.rb', line 197 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, options = {}) ⇒ Object
Get the mayorships for a given user.
183 184 185 186 187 188 |
# File 'lib/foursquare2/users.rb', line 183 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
158 159 160 161 162 163 |
# File 'lib/foursquare2/users.rb', line 158 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(options = {}) ⇒ Object
Get all pending friend requests for the authenticated user
70 71 72 73 74 75 |
# File 'lib/foursquare2/users.rb', line 70 def user_requests(={}) response = connection.get do |req| req.url "users/requests", end return_error_or_body(response, response.body.response.requests) end |
#user_set_friend_pings(user_id, value) ⇒ Object
Set pings for a friend
253 254 255 256 257 258 |
# File 'lib/foursquare2/users.rb', line 253 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.
127 128 129 130 131 132 133 134 |
# File 'lib/foursquare2/users.rb', line 127 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
144 145 146 147 148 149 |
# File 'lib/foursquare2/users.rb', line 144 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, options = {}) ⇒ Object
Unfriend a user
219 220 221 222 223 224 |
# File 'lib/foursquare2/users.rb', line 219 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
172 173 174 175 176 177 |
# File 'lib/foursquare2/users.rb', line 172 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.
265 266 267 268 269 270 |
# File 'lib/foursquare2/users.rb', line 265 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 |