Class: Foursquared::Response::User

Inherits:
Object
  • Object
show all
Defined in:
lib/foursquared/response/user.rb

Overview

User response class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, response) ⇒ 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

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/foursquared/response/user.rb', line 7

def client
  @client
end

#responseObject (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

#badgesHash

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

#bioString

A short bio for the user



82
83
84
# File 'lib/foursquared/response/user.rb', line 82

def bio
  response["bio"]
end

#checkin_pingsString

Whether to ping if user checkins



88
89
90
# File 'lib/foursquared/response/user.rb', line 88

def checkin_pings
  response["checkinPings"]
end

#contactHash

User’s contact details



118
119
120
# File 'lib/foursquared/response/user.rb', line 118

def contact
  response["contact"]
end

#deny_friend_requestFoursquared::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_nameString

User’s first name



21
22
23
# File 'lib/foursquared/response/user.rb', line 21

def first_name
  response["firstName"]
end

#followersHash

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

#followingHash

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

#friendsHash

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_badgesHash

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

Options Hash (options):

  • :limit (Integer)

    Number of results to return, up to 500.

  • :offset (Integer)

    Used to page through results.



64
65
66
# File 'lib/foursquared/response/user.rb', line 64

def full_friends options={}
  client.user_friends(id, options)
end

#full_lists(options = {}) ⇒ Hash

Return the user’s full lists

Options Hash (options):

  • :group (String)

    “edited”, “created”, “followed”, “friends” or “suggested”

  • :ll (String)

    Location of the user eg: 40.7,-74



175
176
177
# File 'lib/foursquared/response/user.rb', line 175

def full_lists options={}
  client.user_lists(id, options)
end

#full_mayorshipsHash

List user’s full mayorships



189
190
191
# File 'lib/foursquared/response/user.rb', line 189

def full_mayorships
  client.user_mayorships(id)
end

#genderString

User’s gender



70
71
72
# File 'lib/foursquared/response/user.rb', line 70

def gender
  response["gender"]
end

#home_cityString

User’s home city



76
77
78
# File 'lib/foursquared/response/user.rb', line 76

def home_city
  response["homeCity"]
end

#idString

The user’s id



15
16
17
# File 'lib/foursquared/response/user.rb', line 15

def id
  response["id"]
end

#last_nameString

User’s last name



27
28
29
# File 'lib/foursquared/response/user.rb', line 27

def last_name
  response["lastName"]
end

#listsHash

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

#mayorshipsHash

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

#nameString

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_infoHash

Page details



124
125
126
# File 'lib/foursquared/response/user.rb', line 124

def page_info
  response["pageInfo"]
end

#photoFoursquared::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

#pingsBoolean

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_idString

User’s refferal ID



130
131
132
# File 'lib/foursquared/response/user.rb', line 130

def refferal_id
  response["refferalId"]
end

#relationshipString

User’s relationship with the acting user



45
46
47
# File 'lib/foursquared/response/user.rb', line 45

def relationship
  response["relationship"]
end

#scoresHash

User’s current game status.



100
101
102
# File 'lib/foursquared/response/user.rb', line 100

def scores
  response["scores"]
end

#send_friend_requestFoursquared::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

Options Hash (options):

  • :value (Boolean)

    required, true or false.



239
240
241
242
# File 'lib/foursquared/response/user.rb', line 239

def set_pings options={}
  request_response = post("/users/#{id}/setpings", options)["response"]
  @user = Foursquared::Response::User.new(client,request_response["user"])
end

#typeString

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

#unfriendFoursquared::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

#venueFoursquared::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