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,102 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Photo response
|
4
|
+
class Photo
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize(client, response)
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# The ID of the photo
|
12
|
+
# @return [String]
|
13
|
+
def id
|
14
|
+
response["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# The time at which the photo was created
|
18
|
+
# @return [Time]
|
19
|
+
def created_at
|
20
|
+
Time.at(response["createdAt"]) if response["createdAt"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# The name and url for the application that created this photo.
|
24
|
+
def source
|
25
|
+
response["source"]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Start of the URL for this photo.
|
29
|
+
# @return [String]
|
30
|
+
def prefix
|
31
|
+
response["prefix"]
|
32
|
+
end
|
33
|
+
|
34
|
+
# End of the URL for this photo.
|
35
|
+
# @return [String]
|
36
|
+
def suffix
|
37
|
+
response["suffix"]
|
38
|
+
end
|
39
|
+
|
40
|
+
# The user to which the photo belongs
|
41
|
+
# @return [Foursquared::Response::User]
|
42
|
+
def user
|
43
|
+
Foursquared::Response::User.new(client, response["user"]) if response["user"]
|
44
|
+
end
|
45
|
+
|
46
|
+
# URLs for each photo size
|
47
|
+
# @return [Hash]
|
48
|
+
def urls
|
49
|
+
@urls = {
|
50
|
+
"36x36" => url(36,36),
|
51
|
+
"100x100" => url(100,100),
|
52
|
+
"300x300" => url(300,300),
|
53
|
+
"500x500" => url(500,500)
|
54
|
+
}
|
55
|
+
@urls.merge!({"original" => url(width, height)}) if (width and height)
|
56
|
+
@urls
|
57
|
+
end
|
58
|
+
|
59
|
+
# Height of the original photo in pixels
|
60
|
+
# @return [Integer]
|
61
|
+
def height
|
62
|
+
response["height"]
|
63
|
+
end
|
64
|
+
|
65
|
+
# Width of the original photo in pixels
|
66
|
+
# @return [Integer]
|
67
|
+
def width
|
68
|
+
response["width"]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Who all can see the photo
|
72
|
+
# @return [String]
|
73
|
+
def visibility
|
74
|
+
response["visibility"]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Venue at which the photo was taken
|
78
|
+
# @return [Foursquared::Response::Venue]
|
79
|
+
def venue
|
80
|
+
Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"]
|
81
|
+
end
|
82
|
+
|
83
|
+
# Tip corresponding to the photo
|
84
|
+
# @return [Foursquared::Response::Tip]
|
85
|
+
def tip
|
86
|
+
Foursquared::Response::Tip.new(client, response["tip"]) if response["tip"]
|
87
|
+
end
|
88
|
+
|
89
|
+
# The checkin for which the photo was taken
|
90
|
+
# @return [Foursquared::Response::Checkin]
|
91
|
+
def checkin
|
92
|
+
Foursquared::Response::Checkin.new(client, response["checkin"]) if response["checkin"]
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def url width, height
|
97
|
+
"#{prefix}#{width}x#{height}#{suffix}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Special response
|
4
|
+
class Special
|
5
|
+
attr_reader :client, :response
|
6
|
+
|
7
|
+
def initialize client, response
|
8
|
+
@client = client
|
9
|
+
@response = response
|
10
|
+
end
|
11
|
+
|
12
|
+
# ID of the special
|
13
|
+
# @return [String]
|
14
|
+
def id
|
15
|
+
response["id"]
|
16
|
+
end
|
17
|
+
|
18
|
+
# A description of how to unlock the special.
|
19
|
+
# @return [String]
|
20
|
+
def description
|
21
|
+
response["description"]
|
22
|
+
end
|
23
|
+
|
24
|
+
# One of mayor, count, frequency, regular, friends, swarm, flash or other.
|
25
|
+
# @return [String]
|
26
|
+
def type
|
27
|
+
response["type"]
|
28
|
+
end
|
29
|
+
|
30
|
+
# A message describing the special.
|
31
|
+
# @return [String]
|
32
|
+
def message
|
33
|
+
response["message"]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Special's image urls
|
37
|
+
# @return [Hash]
|
38
|
+
def image_urls
|
39
|
+
response["imageUrls"]
|
40
|
+
end
|
41
|
+
|
42
|
+
# If the user has unlocked the special
|
43
|
+
# @return [Boolean]
|
44
|
+
def unlocked?
|
45
|
+
response["unlocked"]
|
46
|
+
end
|
47
|
+
|
48
|
+
# The name of the icon to use
|
49
|
+
# @return [String]
|
50
|
+
def icon
|
51
|
+
response["icon"]
|
52
|
+
end
|
53
|
+
|
54
|
+
# URL for the icon
|
55
|
+
# @return [String]
|
56
|
+
def icon_url
|
57
|
+
"http://foursquare.com/img/specials/#{icon}.png" if icon
|
58
|
+
end
|
59
|
+
|
60
|
+
# The header text describing the type of special.
|
61
|
+
# @return [String]
|
62
|
+
def title
|
63
|
+
response["title"]
|
64
|
+
end
|
65
|
+
|
66
|
+
# The state of the special
|
67
|
+
# @return [String] unlocked, before start, in progress, taken, or locked
|
68
|
+
def state
|
69
|
+
response["state"]
|
70
|
+
end
|
71
|
+
|
72
|
+
# A description of how close you are to unlocking the special
|
73
|
+
# @return [Integer] Either the number of people who have already unlocked the special (flash and swarm specials), or the number of your friends who have already checked in (friends specials)
|
74
|
+
def progress
|
75
|
+
response["progress"]
|
76
|
+
end
|
77
|
+
|
78
|
+
# A label describing what the number in the progress field means.
|
79
|
+
# @return [String]
|
80
|
+
def progress_description
|
81
|
+
response["progressDescription"]
|
82
|
+
end
|
83
|
+
|
84
|
+
# Minutes remaining until the special can be unlocked
|
85
|
+
# @return [String]
|
86
|
+
def detail
|
87
|
+
response["detail"]
|
88
|
+
end
|
89
|
+
|
90
|
+
# The provider of the special
|
91
|
+
# @return [String]
|
92
|
+
def provider
|
93
|
+
response["provider"]
|
94
|
+
end
|
95
|
+
|
96
|
+
# Type of redemption
|
97
|
+
# @return [String]
|
98
|
+
def redemption
|
99
|
+
response["redemption"]
|
100
|
+
end
|
101
|
+
|
102
|
+
# The count and urls for the images for the special
|
103
|
+
# @return [Hash]
|
104
|
+
def image_urls
|
105
|
+
response["imageUrls"]
|
106
|
+
end
|
107
|
+
|
108
|
+
# The specific rules for this special.
|
109
|
+
# @return [String]
|
110
|
+
def fine_print
|
111
|
+
response["finePrint"]
|
112
|
+
end
|
113
|
+
|
114
|
+
# Friends who are here
|
115
|
+
# @return [Array<Foursquared::Response::User>] An array of Users
|
116
|
+
def friends_here
|
117
|
+
@friends = response["friendsHere"].collect{|friend| Foursquared::Response::User.new(client, friend)}
|
118
|
+
end
|
119
|
+
|
120
|
+
# Flag the Special
|
121
|
+
# @param [Hash] options
|
122
|
+
# @option option [String] :venueId required The id of the venue running the special.
|
123
|
+
# @option option [String] :problem required One of not_redeemable, not_valuable, other.
|
124
|
+
# @option option [String] :text Additional text about why the user has flagged this special
|
125
|
+
def flag options={}
|
126
|
+
response = post("/specials/#{id}/flag", options)["response"]
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Foursquared
|
2
|
+
module Response
|
3
|
+
# Tip response class
|
4
|
+
class Tip
|
5
|
+
attr_reader :client, :response
|
6
|
+
def initialize client, response
|
7
|
+
@client = client
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
# ID of the tip
|
12
|
+
# @return [String] tip id
|
13
|
+
def id
|
14
|
+
response["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Time since creation of the tip
|
18
|
+
# @return [Time]
|
19
|
+
def created_at
|
20
|
+
Time.at(response["createdAt"]) if response["createdAt"]
|
21
|
+
end
|
22
|
+
|
23
|
+
# The actual tip
|
24
|
+
# @return [String]
|
25
|
+
def text
|
26
|
+
response["text"]
|
27
|
+
end
|
28
|
+
|
29
|
+
# The canonical url for the tip
|
30
|
+
# @return [String] url
|
31
|
+
def canonical_url
|
32
|
+
response["canonicalUrl"]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Groups of users who like the tip
|
36
|
+
# @return [Hash] count, groups and summary
|
37
|
+
def likes
|
38
|
+
@likes = response["likes"]
|
39
|
+
@likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"]
|
40
|
+
end
|
41
|
+
|
42
|
+
# Whether the acting user likes the tip
|
43
|
+
# @return [Boolean] true or false
|
44
|
+
def like?
|
45
|
+
response["like"]
|
46
|
+
end
|
47
|
+
|
48
|
+
# If the context allows tips from multiple venues, the compact venue for this tip.
|
49
|
+
# @return [Foursquared::Response::Venue]
|
50
|
+
def venue
|
51
|
+
Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"]
|
52
|
+
end
|
53
|
+
|
54
|
+
# If the context allows tips from multiple venues, the compact venue for this tip.
|
55
|
+
# @return [Foursquared::Response::User]
|
56
|
+
def user
|
57
|
+
Foursquared::Response::User.new(client, response["user"]) if response["user"]
|
58
|
+
end
|
59
|
+
|
60
|
+
# Groups of lists
|
61
|
+
# @return [Hash] count and groups of lists
|
62
|
+
def listed
|
63
|
+
@listed = response["listed"]
|
64
|
+
|
65
|
+
@listed["groups"].each{|group| group["items"].map!{|item| Foursquared::Response::List.new(client, item)}} if @listed and @listed["groups"]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Photo for this tip
|
69
|
+
# @return [Foursquared::Response::Photo]
|
70
|
+
def photo
|
71
|
+
Foursquared::Response::Photo.new(client, response["photo"]) if response["photo"]
|
72
|
+
end
|
73
|
+
|
74
|
+
# Status of this tip.
|
75
|
+
# @return [String] todo or done
|
76
|
+
def status
|
77
|
+
response["status"]
|
78
|
+
end
|
79
|
+
|
80
|
+
# A URL for more information.
|
81
|
+
# @return [String]
|
82
|
+
def url
|
83
|
+
response["url"]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Users who have marked this tip todo
|
87
|
+
# @return [Hash] count and groups of users
|
88
|
+
def todo
|
89
|
+
@todo = response["todo"]
|
90
|
+
@todo["groups"].each {|group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @todo and @todo["groups"]
|
91
|
+
end
|
92
|
+
|
93
|
+
# Users who have done this tip todo
|
94
|
+
# @return [Hash] count and groups of users
|
95
|
+
def done
|
96
|
+
@done = response["done"]
|
97
|
+
@done["groups"].each {|group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @done and @done["groups"]
|
98
|
+
end
|
99
|
+
|
100
|
+
# Like or unlike the tip
|
101
|
+
# @param [Hash] options
|
102
|
+
# @option options [Integer] :set If 1, like this tip. If 0 unlike (un-do a previous like) it. Default value is 1
|
103
|
+
# @return [Hash] Updated count and groups of users who like this tip.
|
104
|
+
def like options={}
|
105
|
+
response = post("/tips/#{id}/like", options)["response"]
|
106
|
+
@likes = response["likes"]
|
107
|
+
@likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"]
|
108
|
+
@likes
|
109
|
+
end
|
110
|
+
|
111
|
+
# Mark the tip done
|
112
|
+
# @return [Foursquared::Response::Tip] The marked to-do.
|
113
|
+
def mark_done
|
114
|
+
response = post("/tips/#{id}/markdone")["response"]
|
115
|
+
Foursquared::Response::Tip.new(self, response["tip"])
|
116
|
+
end
|
117
|
+
|
118
|
+
# Mark the tip to-do
|
119
|
+
# @return [Foursquared::Response::Todo] The marked to-do.
|
120
|
+
def mark_todo
|
121
|
+
response = post("/tips/#{id}/marktodo")["response"]
|
122
|
+
Foursquared::Response::Todo.new(self, response["todo"])
|
123
|
+
end
|
124
|
+
|
125
|
+
# Unmark the tip as to-do
|
126
|
+
# @return [Foursquared::Response::Tip] The current tip
|
127
|
+
def unmark_todo tip_id
|
128
|
+
response = post("/tips/#{tip_id}/unmark")["response"]
|
129
|
+
Foursquared::Response::Tip.new(self, response["tip"])
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
# Foursquared module
|
2
|
+
module Foursquared
|
3
|
+
# Response module
|
4
|
+
module Response
|
5
|
+
# User response class
|
6
|
+
class User
|
7
|
+
attr_reader :client, :response
|
8
|
+
def initialize client, response
|
9
|
+
@client = client
|
10
|
+
@response = response
|
11
|
+
end
|
12
|
+
|
13
|
+
# The user's id
|
14
|
+
# @return [String] The user's id
|
15
|
+
def id
|
16
|
+
response["id"]
|
17
|
+
end
|
18
|
+
|
19
|
+
# User's first name
|
20
|
+
# @return [String]
|
21
|
+
def first_name
|
22
|
+
response["firstName"]
|
23
|
+
end
|
24
|
+
|
25
|
+
# User's last name
|
26
|
+
# @return [String]
|
27
|
+
def last_name
|
28
|
+
response["lastName"]
|
29
|
+
end
|
30
|
+
|
31
|
+
# User's full name
|
32
|
+
# @return [String]
|
33
|
+
def name
|
34
|
+
[first_name, last_name].join(' ').strip
|
35
|
+
end
|
36
|
+
|
37
|
+
# User's profile photo
|
38
|
+
# @return [Foursquared::Response::Photo]
|
39
|
+
def photo
|
40
|
+
Foursquared::Response::Photo.new(client, response["photo"])
|
41
|
+
end
|
42
|
+
|
43
|
+
# User's relationship with the acting user
|
44
|
+
# @return [String]
|
45
|
+
def relationship
|
46
|
+
response["relationship"]
|
47
|
+
end
|
48
|
+
|
49
|
+
# User's friends list retrieved from the initial response
|
50
|
+
# @return [Hash] count and groups of users
|
51
|
+
def friends
|
52
|
+
@friends = response["friends"]
|
53
|
+
@friends["groups"].each do |group|
|
54
|
+
group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
55
|
+
end
|
56
|
+
@friends
|
57
|
+
end
|
58
|
+
|
59
|
+
# User's full friends list
|
60
|
+
# @param [Hash] options
|
61
|
+
# @option options [Integer] :limit Number of results to return, up to 500.
|
62
|
+
# @option options [Integer] :offset Used to page through results.
|
63
|
+
# @return [Hash] A count and items of friends.
|
64
|
+
def full_friends options={}
|
65
|
+
client.user_friends(id, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
# User's gender
|
69
|
+
# @return [String]
|
70
|
+
def gender
|
71
|
+
response["gender"]
|
72
|
+
end
|
73
|
+
|
74
|
+
# User's home city
|
75
|
+
# @return [String]
|
76
|
+
def home_city
|
77
|
+
response["homeCity"]
|
78
|
+
end
|
79
|
+
|
80
|
+
# A short bio for the user
|
81
|
+
# @return [String]
|
82
|
+
def bio
|
83
|
+
response["bio"]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Whether to ping if user checkins
|
87
|
+
# @return [String]
|
88
|
+
def checkin_pings
|
89
|
+
response["checkinPings"]
|
90
|
+
end
|
91
|
+
|
92
|
+
# Whether we receive pings from this user, if we have a relationship.
|
93
|
+
# @return [Boolean]
|
94
|
+
def pings
|
95
|
+
response["pings"]
|
96
|
+
end
|
97
|
+
|
98
|
+
# User's current game status.
|
99
|
+
# @return [Hash] Contains recent, max, checkinsCount, and goal for showing user's current game status.
|
100
|
+
def scores
|
101
|
+
response["scores"]
|
102
|
+
end
|
103
|
+
|
104
|
+
# Type of user. Optional, Present for non-standard user types
|
105
|
+
# @return [String] One of page, chain, celebrity, or venuePage
|
106
|
+
def type
|
107
|
+
response["type"]
|
108
|
+
end
|
109
|
+
|
110
|
+
# Venue details
|
111
|
+
# @return [Foursquared::Response::Venue] Optional For venuePage users, this field just contains an id for the relevant venue.
|
112
|
+
def venue
|
113
|
+
Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"]
|
114
|
+
end
|
115
|
+
|
116
|
+
# User's contact details
|
117
|
+
# @return [Hash] An object containing none, some, or all of twitter, facebook, email, and phone.
|
118
|
+
def contact
|
119
|
+
response["contact"]
|
120
|
+
end
|
121
|
+
|
122
|
+
# Page details
|
123
|
+
# @return [Hash] Optional, Contains a detailed page, if the type is a page.
|
124
|
+
def page_info
|
125
|
+
response["pageInfo"]
|
126
|
+
end
|
127
|
+
|
128
|
+
# User's refferal ID
|
129
|
+
# @return [String]
|
130
|
+
def refferal_id
|
131
|
+
response["refferalId"]
|
132
|
+
end
|
133
|
+
|
134
|
+
# User's followers
|
135
|
+
# @return [Hash] Optional, Contains count of followers and groups of users who follow or like this user
|
136
|
+
def followers
|
137
|
+
if response["followers"] and response["followers"]["groups"]
|
138
|
+
@followers = response["followers"]
|
139
|
+
@followers["groups"].each do |group|
|
140
|
+
group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
141
|
+
end
|
142
|
+
return @followers
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Groups of pages this user user has liked or followed.
|
147
|
+
# @return [Hash]
|
148
|
+
def following
|
149
|
+
if response["following"] and response["following"]["groups"]
|
150
|
+
@following = response["following"]
|
151
|
+
@following["groups"].each do |group|
|
152
|
+
group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
|
153
|
+
end
|
154
|
+
return @following
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Return the user's lists
|
159
|
+
# @return [Hash]
|
160
|
+
def lists
|
161
|
+
@lists = response["lists"]
|
162
|
+
if @lists and @lists["groups"]
|
163
|
+
@lists["groups"].each do |group|
|
164
|
+
group["items"].map!{|item| Foursquared::Response::List.new(client, item)}
|
165
|
+
end
|
166
|
+
end
|
167
|
+
@lists
|
168
|
+
end
|
169
|
+
|
170
|
+
# Return the user's full lists
|
171
|
+
# @param [Hash] options
|
172
|
+
# @option options [String] :group "edited", "created", "followed", "friends" or "suggested"
|
173
|
+
# @option options [String] :ll Location of the user eg: 40.7,-74
|
174
|
+
# @return [Hash]
|
175
|
+
def full_lists options={}
|
176
|
+
client.user_lists(id, options)
|
177
|
+
end
|
178
|
+
|
179
|
+
# List user's mayorships
|
180
|
+
# @return [Hash]
|
181
|
+
def mayorships
|
182
|
+
@mayorships = response["mayorships"]
|
183
|
+
@mayorships["items"].each{|item| item["venue"] = Foursquared::Response::Venue.new(client, item["venue"])}
|
184
|
+
@mayorships
|
185
|
+
end
|
186
|
+
|
187
|
+
# List user's full mayorships
|
188
|
+
# @return [Hash]
|
189
|
+
def full_mayorships
|
190
|
+
client.user_mayorships(id)
|
191
|
+
end
|
192
|
+
|
193
|
+
# List user's badges
|
194
|
+
# @return [Hash] count and items of badges
|
195
|
+
def badges
|
196
|
+
@badges = response["badges"]
|
197
|
+
@badges["items"].map!{|item| Foursquared::Response::Badge.new(client, item)}
|
198
|
+
end
|
199
|
+
|
200
|
+
# List user's full badges
|
201
|
+
# @return [Hash]
|
202
|
+
def full_badges
|
203
|
+
client.user_badges(id)
|
204
|
+
end
|
205
|
+
|
206
|
+
# Approves a pending friend request from this user.
|
207
|
+
# @return [Foursquared::Response::User] the approved user
|
208
|
+
def approve_friend_request user_id
|
209
|
+
response = post("/users/#{id}/approve")["response"]
|
210
|
+
@user = Foursquared::Response::User.new(client, response["user"])
|
211
|
+
end
|
212
|
+
|
213
|
+
# Denies a pending friend request from this user.
|
214
|
+
# @return [Foursquared::Response::User] the denied user
|
215
|
+
def deny_friend_request
|
216
|
+
request_response = post("/users/#{id}/deny")["response"]
|
217
|
+
@user = Foursquared::Response::User.new(client, request_response["user"])
|
218
|
+
end
|
219
|
+
|
220
|
+
# Send a Friend/Follow Request to this user
|
221
|
+
# @param [String, Integer] user_id The request user's/page's id
|
222
|
+
# @return [Foursquared::Response::User] the pending user
|
223
|
+
def send_friend_request
|
224
|
+
request_response = post("/users/#{id}/request")["response"]
|
225
|
+
@user = Foursquared::Response::User.new(client, request_response["userrequest_"])
|
226
|
+
end
|
227
|
+
|
228
|
+
# Removes a friend, unfollows a celebrity, or cancels a pending friend request.
|
229
|
+
# @return [Foursquared::Response::User] the removed user
|
230
|
+
def unfriend
|
231
|
+
request_response = post("/users/#{id}/unfriend")["response"]
|
232
|
+
@user = Foursquared::Response::User.new(client, request_response["user"])
|
233
|
+
end
|
234
|
+
|
235
|
+
# Set whether to receive pings about this user
|
236
|
+
# @param [Hash] options
|
237
|
+
# @option options [Boolean] :value required, true or false.
|
238
|
+
# @return [Foursquared::Response::User] User object for the user
|
239
|
+
def set_pings options={}
|
240
|
+
request_response = post("/users/#{id}/setpings", options)["response"]
|
241
|
+
@user = Foursquared::Response::User.new(client,request_response["user"])
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|