foursquared 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/Gemfile +19 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +30 -0
- data/foursquared.gemspec +34 -0
- data/lib/core_ext/symbol.rb +7 -0
- data/lib/foursquared/badges.rb +12 -0
- data/lib/foursquared/checkins.rb +89 -0
- data/lib/foursquared/client.rb +58 -0
- data/lib/foursquared/error.rb +17 -0
- data/lib/foursquared/events.rb +18 -0
- data/lib/foursquared/lists.rb +97 -0
- data/lib/foursquared/oauth/client.rb +37 -0
- data/lib/foursquared/pages.rb +49 -0
- data/lib/foursquared/photos.rb +34 -0
- data/lib/foursquared/response/badge.rb +87 -0
- data/lib/foursquared/response/badge_group.rb +42 -0
- data/lib/foursquared/response/category.rb +53 -0
- data/lib/foursquared/response/checkin.rb +180 -0
- data/lib/foursquared/response/event.rb +52 -0
- data/lib/foursquared/response/list.rb +199 -0
- data/lib/foursquared/response/list_item.rb +63 -0
- data/lib/foursquared/response/photo.rb +102 -0
- data/lib/foursquared/response/special.rb +131 -0
- data/lib/foursquared/response/tip.rb +134 -0
- data/lib/foursquared/response/user.rb +246 -0
- data/lib/foursquared/response/venue.rb +252 -0
- data/lib/foursquared/settings.rb +28 -0
- data/lib/foursquared/specials.rb +25 -0
- data/lib/foursquared/tips.rb +113 -0
- data/lib/foursquared/users.rb +206 -0
- data/lib/foursquared/venues.rb +217 -0
- data/lib/foursquared/version.rb +4 -0
- data/lib/foursquared.rb +47 -0
- data/spec/foursquared/badges_spec.rb +82 -0
- data/spec/foursquared/checkins_spec.rb +0 -0
- data/spec/foursquared/events_spec.rb +50 -0
- data/spec/foursquared/oauth/client_spec.rb +24 -0
- data/spec/foursquared/pages_spec.rb +42 -0
- data/spec/foursquared/photos_spec.rb +41 -0
- data/spec/foursquared/response/badge_spec.rb +40 -0
- data/spec/foursquared/response/category_spec.rb +48 -0
- data/spec/foursquared/response/checkin_spec.rb +100 -0
- data/spec/foursquared/response/event_category_spec.rb +48 -0
- data/spec/foursquared/response/event_spec.rb +60 -0
- data/spec/foursquared/response/list_spec.rb +56 -0
- data/spec/foursquared/response/photo_spec.rb +70 -0
- data/spec/foursquared/response/special_spec.rb +0 -0
- data/spec/foursquared/response/user_spec.rb +124 -0
- data/spec/foursquared/response/venue_spec.rb +83 -0
- data/spec/foursquared/specials_spec.rb +4 -0
- data/spec/foursquared/users_spec.rb +241 -0
- data/spec/spec_helper.rb +27 -0
- metadata +344 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Badge response
|
4
|
+
class Badge
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize client, response
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# The badge's id
|
12
|
+
# @return [String]
|
13
|
+
def id
|
14
|
+
response["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Canonical id of the badge
|
18
|
+
# @return [String]
|
19
|
+
def badge_id
|
20
|
+
response["badgeId"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# The name of the badge
|
24
|
+
# @return [String]
|
25
|
+
def name
|
26
|
+
response["name"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# The currently unlocked level
|
30
|
+
# @return [Integer]
|
31
|
+
def level
|
32
|
+
response["level"]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Text about the level unlocked
|
36
|
+
# @return [String]
|
37
|
+
def level_text
|
38
|
+
response["responseText"]
|
39
|
+
end
|
40
|
+
|
41
|
+
# The message to be shown when user unlocks the badge
|
42
|
+
# @return [String]
|
43
|
+
def unlock_message
|
44
|
+
response["unlockMessage"]
|
45
|
+
end
|
46
|
+
|
47
|
+
# The badge description
|
48
|
+
# @return [String]
|
49
|
+
def description
|
50
|
+
response["description"]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Text for the badge
|
54
|
+
# @return [String]
|
55
|
+
def badge_text
|
56
|
+
response["badgeText"]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Hint about the badge
|
60
|
+
# @return [String]
|
61
|
+
def hint
|
62
|
+
response["hint"]
|
63
|
+
end
|
64
|
+
|
65
|
+
# The badge image details
|
66
|
+
# @return [Hash]
|
67
|
+
def image
|
68
|
+
response["image"]
|
69
|
+
end
|
70
|
+
|
71
|
+
# An array of unlock data
|
72
|
+
# @return [Array]
|
73
|
+
def unlocks
|
74
|
+
@unlocks = response["unlocks"]
|
75
|
+
if @unlocks
|
76
|
+
@unlocks.each do |unlock|
|
77
|
+
if unlock["checkins"]
|
78
|
+
unlock["checkins"].map!{|checkin| Foursquared::Response::Checkin.new(client, checkin)}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
@unlocks
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Badge group response
|
4
|
+
class BadgeGroup
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize client, response
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# The type of badge group
|
12
|
+
# @return [String]
|
13
|
+
def type
|
14
|
+
response["type"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Name of the badge group
|
18
|
+
# @return [String]
|
19
|
+
def name
|
20
|
+
response["name"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Image for the badge group
|
24
|
+
# @return [Hash]
|
25
|
+
def image
|
26
|
+
response["image"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# Array of IDs of badges present in the group
|
30
|
+
# @return [Array<String>]
|
31
|
+
def items
|
32
|
+
response["items"]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sub groups of the group
|
36
|
+
# @return [Array<Foursquared::Response::BadgeGroup>]
|
37
|
+
def groups
|
38
|
+
response["groups"].map!{|group| Foursquared::Response::BadgeGroup.new(client, group)}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Category object
|
4
|
+
class Category
|
5
|
+
attr_reader :response
|
6
|
+
def initialize response
|
7
|
+
@response = response
|
8
|
+
end
|
9
|
+
|
10
|
+
# Return the id of the category
|
11
|
+
# @return [String]
|
12
|
+
def id
|
13
|
+
response["id"]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return the name of the category
|
17
|
+
# @return [String]
|
18
|
+
def name
|
19
|
+
response["name"]
|
20
|
+
end
|
21
|
+
|
22
|
+
# Return the plural name of the category
|
23
|
+
# @return [String]
|
24
|
+
def plural_name
|
25
|
+
response["pluralName"]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return the short name of the category
|
29
|
+
# @return [String]
|
30
|
+
def short_name
|
31
|
+
response["shortName"]
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return the details for icons of the category
|
35
|
+
# @return [Hash] with urls added for each icon size
|
36
|
+
def icon
|
37
|
+
@icon = response["icon"]
|
38
|
+
@icon["urls"] = {
|
39
|
+
"32x32" => "#{@icon["prefix"].chomp("_")}#{@icon["suffix"]}",
|
40
|
+
"64x64" => "#{@icon["prefix"]}_64#{@icon["suffix"]}",
|
41
|
+
"256x256" => "#{@icon["prefix"]}_256#{@icon["suffix"]}",
|
42
|
+
}
|
43
|
+
@icon
|
44
|
+
end
|
45
|
+
|
46
|
+
# The sub-categories for the category
|
47
|
+
# @return [Array] array of sub-categories
|
48
|
+
def categories
|
49
|
+
response["categories"].map!{|category| Foursquared::Response::Category.new(category)}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Checkin response
|
4
|
+
class Checkin
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize client, response
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# ID of the checkin
|
12
|
+
# @return [String]
|
13
|
+
def id
|
14
|
+
response["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# The time at which the checkin was created
|
18
|
+
# @return [Time]
|
19
|
+
def created_at
|
20
|
+
Time.at(response["createdAt"]) if response["createdAt"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# One of checkin, shout, or venueless.
|
24
|
+
# @return [String]
|
25
|
+
def type
|
26
|
+
response["type"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# If present, it indicates the checkin was marked as private and not sent to friends
|
30
|
+
def private
|
31
|
+
response["private"]
|
32
|
+
end
|
33
|
+
|
34
|
+
# If the user is not clear from context, then a compact user is present
|
35
|
+
# @return [Foursquared::Response::User]
|
36
|
+
def user
|
37
|
+
Foursquared::Response::User.new(client, response["user"]) if response["user"]
|
38
|
+
end
|
39
|
+
|
40
|
+
# The current location of the user
|
41
|
+
# @return [Hash]
|
42
|
+
def location
|
43
|
+
response["location"]
|
44
|
+
end
|
45
|
+
|
46
|
+
# Optional count and items of checkins from friends checked into the same venue around the same time.
|
47
|
+
# @return [Hash]
|
48
|
+
def overlaps
|
49
|
+
@overlaps = response["overlaps"]
|
50
|
+
@overlaps["items"].map!{|item| Foursquared::Response::Checkin.new(client, item)} if @overlaps
|
51
|
+
@overlaps
|
52
|
+
end
|
53
|
+
|
54
|
+
# Count and items for comments on this checkin.
|
55
|
+
# @return [Hash]
|
56
|
+
def comments
|
57
|
+
response["comments"]
|
58
|
+
end
|
59
|
+
|
60
|
+
# Full list of comments for this checkin
|
61
|
+
# @return [Hash]
|
62
|
+
def full_comments
|
63
|
+
client.get("/checkin/#{id}/comments")["comments"]
|
64
|
+
end
|
65
|
+
|
66
|
+
# Message from check-in, if present and visible to the acting user.
|
67
|
+
# @return [String]
|
68
|
+
def shout
|
69
|
+
response["shout"]
|
70
|
+
end
|
71
|
+
|
72
|
+
# If present, the name and url for the application that created this checkin.
|
73
|
+
# @return [Hash]
|
74
|
+
def source
|
75
|
+
response["source"]
|
76
|
+
end
|
77
|
+
|
78
|
+
# Total and scores for this checkin
|
79
|
+
# @return [Hash]
|
80
|
+
def score
|
81
|
+
response["score"]
|
82
|
+
end
|
83
|
+
|
84
|
+
# Whether the acting user likes the checkin
|
85
|
+
# @return [Boolean]
|
86
|
+
def like?
|
87
|
+
response["like"]
|
88
|
+
end
|
89
|
+
|
90
|
+
# String representation of the time zone where this check-in occurred.
|
91
|
+
# @return [String]
|
92
|
+
def time_zone_offset
|
93
|
+
response["timeZoneOffset"]
|
94
|
+
end
|
95
|
+
|
96
|
+
# The venue of checkin
|
97
|
+
# @return [Foursquared::Response::Venue]
|
98
|
+
def venue
|
99
|
+
Foursquared::Response::Venue.new(client, response["venue"])
|
100
|
+
end
|
101
|
+
|
102
|
+
# Count and items for photos on this checkin
|
103
|
+
# @return [Hash]
|
104
|
+
def photos
|
105
|
+
@photos = response["photos"]
|
106
|
+
@photos["photos"]["items"].map!{|item| Foursquared::Response::Photo.new(client, item)} if response["photos"]
|
107
|
+
@photos
|
108
|
+
end
|
109
|
+
|
110
|
+
# Groups of users who have liked the checkin
|
111
|
+
# @return [Hash]
|
112
|
+
def likes
|
113
|
+
@likes = response["likes"]
|
114
|
+
@likes["groups"].each do |group|
|
115
|
+
group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
116
|
+
end
|
117
|
+
@likes
|
118
|
+
end
|
119
|
+
|
120
|
+
# The full groups of users who have liked the checkin
|
121
|
+
# @return [Hash]
|
122
|
+
def full_likes
|
123
|
+
@likes = client.get("/checkins/#{id}/likes")["response"]["likes"]
|
124
|
+
@likes["groups"].each do |group|
|
125
|
+
group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
126
|
+
end
|
127
|
+
@likes
|
128
|
+
end
|
129
|
+
|
130
|
+
# The count and items of photos associated with the checkin
|
131
|
+
# @return [Hash]
|
132
|
+
def photos
|
133
|
+
@photos = response["photos"]
|
134
|
+
@photos["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
|
135
|
+
@photos
|
136
|
+
end
|
137
|
+
|
138
|
+
# The count and items of all the photos associated with the checkin
|
139
|
+
# @return [Hash]
|
140
|
+
def full_photos
|
141
|
+
resp = get("/checkins/#{id}/photos")
|
142
|
+
@photos = resp["photos"]
|
143
|
+
@photos["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
|
144
|
+
@photos
|
145
|
+
end
|
146
|
+
|
147
|
+
# Add a comment to a check-in
|
148
|
+
# @param [Hash] options
|
149
|
+
# @option options [String] :text The text of the comment, up to 200 characters.
|
150
|
+
# @option options [String] :mentions Mentions in your check-in.
|
151
|
+
def add_comment options={}
|
152
|
+
response = post("/checkins/#{id}/addcomment", options)["response"]
|
153
|
+
@comment = response["comment"]
|
154
|
+
@comment["user"] = Foursquared::Response::User.new(client, @comment["user"])
|
155
|
+
@comment
|
156
|
+
end
|
157
|
+
|
158
|
+
# Remove commment from check-in
|
159
|
+
# @param [Hash] options
|
160
|
+
# @option options [String] :commentId The ID of the checkin to remove a comment from.
|
161
|
+
# @return [Foursquared::Response::Checkin] The checkin, minus this comment.
|
162
|
+
def delete_comment options={}
|
163
|
+
response = post("/checkins/#{id}/deletecomment", options)["response"]
|
164
|
+
@checkin = Foursquared::Response::Checkin.new(client, response["checkin"])
|
165
|
+
end
|
166
|
+
|
167
|
+
# Like or unlike a checkin
|
168
|
+
# @param [Hash] options
|
169
|
+
# @option options [Integer] :set If 1, like this checkin. If 0 unlike (un-do a previous like) it. Default value is 1.
|
170
|
+
def like options={}
|
171
|
+
response = post("/checkins/#{id}/like", options)["response"]["likes"]
|
172
|
+
response["groups"].each do |group|
|
173
|
+
group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
174
|
+
end
|
175
|
+
response
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Event response
|
4
|
+
class Event
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize client, response
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
[:id, :name, :url, :stats].each do |method_name|
|
12
|
+
define_method method_name do
|
13
|
+
response[method_name.to_s] if response
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
[:venueId, :foreignIds, :categories, :allDay, :timeZone, :unlockMessage].each do |method_name|
|
18
|
+
define_method method_name.to_usym do
|
19
|
+
response[method_name.to_s] if response[method_name.to_s]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# The time at which the event starts
|
24
|
+
# @return [Time]
|
25
|
+
def start_at
|
26
|
+
Time.at response["startAt"] if response["startAt"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# The time at which the event ends
|
30
|
+
# @return [Time]
|
31
|
+
def end_at
|
32
|
+
Time.at response["endAt"] if response["endAt"]
|
33
|
+
end
|
34
|
+
|
35
|
+
# The date at which the event is happening
|
36
|
+
# @return [Time]
|
37
|
+
def date
|
38
|
+
Time.at response["date"] if response["date"]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Users who are present at the event now
|
42
|
+
# @return [Hash]
|
43
|
+
def here_now
|
44
|
+
@here_now = response["hereNow"]
|
45
|
+
@here_now["groups"].each do |group|
|
46
|
+
group["items"].map!{|user| Foursquared::Response::User.new(client, user)}
|
47
|
+
end
|
48
|
+
@here_now
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# List response
|
4
|
+
class List
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize client, response
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# Id of the list
|
12
|
+
# @return [String]
|
13
|
+
def id
|
14
|
+
response["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Name of the list
|
18
|
+
# @return [String]
|
19
|
+
def name
|
20
|
+
response["name"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# The list description
|
24
|
+
# @return [String]
|
25
|
+
def description
|
26
|
+
response["description"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# The type of list
|
30
|
+
# @return [String]
|
31
|
+
def type
|
32
|
+
response["type"]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Whether the list is editable by the acting user
|
36
|
+
# @return [Boolean]
|
37
|
+
def editable?
|
38
|
+
response["editable"]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Whether the list is public
|
42
|
+
# @return [Boolean]
|
43
|
+
def public?
|
44
|
+
response["public"]
|
45
|
+
end
|
46
|
+
|
47
|
+
# Whether this list is editable by the owner's friends
|
48
|
+
# @return [Boolean]
|
49
|
+
def collaborative?
|
50
|
+
response["collaborative"]
|
51
|
+
end
|
52
|
+
|
53
|
+
# The list url
|
54
|
+
# @return [String]
|
55
|
+
def url
|
56
|
+
response["url"]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Whether the acting user is following this list
|
60
|
+
# @return [Boolean]
|
61
|
+
def following?
|
62
|
+
response["following"]
|
63
|
+
end
|
64
|
+
|
65
|
+
# The canonical URL for this list
|
66
|
+
# @return [String]
|
67
|
+
def canonical_url
|
68
|
+
response["canonicalUrl"]
|
69
|
+
end
|
70
|
+
|
71
|
+
# The number of venues on the list visited by the acting user
|
72
|
+
# @return [Integer]
|
73
|
+
def visited_count
|
74
|
+
response["visitedCount"]
|
75
|
+
end
|
76
|
+
|
77
|
+
# The number of unique venues on the list.
|
78
|
+
# @return [Integer]
|
79
|
+
def venue_count
|
80
|
+
response["venueCount"]
|
81
|
+
end
|
82
|
+
|
83
|
+
# The time at which the list was created
|
84
|
+
# @return [Time]
|
85
|
+
def created_at
|
86
|
+
Time.at(response["createdAt"]) if response["createdAt"]
|
87
|
+
end
|
88
|
+
|
89
|
+
# The time at which the list was last updated
|
90
|
+
# @return [Time]
|
91
|
+
def updated_at
|
92
|
+
Time.at(response["updatedAt"]) if response["updatedAt"]
|
93
|
+
end
|
94
|
+
|
95
|
+
# The user who created the list
|
96
|
+
# @return [Foursquared::Response::User]
|
97
|
+
def user
|
98
|
+
Foursquared::Response::User.new(client, response["user"]) if response["user"]
|
99
|
+
end
|
100
|
+
|
101
|
+
# Photo for the list
|
102
|
+
# @return [Foursquared::Response::Photo]
|
103
|
+
def photo
|
104
|
+
Foursquared::Response::Photo.new(client, response["photo"]) if response["photo"]
|
105
|
+
end
|
106
|
+
|
107
|
+
# Count and items of list items on this list.
|
108
|
+
# @return [Hash]
|
109
|
+
def list_items
|
110
|
+
@list_items = response["listItems"]
|
111
|
+
if @list_items and @list_items["items"]
|
112
|
+
@list_items["items"].map!{|item| Foursquared::Response::ListItem.new(client, item)}
|
113
|
+
end
|
114
|
+
@list_items
|
115
|
+
end
|
116
|
+
|
117
|
+
# Suggests photos that may be appropriate for this item.
|
118
|
+
# @param [Hash] options
|
119
|
+
# @option options [String] :itemId required, The ID of the list item
|
120
|
+
# @return [Hash] Groups user and others containing lists (a count and items of photos) of photos uploaded by this user and uploaded by other users.
|
121
|
+
def suggest_photo options={}
|
122
|
+
@photos = client.get("/lists/#{id}/suggestphoto", options)["response"]["photos"]
|
123
|
+
if @photos
|
124
|
+
@photos.each_key do |key|
|
125
|
+
key["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
@photos
|
129
|
+
end
|
130
|
+
# Suggests venues that may be appropriate for this list.
|
131
|
+
# @return [Array] Compact venues that may be appropriate for this list.
|
132
|
+
def suggest_venues
|
133
|
+
@suggested_venues = client.get("/lists/#{id}/suggestvenues")["response"]["suggestedVenues"]
|
134
|
+
@suggested_venues.each do |item|
|
135
|
+
item["venue"] = Foursquared::Response::Venue.new(client, item["venue"])
|
136
|
+
end
|
137
|
+
@suggested_venues
|
138
|
+
end
|
139
|
+
|
140
|
+
# Suggests tips that may be appropriate for a list item
|
141
|
+
# @param [Hash] options
|
142
|
+
# @option options [String] :itemId required, The ID of the list item
|
143
|
+
def suggest_tip options={}
|
144
|
+
@tips = client.get("/lists/#{id}/suggesttip", options)["response"]["tips"]
|
145
|
+
if @tips
|
146
|
+
@tips.each_key do |key|
|
147
|
+
key["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
@tips
|
151
|
+
end
|
152
|
+
|
153
|
+
# Add an Item to the list
|
154
|
+
# @param [Hash] options
|
155
|
+
# @option options [String] :venueId A venue to add to the list
|
156
|
+
# @option options [String] :text If the target is a user-created list, this will create a public tip on the venue. If the target is /userid/todos, the text will be a private note that is only visible to the author.
|
157
|
+
# @option options [String] :url If adding a new tip via text, this can associate a url with the tip.
|
158
|
+
# @option options [String] :tipId Used to add a tip to a list. Cannot be used in conjunction with the text and url fields.
|
159
|
+
# @option options [String] :tipId Used to add a tip to a list. Cannot be used in conjunction with the text and url fields.
|
160
|
+
# @option options [String] :listId Used in conjuction with itemId, the id for a user created or followed list as well as one of USER_ID/tips, USER_ID/todos, or USER_ID/dones.
|
161
|
+
# @option options [String] :itemId Used in conjuction with listId, the id of an item on that list that we wish to copy to this list.
|
162
|
+
# @return [Foursquared::Response::ListItem] The newly added list item
|
163
|
+
def add_item options={}
|
164
|
+
@item = client.post("/lists/#{id}/additem", options)["response"]["item"]
|
165
|
+
Foursquared::Response::ListItem.new(client, @item) if @item
|
166
|
+
end
|
167
|
+
|
168
|
+
# List Followers
|
169
|
+
# @return [Hash] A count and items of users following this list.
|
170
|
+
def followers
|
171
|
+
@followers = client.get("/lists/#{id}/followers")["response"]["followers"]
|
172
|
+
if @followers and @followers["items"]
|
173
|
+
@followers["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
174
|
+
end
|
175
|
+
@followers
|
176
|
+
end
|
177
|
+
|
178
|
+
# Delete an item from the list
|
179
|
+
# @param [Hash] options
|
180
|
+
# @option options [String] :venueId ID of a venue to be deleted.
|
181
|
+
# @option options [String] :itemId ID of the item to delete.
|
182
|
+
# @option options [String] :tipId id of a tip to be deleted.
|
183
|
+
# @return [Hash] A count and items of list items that were just deleted.
|
184
|
+
def delete_item options={}
|
185
|
+
@items = client.post("/lists/#{id}/deleteitem", options)["response"]["items"]
|
186
|
+
@items["items"].map!{|item| Foursquared::Response::ListItem.new(client, item)}
|
187
|
+
@list_items
|
188
|
+
end
|
189
|
+
|
190
|
+
# Count and items of users who have edited this list
|
191
|
+
# @return [Hash]
|
192
|
+
def collaborators
|
193
|
+
@collaborators = response["collaborators"]
|
194
|
+
@collaborators["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
195
|
+
@collaborators
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# List item response
|
4
|
+
class ListItem
|
5
|
+
attr_reader :client, :response
|
6
|
+
|
7
|
+
def initialize client, response
|
8
|
+
@client = client
|
9
|
+
@response = response
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# ID of the list item
|
14
|
+
# @return [String]
|
15
|
+
def id
|
16
|
+
response["id"]
|
17
|
+
end
|
18
|
+
|
19
|
+
# The time at which the list item was created
|
20
|
+
# @return [Time]
|
21
|
+
def created_at
|
22
|
+
Time.at(response["createdAt"]) if response["createdAt"]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Tip, if present, in the list
|
26
|
+
# @return [Foursquared::Response::Tip]
|
27
|
+
def tip
|
28
|
+
Foursquared::Response::Tip.new(client, response["tip"]) if response["tip"]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Venue, if present, in the list
|
32
|
+
# @return [Foursquared::Response::Venue]
|
33
|
+
def venue
|
34
|
+
Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Text entered by the user when creating this item
|
38
|
+
# @return [String]
|
39
|
+
def note
|
40
|
+
response["note"]
|
41
|
+
end
|
42
|
+
|
43
|
+
# User who added this item to the current list
|
44
|
+
# @return [Foursquared::Response::User]
|
45
|
+
def user
|
46
|
+
Foursquared::Response::User.new(client, response["user"]) if response["user"]
|
47
|
+
end
|
48
|
+
|
49
|
+
# A photo for this list item
|
50
|
+
# @return [Foursquared::Response::Photo]
|
51
|
+
def photo
|
52
|
+
Foursquared::Response::Photo.new(client, response["photo"]) if response["photo"]
|
53
|
+
end
|
54
|
+
|
55
|
+
# Information about what other lists this item appears on
|
56
|
+
# @return [Array] array of compact lists
|
57
|
+
def listed
|
58
|
+
response["listed"].collect{|item| Foursquared::Response::List.new(item)} if response["listed"]
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|