Module: Foursquared::Users
- Included in:
- Client
- Defined in:
- lib/foursquared/users.rb
Overview
Users module
Instance Method Summary collapse
-
#approve_friend_request(user_id) ⇒ Foursquared::Response::User
Approves a pending friend request from another user.
-
#deny_friend_request(user_id) ⇒ Foursquared::Response::User
Denies a pending friend request from another user.
-
#leaderboard(options = {}) ⇒ Hash
Returns the user’s leaderboard.
-
#requests ⇒ Array
Pending friend requests.
-
#search(options = {}) ⇒ Hash
Find users.
-
#send_friend_request(user_id) ⇒ Foursquared::Response::User
Send a Friend/Follow Request.
-
#set_pings(user_id, options = {}) ⇒ Foursquared::Response::User
Set whether to receive pings about a user.
-
#unfriend(user_id) ⇒ Foursquared::Response::User
Removes a friend, unfollows a celebrity, or cancels a pending friend request.
-
#update_photo(image_filename) ⇒ Foursquared::Response::User
Update user’s photo.
-
#user(user_id = "self") ⇒ Foursquared::Response::User
Return profile information for a given user.
-
#user_badges(user_id = "self") ⇒ Hash
Badges for a user.
-
#user_checkins(user_id = "self", options = {}) ⇒ Hash
Checkins by a user.
-
#user_friends(user_id = "self", options = {}) ⇒ Hash
List friends.
-
#user_lists(user_id = "self", options = {}) ⇒ Hash
Return the user’s lists.
-
#user_mayorships(user_id = "self") ⇒ Hash
List user’s mayorships.
-
#user_photos(user_id = "self", options = {}) ⇒ Hash
Photos from a User.
-
#user_tips(user_id = "self", options = {}) ⇒ Foursquared::Response::List
Tips from a User.
-
#user_todos(user_id = "self", options = {}) ⇒ Foursquared::Response::List
Todos from a User.
Instance Method Details
#approve_friend_request(user_id) ⇒ Foursquared::Response::User
Approves a pending friend request from another user.
29 30 31 32 |
# File 'lib/foursquared/users.rb', line 29 def approve_friend_request user_id response = post("/users/#{user_id}/approve")["response"] @user = Foursquared::Response::User.new(self,response["user"]) end |
#deny_friend_request(user_id) ⇒ Foursquared::Response::User
Denies a pending friend request from another user.
37 38 39 40 |
# File 'lib/foursquared/users.rb', line 37 def deny_friend_request user_id response = post("/users/#{user_id}/deny")["response"] @user = Foursquared::Response::User.new(self,response["user"]) end |
#leaderboard(options = {}) ⇒ Hash
Returns the user’s leaderboard.
18 19 20 21 22 23 24 |
# File 'lib/foursquared/users.rb', line 18 def leaderboard ={} @leaderboard = get("/users/leaderboard", )["response"]["leaderboard"] @leaderboard["items"].each do |item| item["user"] = Foursquared::Response::User.new(self,item["user"]) end @leaderboard end |
#requests ⇒ Array
Pending friend requests
60 61 62 63 |
# File 'lib/foursquared/users.rb', line 60 def requests response = get("/users/requests")["response"] @requests = response["requests"].collect{|request| Foursquared::Response::User.new(self,request)} end |
#search(options = {}) ⇒ Hash
Find users
74 75 76 77 78 |
# File 'lib/foursquared/users.rb', line 74 def search ={} response = get("/users/search", )["response"] response["results"].map!{|result| Foursquared::Response::User.new(self,result)} response end |
#send_friend_request(user_id) ⇒ Foursquared::Response::User
Send a Friend/Follow Request
45 46 47 48 |
# File 'lib/foursquared/users.rb', line 45 def send_friend_request user_id response = post("/users/#{user_id}/request")["response"] @user = Foursquared::Response::User.new(self,response["user"]) end |
#set_pings(user_id, options = {}) ⇒ Foursquared::Response::User
Set whether to receive pings about a user
85 86 87 88 |
# File 'lib/foursquared/users.rb', line 85 def set_pings user_id, ={} response = post("/users/#{user_id}/setpings", )["response"] @user = Foursquared::Response::User.new(self,response["user"]) end |
#unfriend(user_id) ⇒ Foursquared::Response::User
Removes a friend, unfollows a celebrity, or cancels a pending friend request.
53 54 55 56 |
# File 'lib/foursquared/users.rb', line 53 def unfriend user_id response = post("/users/#{user_id}/unfriend")["response"] @user = Foursquared::Response::User.new(self,response["user"]) end |
#update_photo(image_filename) ⇒ Foursquared::Response::User
Update user’s photo
93 94 95 96 |
# File 'lib/foursquared/users.rb', line 93 def update_photo image_filename response = post("/users/self/update", ={:photo => File.read(image_filename)})["response"] @user = Foursquared::Response::User.new(self, response["user"]) end |
#user(user_id = "self") ⇒ Foursquared::Response::User
Return profile information for a given user
9 10 11 12 |
# File 'lib/foursquared/users.rb', line 9 def user user_id="self" @user = get("/users/#{user_id}")["response"]["user"] Foursquared::Response::User.new(self,@user) end |
#user_badges(user_id = "self") ⇒ Hash
Badges for a user
191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/foursquared/users.rb', line 191 def user_badges user_id="self" response = get("/users/#{user_id}/badges")["response"] if response["sets"] and response["sets"]["groups"] response["sets"]["groups"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)} end if response["badges"] response["badges"].each_key do |badge_id| response["badges"][badge_id] = badge(badge_id) end end response end |
#user_checkins(user_id = "self", options = {}) ⇒ Hash
Checkins by a user
107 108 109 110 111 |
# File 'lib/foursquared/users.rb', line 107 def user_checkins user_id="self", ={} response = get("/users/#{user_id}/checkins",)["response"]["checkins"] response["items"].map!{|checkin| Foursquared::Response::Checkin.new(self, checkin)} if response["items"] response end |
#user_friends(user_id = "self", options = {}) ⇒ Hash
List friends
119 120 121 122 123 |
# File 'lib/foursquared/users.rb', line 119 def user_friends user_id="self", ={} response = get("/users/#{user_id}/friends"), ["response"]["friends"] response["items"].map!{|friend| Foursquared::Response::User.new(self, friend)} if response["items"] response end |
#user_lists(user_id = "self", options = {}) ⇒ Hash
Return the user’s lists
131 132 133 134 135 136 137 138 |
# File 'lib/foursquared/users.rb', line 131 def user_lists user_id="self", ={} response = get("/users/#{user_id}/lists", )["response"] @lists = response["lists"] @lists["groups"].each do |group| group["items"].map!{|item| Foursquared::Response::List.new(self, item)} end @lists end |
#user_mayorships(user_id = "self") ⇒ Hash
List user’s mayorships
143 144 145 146 147 148 |
# File 'lib/foursquared/users.rb', line 143 def user_mayorships user_id="self" response = get("/users/#{user_id}/mayorships")["response"] @mayorships = response["mayorships"] @mayorships["items"].each{|item| item["venue"] = Foursquared::Response::Venue.new(self, item["venue"])} @mayorships end |
#user_photos(user_id = "self", options = {}) ⇒ Hash
Photos from a User
156 157 158 159 160 |
# File 'lib/foursquared/users.rb', line 156 def user_photos user_id="self", ={} response = get("/users/#{user_id}/photos",)["response"] @photos = response["photos"] @photos["items"].map!{|item| Foursquared::Response::Photo.new(self, item)} end |
#user_tips(user_id = "self", options = {}) ⇒ Foursquared::Response::List
Tips from a User
170 171 172 173 |
# File 'lib/foursquared/users.rb', line 170 def user_tips user_id="self", ={} response = get("/lists/#{user_id}/tips", )["response"] Foursquared::Response::List.new(self, response["list"]) end |
#user_todos(user_id = "self", options = {}) ⇒ Foursquared::Response::List
Todos from a User
183 184 185 186 |
# File 'lib/foursquared/users.rb', line 183 def user_todos user_id="self", ={} response = get("/lists/#{user_id}/todos", )["response"] Foursquared::Response::List.new(self, response["list"]) end |