foursquared 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +10 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +19 -0
  4. data/Guardfile +6 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +30 -0
  7. data/Rakefile +30 -0
  8. data/foursquared.gemspec +34 -0
  9. data/lib/core_ext/symbol.rb +7 -0
  10. data/lib/foursquared/badges.rb +12 -0
  11. data/lib/foursquared/checkins.rb +89 -0
  12. data/lib/foursquared/client.rb +58 -0
  13. data/lib/foursquared/error.rb +17 -0
  14. data/lib/foursquared/events.rb +18 -0
  15. data/lib/foursquared/lists.rb +97 -0
  16. data/lib/foursquared/oauth/client.rb +37 -0
  17. data/lib/foursquared/pages.rb +49 -0
  18. data/lib/foursquared/photos.rb +34 -0
  19. data/lib/foursquared/response/badge.rb +87 -0
  20. data/lib/foursquared/response/badge_group.rb +42 -0
  21. data/lib/foursquared/response/category.rb +53 -0
  22. data/lib/foursquared/response/checkin.rb +180 -0
  23. data/lib/foursquared/response/event.rb +52 -0
  24. data/lib/foursquared/response/list.rb +199 -0
  25. data/lib/foursquared/response/list_item.rb +63 -0
  26. data/lib/foursquared/response/photo.rb +102 -0
  27. data/lib/foursquared/response/special.rb +131 -0
  28. data/lib/foursquared/response/tip.rb +134 -0
  29. data/lib/foursquared/response/user.rb +246 -0
  30. data/lib/foursquared/response/venue.rb +252 -0
  31. data/lib/foursquared/settings.rb +28 -0
  32. data/lib/foursquared/specials.rb +25 -0
  33. data/lib/foursquared/tips.rb +113 -0
  34. data/lib/foursquared/users.rb +206 -0
  35. data/lib/foursquared/venues.rb +217 -0
  36. data/lib/foursquared/version.rb +4 -0
  37. data/lib/foursquared.rb +47 -0
  38. data/spec/foursquared/badges_spec.rb +82 -0
  39. data/spec/foursquared/checkins_spec.rb +0 -0
  40. data/spec/foursquared/events_spec.rb +50 -0
  41. data/spec/foursquared/oauth/client_spec.rb +24 -0
  42. data/spec/foursquared/pages_spec.rb +42 -0
  43. data/spec/foursquared/photos_spec.rb +41 -0
  44. data/spec/foursquared/response/badge_spec.rb +40 -0
  45. data/spec/foursquared/response/category_spec.rb +48 -0
  46. data/spec/foursquared/response/checkin_spec.rb +100 -0
  47. data/spec/foursquared/response/event_category_spec.rb +48 -0
  48. data/spec/foursquared/response/event_spec.rb +60 -0
  49. data/spec/foursquared/response/list_spec.rb +56 -0
  50. data/spec/foursquared/response/photo_spec.rb +70 -0
  51. data/spec/foursquared/response/special_spec.rb +0 -0
  52. data/spec/foursquared/response/user_spec.rb +124 -0
  53. data/spec/foursquared/response/venue_spec.rb +83 -0
  54. data/spec/foursquared/specials_spec.rb +4 -0
  55. data/spec/foursquared/users_spec.rb +241 -0
  56. data/spec/spec_helper.rb +27 -0
  57. metadata +344 -0
@@ -0,0 +1,252 @@
1
+ module Foursquared
2
+ module Response
3
+ # Venue response
4
+ class Venue
5
+ attr_reader :client, :response
6
+
7
+ def initialize client, response
8
+ @client = client
9
+ @response = response
10
+ end
11
+
12
+ # The venue ID
13
+ # @return [String]
14
+ def id
15
+ response["id"]
16
+ end
17
+
18
+ # The venue name
19
+ # @return [String]
20
+ def name
21
+ response["name"]
22
+ end
23
+
24
+ # The contact details for the venue
25
+ # @return [Hash]
26
+ def contact
27
+ response["contact"]
28
+ end
29
+
30
+ # The location details for the venue
31
+ # @return [Hash]
32
+ def location
33
+ response["location"]
34
+ end
35
+
36
+ # Whether this is a verified venue
37
+ # @return [Boolean]
38
+ def verified?
39
+ response["verified"]
40
+ end
41
+
42
+ # The canonical url for this venue
43
+ # @return [String]
44
+ def canonical_url
45
+ response["canonicalUrl"]
46
+ end
47
+
48
+ # An array of categories that have been applied to this venue
49
+ # @return [Array<Foursquared::Response::Category>]
50
+ def categories
51
+ response["categories"].map!{|category| Foursquared::Response::Category.new(client, category)} if response["categories"]
52
+ end
53
+
54
+ # Contains checkinsCount , usersCount , and tipCount.
55
+ # @return [Hash]
56
+ def stats
57
+ response["stats"]
58
+ end
59
+
60
+ # URL of the venue's website, typically provided by the venue manager.
61
+ def url
62
+ response["url"]
63
+ end
64
+
65
+ # An object containing the price tier from 1 (least pricey) - 4 (most pricey) and a message describing the price tier.
66
+ # @return [Hash]
67
+ def price
68
+ response["price"]
69
+ end
70
+
71
+ # Whether the current user has liked this venue.
72
+ # @return [Boolean]
73
+ def like?
74
+ response["like"]
75
+ end
76
+
77
+ # Whether the current user has disliked this venue.
78
+ # @return [Boolean]
79
+ def dislike?
80
+ response["dislike"]
81
+ end
82
+
83
+ # The rating for this venue
84
+ # @return [Float]
85
+ def rating
86
+ response["rating"]
87
+ end
88
+
89
+ # Array of categories that have been applied to this venue
90
+ # @return [Array<Foursquared::Response::Category>]
91
+ def categories
92
+ @categories = response["categories"] || []
93
+ @categories.map!{|category| Foursquared::Response::Category.new(client, category)}
94
+ end
95
+
96
+ # Menu information for the venue.
97
+ # @return [Hash]
98
+ def menu
99
+ response["menu"]
100
+ end
101
+
102
+ # Contains the hours during the week that the venue is open along with any named hours segments in a human-readable format.
103
+ # @return [Hash]
104
+ def hours
105
+ response["hours"]
106
+ end
107
+
108
+ # An array of phrases applied to this menu
109
+ # @return [Array<Hash>]
110
+ def phrases
111
+ response["phrases"]
112
+ end
113
+
114
+ # Count and items of reasons that have been applied at this venue
115
+ # @return [Hash]
116
+ def reasons
117
+ response["reasons"]
118
+ end
119
+
120
+ # Venue description
121
+ # @return [String]
122
+ def description
123
+ response["description"]
124
+ end
125
+
126
+ # The mayor of the venue
127
+ # @return [Foursquared::Response::User]
128
+ def mayor
129
+ Foursquared::Response::User.new(response["mayor"]["user"]) if response["mayor"] and response["mayor"]["user"]
130
+ end
131
+
132
+ # Users who like the venue
133
+ # @return [Hash]
134
+ def likes
135
+ likes_response = client.get("/venues/#{id}/likes")["response"]
136
+ @likes = {}
137
+ if likes_response["likes"]
138
+ @likes.merge!(likes_response["likes"])
139
+ if @likes["groups"]
140
+ @likes["groups"].each do |group|
141
+ group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
142
+ end
143
+ end
144
+ end
145
+ @likes
146
+ end
147
+
148
+ # Count and items of specials at the venue
149
+ # @return [Hash]
150
+ def specials
151
+ @specials = response["specials"]
152
+ @specials["items"].map!{|item| Foursquared::Response::Special.new(client, item)} if @specials
153
+ @specials
154
+ end
155
+
156
+ # The time at which the venue was added
157
+ # @return [Time]
158
+ def created_at
159
+ Time.at(response["createdAt"]) if response["createdAt"]
160
+ end
161
+
162
+ # The tips for this venue
163
+ # @return [Hash]
164
+ def tips
165
+ @tips = response["tips"]
166
+ if @tips["groups"]
167
+ @tips["groups"].each do |group|
168
+ group["items"].map!{|item| Foursquared::Response::Tip.new(client, item)}
169
+ end
170
+ end
171
+ @tips
172
+ end
173
+
174
+ # Array of string tags for this venue
175
+ # @return [Array<String>]
176
+ def tags
177
+ response["tags"]
178
+ end
179
+
180
+ # The shortened url for the venue
181
+ # @return [String]
182
+ def short_url
183
+ response["shortUrl"]
184
+ end
185
+
186
+ # The time zone
187
+ # @return [String]
188
+ def time_zone
189
+ response["timeZone"]
190
+ end
191
+
192
+ # A grouped response of lists that contain this venue
193
+ # @return [Hash]
194
+ def listed
195
+ @listed = response["listed"]
196
+ @listed["groups"].each do |group|
197
+ @listed["items"].map!{|item| Foursquared::Response::List.new(client, item)}
198
+ end
199
+ @listed
200
+ end
201
+
202
+ # The number of times the acting user has been to this venue
203
+ # @return [Integer]
204
+ def been_here
205
+ response["beenHere"]["count"] if response["beenHere"]
206
+ end
207
+
208
+ # Present only for venues returned in Explore search results.
209
+ # @return [Hash]
210
+ def flags
211
+ response["flags"]
212
+ end
213
+
214
+ # Present if and only if the current user has at least one assigned role for this venue.
215
+ # @return [Array]
216
+ def roles
217
+ response["roles"]
218
+ end
219
+
220
+ # The venue photos
221
+ # @return [Hash] count and groups of photos
222
+ def photos
223
+ @photos = response["photos"]
224
+ if @photos
225
+ @photos["groups"].each do |group|
226
+ group["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
227
+ end
228
+ end
229
+ @photos
230
+ end
231
+
232
+ # The users who have checked in here now
233
+ # @return [Hash] count and groups of users
234
+ def here_now
235
+ @here_now = response["hereNow"]
236
+ if @here_now
237
+ @here_now["groups"].each do |group|
238
+ group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
239
+ end
240
+ end
241
+ @here_now
242
+ end
243
+
244
+ # Specials available at nearby venues
245
+ # @return [Array<Foursquared::Response::Special>]
246
+ def specials_nearby
247
+ response["specialsNearby"].map{|special| Foursquared::Response::Special.new(client, special)} if response["specialsNearby"]
248
+ end
249
+
250
+ end
251
+ end
252
+ end
@@ -0,0 +1,28 @@
1
+ module Foursquared
2
+ # Settings module
3
+ module Settings
4
+
5
+ # Return the value for the setting with given ID
6
+ # @param [String] setting_id ID of the setting
7
+ # @return [Hash] ex: {"value" => "true"}
8
+ def setting setting_id
9
+ response = get("/settings/#{setting_id}")["response"]
10
+ response
11
+ end
12
+
13
+ # Returns all settings for the user
14
+ # @return [Hash]
15
+ def all_settings
16
+ response = get("/settings/all")["response"]["settings"]
17
+ end
18
+
19
+ # Set the value for a setting
20
+ # @param [String] setting_id ID of the setting
21
+ # @param [Hash] options
22
+ # @option options [Integer] :value 1 for true or 0 for false
23
+ # @return [Hash] With a confirmation message
24
+ def set_setting setting_id, options={}
25
+ response = post("/settings/#{setting_id}/set",options)["response"]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ module Foursquared
2
+ # Specials module
3
+ module Specials
4
+ # Gives details about a special
5
+ # @param [String] special_id required ID of special to retrieve
6
+ # @param [Hash] options
7
+ # @option options [String] :venueId required ID of a venue the special is running at
8
+ # @option options [String] :userId ID of the user to check whether the special is unlocked for. Only available if the current user is the manager of the venue. If not provided, checks wher the special is unlocked for the current user.
9
+ # @return [Foursquared::Response::Special]
10
+ def special special_id, options={}
11
+ response = get("/specials/#{special_id}")["response"]
12
+ @special = Foursquared::Response::Special.new(self, response["special"])
13
+ end
14
+
15
+ # Flag a Special
16
+ # @param [String] special_id required ID of special to flag
17
+ # @param [Hash] options
18
+ # @option option [String] :venueId required The id of the venue running the special.
19
+ # @option option [String] :problem required One of not_redeemable, not_valuable, other.
20
+ # @option option [String] :text Additional text about why the user has flagged this special
21
+ def flag_special special_id, options={}
22
+ response = post("/specials/#{special_id}/flag", options)["response"]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,113 @@
1
+ module Foursquared
2
+ # Tips module
3
+ module Tips
4
+ # Tip detail
5
+ # @param [String] tip_id required, ID of tip to retrieve.
6
+ # @return [Foursquared::Response::Tip] A complete tip.
7
+ def tip tip_id
8
+ response = get("/tips/#{tip_id}")["response"]
9
+ Foursquared::Response::Tip.new(self, response["tip"])
10
+ end
11
+
12
+ # Add a tip
13
+ # @param [Hash] options
14
+ # @option options [String] :venueId required, the venue where you want to add this tip.
15
+ # @option options [String] :text required, the text of the tip, up to 200 characters.
16
+ # @option options [String] :url A URL related to this tip.
17
+ # @option options [String] :broadcast eg: twitter,facebook
18
+ # @return [Foursquared::Response::Tip] The newly added tip
19
+ def add_tip options={}
20
+ response = post("/tips/add", options)["response"]
21
+ Foursquared::Response::Tip.new(self, response["tip"])
22
+ end
23
+
24
+ # Search Nearby Tips
25
+ # @param [Hash] options
26
+ # @option options [String] :ll required, unless near is provided. Latitude and longitude of the user's location.
27
+ # @option options [String] :near required, unless ll is provided. A string naming a place in the world
28
+ # @option options [Integer] :limit optional, number of results to return, up to 500.
29
+ # @option options [Integer] :offset optional, used to page through results.
30
+ # @option options [String] :filter if set to friends, only show nearby tips from friends.
31
+ # @option options [String] :query only find tips matching the given term, cannot be used in conjunction with friends filter.
32
+ # @return [Array] tips matching the criteria
33
+ def search_tips options={}
34
+ response = get("/tips/search", options)["response"]
35
+ @tips = response["tips"]
36
+ @tips.collect{|tip| Foursquared::Response::Tip.new(self, tip)}
37
+ end
38
+
39
+ # Users who have done a tip
40
+ # @param [String] tip_id required, ID of tip.
41
+ # @param [Hash] options
42
+ # @option options [Integer] :limit optional, number of results to return, up to 200.
43
+ # @option options [Integer] :offset optional, used to page through results.
44
+ # @return A count and items of compact user objects
45
+ def tip_dones tip_id, options={}
46
+ response = get("/tips/#{tip_id}/done", options)["response"]
47
+ @users = response["users"]
48
+ @users["items"].map!{|item| Foursquared::Response::User.new(self, item)} if @users["items"]
49
+ @users
50
+ end
51
+
52
+ # Users who have liked a tip
53
+ # @param [String] tip_id required, ID of tip.
54
+ # @return [Hash] A count and groups of users who like this tip
55
+ def tip_likes tip_id
56
+ response = get("/tips/#{tip_id}/likes")["response"]
57
+ @likes = response["likes"]
58
+ @likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"]
59
+ end
60
+
61
+ # The lists that this tip appears on
62
+ # @param [String] tip_id required, ID of tip.
63
+ # @return [Hash]
64
+ def tip_listed tip_id, options={}
65
+ response = get("/tips/#{tip_id}/listed")["response"]
66
+ @lists = response["lists"]
67
+ if @lists["groups"]
68
+ @lists["groups"].each do |group|
69
+ group["items"].map!{|item| Foursquared::Response::List.new(client, item) } if group["items"]
70
+ end
71
+ elsif @lists["items"]
72
+ @lists["items"].map!{|item| Foursquared::Response::List.new(client, item) }
73
+ end
74
+ end
75
+
76
+ # Like or unlike a tip
77
+ # @param [String] tip_id required, ID of tip.
78
+ # @param [Hash] options
79
+ # @option options [Integer] :set If 1, like this tip. If 0 unlike (un-do a previous like) it. Default value is 1
80
+ # @return [Hash] Updated count and groups of users who like this tip.
81
+ def like_tip tip_id, options={}
82
+ response = post("/tips/#{tip_id}/like", options)["response"]
83
+ @likes = response["likes"]
84
+ @likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"]
85
+ @likes
86
+ end
87
+
88
+ # Mark a tip done
89
+ # @param [String] tip_id required, ID of tip.
90
+ # @return [Foursquared::Response::Tip] The marked to-do.
91
+ def mark_tip_done tip_id
92
+ response = post("/tips/#{tip_id}/markdone")["response"]
93
+ Foursquared::Response::Tip.new(self, response["tip"])
94
+ end
95
+
96
+ # Mark a tip to-do
97
+ # @param [String] tip_id required, ID of tip.
98
+ # @return [Foursquared::Response::Todo] The marked to-do.
99
+ def mark_tip_todo tip_id
100
+ response = post("/tips/#{tip_id}/marktodo")["response"]
101
+ Foursquared::Response::Todo.new(self, response["todo"])
102
+ end
103
+
104
+ # Unmark a tip as to-do
105
+ # @param [String] tip_id required, ID of tip.
106
+ # @return [Foursquared::Response::Tip] The current tip
107
+ def unmark_tip_todo tip_id
108
+ response = post("/tips/#{tip_id}/unmark")["response"]
109
+ Foursquared::Response::Tip.new(self, response["tip"])
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,206 @@
1
+ # Foursquared Module
2
+ module Foursquared
3
+ # Users module
4
+ module Users
5
+
6
+ # Return profile information for a given user
7
+ # @param [String, Integer] user_id user's id
8
+ # @return [Foursquared::Response::User] A user.
9
+ def user user_id="self"
10
+ @user = get("/users/#{user_id}")["response"]["user"]
11
+ Foursquared::Response::User.new(self,@user)
12
+ end
13
+
14
+ # Returns the user's leaderboard.
15
+ # @param [Hash] options the optional options to be passed with the request
16
+ # @option options [Integer] :neighbors Number of friends' scores to return that are adjacent to your score, in ranked order.
17
+ # @return [Hash] the user's leaderboard.
18
+ def leaderboard options={}
19
+ @leaderboard = get("/users/leaderboard", options)["response"]["leaderboard"]
20
+ @leaderboard["items"].each do |item|
21
+ item["user"] = Foursquared::Response::User.new(self,item["user"])
22
+ end
23
+ @leaderboard
24
+ end
25
+
26
+ # Approves a pending friend request from another user.
27
+ # @param [String, Integer] user_id The request user's id
28
+ # @return [Foursquared::Response::User] the approved user
29
+ def approve_friend_request user_id
30
+ response = post("/users/#{user_id}/approve")["response"]
31
+ @user = Foursquared::Response::User.new(self,response["user"])
32
+ end
33
+
34
+ # Denies a pending friend request from another user.
35
+ # @param [String, Integer] user_id The request user's id
36
+ # @return [Foursquared::Response::User] the denied user
37
+ def deny_friend_request user_id
38
+ response = post("/users/#{user_id}/deny")["response"]
39
+ @user = Foursquared::Response::User.new(self,response["user"])
40
+ end
41
+
42
+ # Send a Friend/Follow Request
43
+ # @param [String, Integer] user_id The request user's/page's id
44
+ # @return [Foursquared::Response::User] the pending user
45
+ def send_friend_request user_id
46
+ response = post("/users/#{user_id}/request")["response"]
47
+ @user = Foursquared::Response::User.new(self,response["user"])
48
+ end
49
+
50
+ # Removes a friend, unfollows a celebrity, or cancels a pending friend request.
51
+ # @param [String, Integer] user_id The request user's id
52
+ # @return [Foursquared::Response::User] the removed user
53
+ def unfriend user_id
54
+ response = post("/users/#{user_id}/unfriend")["response"]
55
+ @user = Foursquared::Response::User.new(self,response["user"])
56
+ end
57
+
58
+ # Pending friend requests
59
+ # @return [Array] User objects
60
+ def requests
61
+ response = get("/users/requests")["response"]
62
+ @requests = response["requests"].collect{|request| Foursquared::Response::User.new(self,request)}
63
+ end
64
+
65
+ # Find users
66
+ # @param [Hash] options
67
+ # @option options [String] :phone A comma-delimited list of phone numbers to look for.
68
+ # @option options [String] :email A comma-delimited list of email addresses to look for.
69
+ # @option options [String] :twitter A comma-delimited list of Twitter handles to look for.
70
+ # @option options [String] :twitterSource A single Twitter handle. Results will be users that this handle follows on Twitter who use Foursquare.
71
+ # @option options [String] :fbid A comma-delimited list of Facebook ID's to look for.
72
+ # @option options [String] :name A single string to search for in users' names.
73
+ # @return [Hash]
74
+ def search options={}
75
+ response = get("/users/search", options)["response"]
76
+ response["results"].map!{|result| Foursquared::Response::User.new(self,result)}
77
+ response
78
+ end
79
+
80
+ # Set whether to receive pings about a user
81
+ # @param [String, Integer] user_id User ID of a friend
82
+ # @param [Hash] options
83
+ # @option options [Boolean] :value True or false.
84
+ # @return [Foursquared::Response::User] User object for the user
85
+ def set_pings user_id, options={}
86
+ response = post("/users/#{user_id}/setpings", options)["response"]
87
+ @user = Foursquared::Response::User.new(self,response["user"])
88
+ end
89
+
90
+ # Update user's photo
91
+ # @param [String] image_filename The location of the photo to be uploaded
92
+ # @return [Foursquared::Response::User] User object for the user
93
+ def update_photo image_filename
94
+ response = post("/users/self/update", options={:photo => File.read(image_filename)})["response"]
95
+ @user = Foursquared::Response::User.new(self, response["user"])
96
+ end
97
+
98
+ # Checkins by a user
99
+ # @param [String, Integer] user_id
100
+ # @param [Hash] options
101
+ # @option options [Integer] :limit Number of results to return, up to 250.
102
+ # @option options [Integer] :offset The number of results to skip. Used to page through results.
103
+ # @option options [String] :sort How to sort the returned checkins. Can be "newestfirst" or "oldestfirst".
104
+ # @option options [Integer] :afterTimestamp Retrieve the first results to follow these seconds since epoch
105
+ # @option options [Integer] :beforeTimestamp Retrieve the first results prior to these seconds since epoch
106
+ # @return [Hash] A count and items of check-ins.
107
+ def user_checkins user_id="self", options={}
108
+ response = get("/users/#{user_id}/checkins",options)["response"]["checkins"]
109
+ response["items"].map!{|checkin| Foursquared::Response::Checkin.new(self, checkin)} if response["items"]
110
+ response
111
+ end
112
+
113
+ # List friends
114
+ # @param [String, Integer] user_id
115
+ # @param [Hash] options
116
+ # @option options [Integer] :limit Number of results to return, up to 500.
117
+ # @option options [Integer] :offset Used to page through results.
118
+ # @return [Hash] A count and items of friends.
119
+ def user_friends user_id="self", options={}
120
+ response = get("/users/#{user_id}/friends"), options["response"]["friends"]
121
+ response["items"].map!{|friend| Foursquared::Response::User.new(self, friend)} if response["items"]
122
+ response
123
+ end
124
+
125
+ # Return the user's lists
126
+ # @param [String, Integer] user_id
127
+ # @param [Hash] options
128
+ # @option options [String] :group "edited", "created", "followed", "friends" or "suggested"
129
+ # @option options [String] :ll Location of the user eg: 40.7,-74
130
+ # @return [Hash]
131
+ def user_lists user_id="self", options={}
132
+ response = get("/users/#{user_id}/lists", options)["response"]
133
+ @lists = response["lists"]
134
+ @lists["groups"].each do |group|
135
+ group["items"].map!{|item| Foursquared::Response::List.new(self, item)}
136
+ end
137
+ @lists
138
+ end
139
+
140
+ # List user's mayorships
141
+ # @param [String, Integer] user_id
142
+ # @return [Hash]
143
+ def user_mayorships user_id="self"
144
+ response = get("/users/#{user_id}/mayorships")["response"]
145
+ @mayorships = response["mayorships"]
146
+ @mayorships["items"].each{|item| item["venue"] = Foursquared::Response::Venue.new(self, item["venue"])}
147
+ @mayorships
148
+ end
149
+
150
+ # Photos from a User
151
+ # @param [String, Integer] user_id
152
+ # @param [Hash] options
153
+ # @option options [Integer] :limit Number of results to return, up to 500.
154
+ # @option options [Integer] :offset The number of results to skip. Used to page through results.
155
+ # @return [Hash] A count and items of photos.
156
+ def user_photos user_id="self", options={}
157
+ response = get("/users/#{user_id}/photos",options)["response"]
158
+ @photos = response["photos"]
159
+ @photos["items"].map!{|item| Foursquared::Response::Photo.new(self, item)}
160
+ end
161
+
162
+ # Tips from a User
163
+ # @param [String, Integer] user_id
164
+ # @param [Hash] options
165
+ # @option options :limit Number of results to return, up to 200.
166
+ # @option options :offset The number of results to skip. Used to page through results.
167
+ # @option options :llBounds Restricts the returned results to the input bounding box.
168
+ # @option options :categoryId Restricts the returned results to venues matching the input category id.
169
+ # @return [Foursquared::Response::List]
170
+ def user_tips user_id="self", options={}
171
+ response = get("/lists/#{user_id}/tips", options)["response"]
172
+ Foursquared::Response::List.new(self, response["list"])
173
+ end
174
+
175
+ # Todos from a User
176
+ # @param [String, Integer] user_id
177
+ # @param [Hash] options
178
+ # @option options :limit Number of results to return, up to 200.
179
+ # @option options :offset The number of results to skip. Used to page through results.
180
+ # @option options :llBounds Restricts the returned results to the input bounding box.
181
+ # @option options :categoryId Restricts the returned results to venues matching the input category id.
182
+ # @return [Foursquared::Response::List]
183
+ def user_todos user_id="self", options={}
184
+ response = get("/lists/#{user_id}/todos", options)["response"]
185
+ Foursquared::Response::List.new(self, response["list"])
186
+ end
187
+
188
+ # Badges for a user
189
+ # @param [String, Integer] user_id
190
+ # @return [Hash]
191
+ def user_badges user_id="self"
192
+ response = get("/users/#{user_id}/badges")["response"]
193
+ if response["sets"] and response["sets"]["groups"]
194
+ response["sets"]["groups"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)}
195
+ end
196
+
197
+ if response["badges"]
198
+ response["badges"].each_key do |badge_id|
199
+ response["badges"][badge_id] = badge(badge_id)
200
+ end
201
+ end
202
+ response
203
+ end
204
+
205
+ end
206
+ end