module FoursquareNext::Users
Public Instance Methods
check if the first last name of user match the query
# File lib/foursquare_next/users.rb, line 64 def check_name user, query user.firstName.downcase.match(query.downcase) end
Get user's leaderboard details
@param [Hash] options @option options Integer :neighbors Number of friends' scores adjacent to your score
# File lib/foursquare_next/users.rb, line 8 def leaderboard(options={}) response = connection.get do |req| req.url "users/leaderboard", options end return_error_or_body(response, response.body.response) end
Search for users @param [Hash] options @option options String :phone - Match on phone number @option options String :email - Match on email @option options String :twitter - Match on twitter username @option options String :twitterSource - Friends of this twitter handle that use foursquare. @option options String :fbid - Match on facebook id. @option options String :name - Match on name
# File lib/foursquare_next/users.rb, line 35 def search_users(options={}) response = connection.get do |req| req.url "users/search", options end return_error_or_body(response, response.body.response) end
Search for users by tip @param [Hash] options @option options String :ll - Latitude and longitude in format LAT,LON @option options Integer :limit - The limit of results to return. @option options Integer :offset - Used to page through results. @option options String :filter - Set to 'friends' to limit tips to those from friends. @option options String :query - Only find tips matching this term. @option options String :name - Match on name
# File lib/foursquare_next/users.rb, line 51 def search_users_by_tip(options={}) name = options.delete(:name) options[:limit] = 500 tips = search_tips(options) user = [] tips.each do |tip| user << tip['user'] if check_name(tip['user'], name) end user.uniq end
Get information about a user
@param [Integer] user_id - User to get information for.
# File lib/foursquare_next/users.rb, line 19 def user(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}", options end return_error_or_body(response, response.body.response.user) end
Approve friendship with a user.
@param [String] user_id - The user to approve friendship with.
# File lib/foursquare_next/users.rb, line 226 def user_approve_friend(user_id, options={}) response = connection.post do |req| req.url "users/#{user_id}/approve", options end return_error_or_body(response, response.body.response) end
Get all badges for a given user.
@param [String] user_id - The user to retrieve badges for.
# File lib/foursquare_next/users.rb, line 80 def user_badges(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}/badges", options end return_error_or_body(response, response.body.response) end
Get checkins for the authenticated user @param [Hash] options @option options Integer :limit @option options Integer :offest - For paging through results @option options String :sort - “newestfirst” or “oldestfirst” @option options Integer :afterTimestamp - Get all checkins after this epoch time. @option options Integer :beforeTimestamp - Get all checkins before this epoch time.
# File lib/foursquare_next/users.rb, line 95 def user_checkins(options={}) response = connection.get do |req| req.url "users/self/checkins", options end return_error_or_body(response, response.body.response.checkins) end
Deny friendship with a user.
@param [String] user_id - The user to deny friendship with.
# File lib/foursquare_next/users.rb, line 237 def user_deny_friend(user_id, options={}) response = connection.post do |req| req.url "users/#{user_id}/deny", options end return_error_or_body(response, response.body.response) end
Request friendship with a user
@param [String] user_id - The user to request friendship with.
# File lib/foursquare_next/users.rb, line 204 def user_friend_request(user_id, options={}) response = connection.post do |req| req.url "users/#{user_id}/request", options end return_error_or_body(response, response.body.response) end
Get all friends for a given user.
@param [String] user_id - The user to retrieve friends for. @param [Hash] options @option options Integer :limit @option options Integer :offest - For paging through results
# File lib/foursquare_next/users.rb, line 109 def user_friends(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}/friends", options end return_error_or_body(response, response.body.response.friends) end
Get the lists for a given user.
@param [String] user_id - The user to retrieve lists for. @param [Hash] options @option options String :group - One of: created, edited, followed, friends, or suggestions @option options String :ll - Location of the user, required in order to receive the suggested group.
# File lib/foursquare_next/users.rb, line 193 def user_lists(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}/lists", options end return_error_or_body(response, response.body.response.lists) end
Get the mayorships for a given user.
@param [String] user_id - The user to retrieve friends for.
# File lib/foursquare_next/users.rb, line 179 def user_mayorships(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}/mayorships", options end return_error_or_body(response, response.body.response.mayorships) end
Get the photos for the authenticated user.
@param [Hash] options @option options Integer :limit - The limit of results to return. @option options Integer :offset - Used to page through results.
# File lib/foursquare_next/users.rb, line 155 def user_photos(options={}) response = connection.get do |req| req.url "users/self/photos", options end return_error_or_body(response, response.body.response.photos) end
Get all pending friend requests for the authenticated user
# File lib/foursquare_next/users.rb, line 69 def user_requests(options={}) response = connection.get do |req| req.url "users/requests", options end return_error_or_body(response, response.body.response.requests) end
Set pings for a friend
@param [String] user_id - The user to set pings for @param [String] value - The value of ping setting for this friend, either true or false.
# File lib/foursquare_next/users.rb, line 249 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
Get all tips for a given user, optionally filtering by text.
@param [String] user_id - The user to retrieve friends for. @param [Hash] options @option options Integer :limit @option options Integer :offest - For paging through results @option options String :sort - One of recent, nearby, popular @option options String :ll - Latitude and longitude in format LAT,LON - required for nearby sort option. @option String :query - Only find tips matching this term.
# File lib/foursquare_next/users.rb, line 126 def user_tips(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}/tips", options end tips = return_error_or_body(response, response.body.response.tips) tips = FoursquareNext.filter(tips, options[:query]) if options.has_key? :query tips end
Get all todos for a given user.
@param [String] user_id - The user to retrieve friends for. @param [Hash] options @option options String :sort - One of recent, nearby, popular @option options String :ll - Latitude and longitude in format LAT,LON - required for nearby sort option.
# File lib/foursquare_next/users.rb, line 142 def user_todos(user_id, options={}) response = connection.get do |req| req.url "users/#{user_id}/todos", options end return_error_or_body(response, response.body.response.todos) end
Unfriend a user
@param [String] user_id - The user to unfriend.
# File lib/foursquare_next/users.rb, line 215 def user_unfriend(user_id, options={}) response = connection.post do |req| req.url "users/#{user_id}/unfriend", options end return_error_or_body(response, response.body.response) end
Get the venue history for the authenticated user.
@param [Hash] options @option options Integer :afterTimestamp - Get all venues after this epoch time. @option options Integer :beforeTimestamp - Get all venues before this epoch time.
# File lib/foursquare_next/users.rb, line 168 def user_venue_history(options={}) response = connection.get do |req| req.url "users/self/venuehistory", options end return_error_or_body(response, response.body.response.venues) end
Summary of venues visited by a user optional @param [String] user_id - The user to get venue stats for.
@option options Integer :afterTimestamp - checkins after this epoch time. @option options Integer :beforeTimestamp - checkins before this epoch time.
# File lib/foursquare_next/users.rb, line 261 def venuestats(user_id="self", options={}) response = connection.get do |req| req.url "users/#{user_id}/venuestats", options end return_error_or_body(response, response.body.response) end