quimby 0.4.3 → 0.4.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/README.md +4 -2
- data/lib/foursquare.rb +1 -0
- data/lib/foursquare/base.rb +2 -0
- data/lib/foursquare/user.rb +12 -0
- data/lib/foursquare/venue.rb +24 -0
- metadata +3 -3
data/README.md
CHANGED
|
@@ -6,8 +6,10 @@ It's a Foursquare API wrapper. It uses objects instead of hashes, and tries to b
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
Install it as a gem (in your `Gemfile`)
|
|
9
|
+
Install it as a gem (in your `Gemfile`) and its dependencies:
|
|
10
10
|
|
|
11
|
+
gem "json"
|
|
12
|
+
gem "typhoeus"
|
|
11
13
|
gem "quimby"
|
|
12
14
|
|
|
13
15
|
## Usage
|
|
@@ -51,7 +53,7 @@ Find a user:
|
|
|
51
53
|
user = foursquare.users.find("USER_ID")
|
|
52
54
|
|
|
53
55
|
Now we've got a `Foursquare::User` object. You can call sweet methods like `user.name` and even
|
|
54
|
-
`user.last_checkin`. **In general,
|
|
56
|
+
`user.last_checkin`. **In general, Quimby's Foursquare object methods are just snake-cased
|
|
55
57
|
versions of the attributes returned in the JSON.** Now let's accidentally that user's friends:
|
|
56
58
|
|
|
57
59
|
user.friends
|
data/lib/foursquare.rb
CHANGED
data/lib/foursquare/base.rb
CHANGED
|
@@ -115,6 +115,8 @@ module Foursquare
|
|
|
115
115
|
else
|
|
116
116
|
error_type = response['meta']['errorType']
|
|
117
117
|
case error_type
|
|
118
|
+
when "invalid_auth"
|
|
119
|
+
raise Foursquare::InvalidAuth.new(Foursquare::ERRORS[error_type])
|
|
118
120
|
when "server_error"
|
|
119
121
|
raise Foursquare::ServiceUnavailable.new(Foursquare::ERRORS[error_type])
|
|
120
122
|
else
|
data/lib/foursquare/user.rb
CHANGED
|
@@ -60,6 +60,18 @@ module Foursquare
|
|
|
60
60
|
def twitter
|
|
61
61
|
contact["twitter"]
|
|
62
62
|
end
|
|
63
|
+
|
|
64
|
+
def facebook
|
|
65
|
+
contact["facebook"]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def twitter?
|
|
69
|
+
!twitter.blank?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def facebook?
|
|
73
|
+
!facebook.blank?
|
|
74
|
+
end
|
|
63
75
|
|
|
64
76
|
def phone_number
|
|
65
77
|
contact["phone"]
|
data/lib/foursquare/venue.rb
CHANGED
|
@@ -5,6 +5,11 @@ module Foursquare
|
|
|
5
5
|
def initialize(foursquare, json)
|
|
6
6
|
@foursquare, @json = foursquare, json
|
|
7
7
|
end
|
|
8
|
+
|
|
9
|
+
def fetch
|
|
10
|
+
@json = @foursquare.get("venues/#{id}")["venue"]
|
|
11
|
+
self
|
|
12
|
+
end
|
|
8
13
|
|
|
9
14
|
def id
|
|
10
15
|
@json["id"]
|
|
@@ -57,6 +62,10 @@ module Foursquare
|
|
|
57
62
|
primary_category ? primary_category["icon"] : "https://foursquare.com/img/categories/none.png"
|
|
58
63
|
end
|
|
59
64
|
|
|
65
|
+
def short_url
|
|
66
|
+
@json["shortUrl"]
|
|
67
|
+
end
|
|
68
|
+
|
|
60
69
|
def photos_count
|
|
61
70
|
@json["photos"]["count"]
|
|
62
71
|
end
|
|
@@ -77,5 +86,20 @@ module Foursquare
|
|
|
77
86
|
end
|
|
78
87
|
end
|
|
79
88
|
|
|
89
|
+
# count the people who have checked-in at the venue in the last two hours
|
|
90
|
+
def here_now_count
|
|
91
|
+
fetch unless @json.has_key?("hereNow")
|
|
92
|
+
@json["hereNow"]["count"]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# returns a list of checkins (only if a valid oauth token from a user is provided)
|
|
96
|
+
# https://developer.foursquare.com/docs/venues/herenow.html
|
|
97
|
+
# options: limit, offset, aftertimestamp
|
|
98
|
+
def here_now_checkins(options={:limit => "50"})
|
|
99
|
+
@foursquare.get("venues/#{id}/herenow", options)["hereNow"]["items"].map do |item|
|
|
100
|
+
Foursquare::Checkin.new(@foursquare, item)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
80
104
|
end
|
|
81
105
|
end
|
metadata
CHANGED