Class: Foursquared::Response::User
- Inherits:
-
Object
- Object
- Foursquared::Response::User
- Defined in:
- lib/foursquared/response/user.rb
Overview
User response class
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#approve_friend_request(user_id) ⇒ Foursquared::Response::User
Approves a pending friend request from this user.
-
#badges ⇒ Hash
List user’s badges.
-
#bio ⇒ String
A short bio for the user.
-
#checkin_pings ⇒ String
Whether to ping if user checkins.
-
#contact ⇒ Hash
User’s contact details.
-
#deny_friend_request ⇒ Foursquared::Response::User
Denies a pending friend request from this user.
-
#first_name ⇒ String
User’s first name.
-
#followers ⇒ Hash
User’s followers.
-
#following ⇒ Hash
Groups of pages this user user has liked or followed.
-
#friends ⇒ Hash
User’s friends list retrieved from the initial response.
-
#full_badges ⇒ Hash
List user’s full badges.
-
#full_friends(options = {}) ⇒ Hash
User’s full friends list.
-
#full_lists(options = {}) ⇒ Hash
Return the user’s full lists.
-
#full_mayorships ⇒ Hash
List user’s full mayorships.
-
#gender ⇒ String
User’s gender.
-
#home_city ⇒ String
User’s home city.
-
#id ⇒ String
The user’s id.
-
#initialize(client, response) ⇒ User
constructor
A new instance of User.
-
#last_name ⇒ String
User’s last name.
-
#lists ⇒ Hash
Return the user’s lists.
-
#mayorships ⇒ Hash
List user’s mayorships.
-
#name ⇒ String
User’s full name.
-
#page_info ⇒ Hash
Page details.
-
#photo ⇒ Foursquared::Response::Photo
User’s profile photo.
-
#pings ⇒ Boolean
Whether we receive pings from this user, if we have a relationship.
-
#refferal_id ⇒ String
User’s refferal ID.
-
#relationship ⇒ String
User’s relationship with the acting user.
-
#scores ⇒ Hash
User’s current game status.
-
#send_friend_request ⇒ Foursquared::Response::User
Send a Friend/Follow Request to this user.
-
#set_pings(options = {}) ⇒ Foursquared::Response::User
Set whether to receive pings about this user.
-
#type ⇒ String
Type of user.
-
#unfriend ⇒ Foursquared::Response::User
Removes a friend, unfollows a celebrity, or cancels a pending friend request.
-
#venue ⇒ Foursquared::Response::Venue
Venue details.
Constructor Details
#initialize(client, response) ⇒ User
Returns a new instance of User.
8 9 10 11 |
# File 'lib/foursquared/response/user.rb', line 8 def initialize client, response @client = client @response = response end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/foursquared/response/user.rb', line 7 def client @client end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/foursquared/response/user.rb', line 7 def response @response end |
Instance Method Details
#approve_friend_request(user_id) ⇒ Foursquared::Response::User
Approves a pending friend request from this user.
208 209 210 211 |
# File 'lib/foursquared/response/user.rb', line 208 def approve_friend_request user_id response = post("/users/#{id}/approve")["response"] @user = Foursquared::Response::User.new(client, response["user"]) end |
#badges ⇒ Hash
List user’s badges
195 196 197 198 |
# File 'lib/foursquared/response/user.rb', line 195 def badges @badges = response["badges"] @badges["items"].map!{|item| Foursquared::Response::Badge.new(client, item)} end |
#bio ⇒ String
A short bio for the user
82 83 84 |
# File 'lib/foursquared/response/user.rb', line 82 def bio response["bio"] end |
#checkin_pings ⇒ String
Whether to ping if user checkins
88 89 90 |
# File 'lib/foursquared/response/user.rb', line 88 def checkin_pings response["checkinPings"] end |
#contact ⇒ Hash
User’s contact details
118 119 120 |
# File 'lib/foursquared/response/user.rb', line 118 def contact response["contact"] end |
#deny_friend_request ⇒ Foursquared::Response::User
Denies a pending friend request from this user.
215 216 217 218 |
# File 'lib/foursquared/response/user.rb', line 215 def deny_friend_request request_response = post("/users/#{id}/deny")["response"] @user = Foursquared::Response::User.new(client, request_response["user"]) end |
#first_name ⇒ String
User’s first name
21 22 23 |
# File 'lib/foursquared/response/user.rb', line 21 def first_name response["firstName"] end |
#followers ⇒ Hash
User’s followers
136 137 138 139 140 141 142 143 144 |
# File 'lib/foursquared/response/user.rb', line 136 def followers if response["followers"] and response["followers"]["groups"] @followers = response["followers"] @followers["groups"].each do |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)} end return @followers end end |
#following ⇒ Hash
Groups of pages this user user has liked or followed.
148 149 150 151 152 153 154 155 156 |
# File 'lib/foursquared/response/user.rb', line 148 def following if response["following"] and response["following"]["groups"] @following = response["following"] @following["groups"].each do |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)} end return @following end end |
#friends ⇒ Hash
User’s friends list retrieved from the initial response
51 52 53 54 55 56 57 |
# File 'lib/foursquared/response/user.rb', line 51 def friends @friends = response["friends"] @friends["groups"].each do |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)} end @friends end |
#full_badges ⇒ Hash
List user’s full badges
202 203 204 |
# File 'lib/foursquared/response/user.rb', line 202 def full_badges client.user_badges(id) end |
#full_friends(options = {}) ⇒ Hash
User’s full friends list
64 65 66 |
# File 'lib/foursquared/response/user.rb', line 64 def full_friends ={} client.user_friends(id, ) end |
#full_lists(options = {}) ⇒ Hash
Return the user’s full lists
175 176 177 |
# File 'lib/foursquared/response/user.rb', line 175 def full_lists ={} client.user_lists(id, ) end |
#full_mayorships ⇒ Hash
List user’s full mayorships
189 190 191 |
# File 'lib/foursquared/response/user.rb', line 189 def full_mayorships client.user_mayorships(id) end |
#gender ⇒ String
User’s gender
70 71 72 |
# File 'lib/foursquared/response/user.rb', line 70 def gender response["gender"] end |
#home_city ⇒ String
User’s home city
76 77 78 |
# File 'lib/foursquared/response/user.rb', line 76 def home_city response["homeCity"] end |
#id ⇒ String
The user’s id
15 16 17 |
# File 'lib/foursquared/response/user.rb', line 15 def id response["id"] end |
#last_name ⇒ String
User’s last name
27 28 29 |
# File 'lib/foursquared/response/user.rb', line 27 def last_name response["lastName"] end |
#lists ⇒ Hash
Return the user’s lists
160 161 162 163 164 165 166 167 168 |
# File 'lib/foursquared/response/user.rb', line 160 def lists @lists = response["lists"] if @lists and @lists["groups"] @lists["groups"].each do |group| group["items"].map!{|item| Foursquared::Response::List.new(client, item)} end end @lists end |
#mayorships ⇒ Hash
List user’s mayorships
181 182 183 184 185 |
# File 'lib/foursquared/response/user.rb', line 181 def mayorships @mayorships = response["mayorships"] @mayorships["items"].each{|item| item["venue"] = Foursquared::Response::Venue.new(client, item["venue"])} @mayorships end |
#name ⇒ String
User’s full name
33 34 35 |
# File 'lib/foursquared/response/user.rb', line 33 def name [first_name, last_name].join(' ').strip end |
#page_info ⇒ Hash
Page details
124 125 126 |
# File 'lib/foursquared/response/user.rb', line 124 def page_info response["pageInfo"] end |
#photo ⇒ Foursquared::Response::Photo
User’s profile photo
39 40 41 |
# File 'lib/foursquared/response/user.rb', line 39 def photo Foursquared::Response::Photo.new(client, response["photo"]) end |
#pings ⇒ Boolean
Whether we receive pings from this user, if we have a relationship.
94 95 96 |
# File 'lib/foursquared/response/user.rb', line 94 def pings response["pings"] end |
#refferal_id ⇒ String
User’s refferal ID
130 131 132 |
# File 'lib/foursquared/response/user.rb', line 130 def refferal_id response["refferalId"] end |
#relationship ⇒ String
User’s relationship with the acting user
45 46 47 |
# File 'lib/foursquared/response/user.rb', line 45 def relationship response["relationship"] end |
#scores ⇒ Hash
User’s current game status.
100 101 102 |
# File 'lib/foursquared/response/user.rb', line 100 def scores response["scores"] end |
#send_friend_request ⇒ Foursquared::Response::User
Send a Friend/Follow Request to this user
223 224 225 226 |
# File 'lib/foursquared/response/user.rb', line 223 def send_friend_request request_response = post("/users/#{id}/request")["response"] @user = Foursquared::Response::User.new(client, request_response["userrequest_"]) end |
#set_pings(options = {}) ⇒ Foursquared::Response::User
Set whether to receive pings about this user
239 240 241 242 |
# File 'lib/foursquared/response/user.rb', line 239 def set_pings ={} request_response = post("/users/#{id}/setpings", )["response"] @user = Foursquared::Response::User.new(client,request_response["user"]) end |
#type ⇒ String
Type of user. Optional, Present for non-standard user types
106 107 108 |
# File 'lib/foursquared/response/user.rb', line 106 def type response["type"] end |
#unfriend ⇒ Foursquared::Response::User
Removes a friend, unfollows a celebrity, or cancels a pending friend request.
230 231 232 233 |
# File 'lib/foursquared/response/user.rb', line 230 def unfriend request_response = post("/users/#{id}/unfriend")["response"] @user = Foursquared::Response::User.new(client, request_response["user"]) end |
#venue ⇒ Foursquared::Response::Venue
Venue details
112 113 114 |
# File 'lib/foursquared/response/user.rb', line 112 def venue Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"] end |