cmdrkeene-foursquare 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1 +1,20 @@
1
- Until further notice: Copyright 2009 Brandon Keene - All Rights Reserved
1
+ Copyright (c) 2009 Brandon Keene
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,104 @@
1
+ Foursquare
2
+ ==========
3
+
4
+ A ruby interface for Foursquare's [JSON API](http://groups.google.com/group/foursquare-api/web/api-documentation).
5
+ Sign up for a Foursquare account at [http://playfoursquare.com](http://playfoursquare.com).
6
+
7
+ Install
8
+ -------
9
+
10
+ $ gem sources -a http://gems.github.com
11
+ $ sudo gem install cmdrkeene-foursquare
12
+
13
+ Usage
14
+ -----
15
+
16
+ ### checkin(options = {})
17
+
18
+ Allows you to check-in to a place.
19
+
20
+ First, create a new Foursquare instance with your Basic Authentication
21
+ credentials:
22
+
23
+ @foursquare = Foursquare.new("user@example.com", "sekret")
24
+
25
+ Then, you can check in with a venue id (vid):
26
+
27
+ @foursquare.checkin(:vid => 1234)
28
+
29
+ Or you can check in with a name search for a venue:
30
+
31
+ @foursquare.checkin(:venue => "Mamoun's")
32
+
33
+ If successful, you will get a response hash with the following keys:
34
+
35
+ * **ID**
36
+
37
+ "id" => 701707
38
+
39
+ * **Message**
40
+
41
+ "message" => "OK! We've got you @ Santana's Bay Park."
42
+
43
+ * **Created**
44
+
45
+ "created" => "Tue, 11 Aug 09 16:02:13 +0000"
46
+
47
+
48
+ * **Mayor**
49
+
50
+ "mayor" => {
51
+ "type" => "nochange",
52
+ "message" => "Casey W. is The Mayor of Santana's Bay Park."
53
+ }
54
+
55
+ * **Scoring**
56
+
57
+ "scoring" => {
58
+ "score" => {
59
+ "icon" => "http://playfoursquare.com/images/scoring/2.png",
60
+ "points" => 1,
61
+ "message" => "First stop today"
62
+ },
63
+ "total" => {
64
+ "points" => 6,
65
+ "message" => "6 pts "
66
+ },
67
+ "rank" => {
68
+ "city" => {
69
+ "city" => "San Diego",
70
+ "position" => 42,
71
+ "message" => "#42 in San Diego (this week)"
72
+ },
73
+ "friends" => {
74
+ "position" => 1,
75
+ "message" => "#1 amongst friends"
76
+ }
77
+ }
78
+ }
79
+
80
+ * **Badges**
81
+
82
+ "badges" => {
83
+ "badge" => {
84
+ "name" => "Newbie",
85
+ "text" => "Congrats on your first check-in!",
86
+ "icon" => "http://playfoursquare.com/images/badges/newbie_on.png",
87
+ "id" => 54494
88
+ }
89
+ }
90
+
91
+ * **Venue**
92
+
93
+ "venue" => {
94
+ "city" => "San Diego",
95
+ "address" => "1975 Morena Blvd.",
96
+ "name" => "Santana's Bay Park",
97
+ "zip" => 92110,
98
+ "geolong" => -117.207,
99
+ "geolat" => 32.782,
100
+ "crossstreet" => nil,
101
+ "id" => 84689,
102
+ "cityid" => 38,
103
+ "state" => "CA"
104
+ }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,20 +5,20 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{foursquare}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brandon Keene"]
12
- s.date = %q{2009-08-12}
12
+ s.date = %q{2009-08-28}
13
13
  s.description = %q{Ruby API for Foursquare (playfoursquare.com)}
14
14
  s.email = %q{bkeene@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README"
17
+ "README.markdown"
18
18
  ]
19
19
  s.files = [
20
20
  "LICENSE",
21
- "README",
21
+ "README.markdown",
22
22
  "Rakefile",
23
23
  "VERSION",
24
24
  "foursquare.gemspec",
@@ -26,6 +26,12 @@ Gem::Specification.new do |s|
26
26
  "lib/foursquare.rb",
27
27
  "spec/fixtures/checkin_failure.json",
28
28
  "spec/fixtures/checkin_success.json",
29
+ "spec/fixtures/cities.json",
30
+ "spec/fixtures/test_failure.json",
31
+ "spec/fixtures/test_success.json",
32
+ "spec/fixtures/user.json",
33
+ "spec/fixtures/venues_authenticated.json",
34
+ "spec/fixtures/venues_unauthenticated.json",
29
35
  "spec/foursquare_spec.rb",
30
36
  "spec/spec_helper.rb"
31
37
  ]
@@ -1,20 +1,126 @@
1
1
  require 'httparty'
2
2
 
3
3
  class Foursquare
4
+ class AuthenticationRequiredError < StandardError;end
4
5
  class VenueNotFoundError < StandardError;end
5
-
6
+
6
7
  include HTTParty
7
8
  base_uri "http://api.playfoursquare.com/v1"
8
9
  format :json
9
-
10
- def initialize(username, password)
10
+
11
+ def initialize(username = nil, password = nil)
11
12
  @auth = {:username => username, :password => password}
12
13
  end
13
-
14
- def checkin(venue_id)
15
- raise ArgumentError, "you must pass a venue_id" unless venue_id
16
- response = self.class.post("/checkin.json", {:query => {:vid => venue_id}, :basic_auth => @auth})
14
+
15
+ # Allows you to check-in to a place.
16
+ #
17
+ # Options
18
+ # :vid => (optional, not necessary if you are 'shouting' or have a
19
+ # venue name). ID of the venue where you want to check-in.
20
+ # :venue => (optional, not necessary if you are 'shouting' or have a
21
+ # vid) if you don't have a venue ID, pass the venue name as
22
+ # a string using this parameter. foursquare will attempt to
23
+ # match it on the server-side
24
+ # :shout => (optional) a message about your check-in
25
+ # :private => (optional, defaults to the user's setting). true means
26
+ # "don't show your friends". false means "show everyone"
27
+ # :twitter => (optional, defaults to the user's setting). false means
28
+ # "send to twitter". false means "don't send to twitter"
29
+ # :geolat => (optional, but recommended)
30
+ # :geolong => (optional, but recommended)
31
+ def checkin(options = {})
32
+ unless options[:private].nil?
33
+ options[:private] = 1 if options[:private] == true
34
+ options[:private] = 0 if options[:private] == false
35
+ end
36
+ unless options[:twitter].nil?
37
+ options[:twitter] = 1 if options[:twitter] == true
38
+ options[:twitter] = 0 if options[:twitter] == false
39
+ end
40
+ response = self.class.post("/checkin.json",
41
+ :query => options,
42
+ :basic_auth => @auth)
17
43
  raise VenueNotFoundError if response.keys.include?("addvenueprompt")
18
44
  response["checkin"]
19
45
  end
46
+
47
+ # Like self.venues(), except when authenticated the method will return venue
48
+ # meta-data related to you and your friends.
49
+ def venues(options = {})
50
+ self.class.require_latitude_and_longitude(options)
51
+
52
+ response = self.class.get("/venues.json",
53
+ :query => options,
54
+ :basic_auth => @auth)["venues"]
55
+ response && response.flatten
56
+ end
57
+
58
+ # Returns data for a particular user
59
+ #
60
+ # Options
61
+ # :uid => userid for the user whose information you want to retrieve.
62
+ # if you do not specify a 'uid', the authenticated user's
63
+ # profile data will be returned.
64
+ # :badges => (optional, default: false) set to true ("1") to also show
65
+ # badges for this user
66
+ # :mayor => (optional, default: false) set to true ("1") to also show
67
+ # venues for which this user is a mayor
68
+ def user(options = {})
69
+ self.class.get("/user.json", :query => options)["user"]
70
+ end
71
+
72
+ ############################################################################
73
+ # Class methods
74
+ ############################################################################
75
+
76
+ # Returns a list of currently active cities.
77
+ # http://api.playfoursquare.com/v1/cities
78
+ def self.cities
79
+ get("/cities.json", :query => nil)["cities"]
80
+ end
81
+
82
+ # Returns a list of tips near the area specified. (The distance returned is
83
+ # in miles).
84
+ # Options
85
+ # :geolat => latitude (required)
86
+ # :geolong => longitude (required)
87
+ #
88
+ # http://api.playfoursquare.com/v1/tips
89
+ def self.tips(options = {})
90
+ require_latitude_and_longitude(options)
91
+ # XXX
92
+ end
93
+
94
+ # Returns a list of venues near the area specified or that match the search
95
+ # term. Distance returned is in miles. It will return venue meta-data
96
+ # related to you and your friends.
97
+ #
98
+ # Options
99
+ # :geolat => latitude (required)
100
+ # :geolong => longitude (required)
101
+ # :r => radius in miles (optional)
102
+ # :l => limit of results (optional, default 10)
103
+ # :q => keyword search (optional)
104
+ #
105
+ # http://api.playfoursquare.com/v1/venues
106
+ def self.venues(options = {})
107
+ require_latitude_and_longitude(options)
108
+
109
+ get("/venues.json", :query => options)["venues"]["group"]
110
+ end
111
+
112
+ # Test if API is up and available
113
+ # http://api.playfoursquare.com/v1/test
114
+ def self.available?
115
+ response = get("/test.json", :query => nil)
116
+ (!response.nil? && response["response"] == "ok") ? true : false
117
+ end
118
+
119
+ private
120
+
121
+ def self.require_latitude_and_longitude(options)
122
+ unless options[:geolat] and options[:geolong]
123
+ raise ArgumentError, "you must supply :geolat and :geolong"
124
+ end
125
+ end
20
126
  end
@@ -0,0 +1 @@
1
+ {"cities":[{"id":56,"timezone":"Europe/Amsterdam","name":"Amsterdam","geolat":52.3789,"geolong":4.90067},{"id":46,"timezone":"America/New_York","name":"Atlanta","geolat":33.7525,"geolong":-84.3888},{"id":42,"timezone":"America/Chicago","name":"Austin","geolat":30.2669,"geolong":-97.7428},{"id":24,"timezone":"America/New_York","name":"Boston","geolat":42.3583,"geolong":-71.0603},{"id":32,"timezone":"America/Chicago","name":"Chicago","geolat":41.8858,"geolong":-87.6181},{"id":43,"timezone":"America/Chicago","name":"Dallas / Fort Worth","geolat":32.7887,"geolong":-96.7676},{"id":25,"timezone":"America/Denver","name":"Denver","geolat":39.734,"geolong":-105.026},{"id":47,"timezone":"America/New_York","name":"Detroit","geolat":42.3333,"geolong":-83.0484},{"id":48,"timezone":"America/Chicago","name":"Houston","geolat":29.7594,"geolong":-95.3594},{"id":49,"timezone":"America/Los_Angeles","name":"Las Vegas","geolat":36.1721,"geolong":-115.122},{"id":34,"timezone":"America/Los_Angeles","name":"Los Angeles","geolat":34.0443,"geolong":-118.251},{"id":39,"timezone":"America/New_York","name":"Miami","geolat":25.7323,"geolong":-80.2436},{"id":51,"timezone":"America/Chicago","name":"Minneapolis / St. Paul","geolat":44.9609,"geolong":-93.2642},{"id":22,"timezone":"America/New_York","name":"New York City","geolat":40.7255,"geolong":-73.9983},{"id":33,"timezone":"America/New_York","name":"Philadelphia","geolat":39.8694,"geolong":-75.2731},{"id":53,"timezone":"America/Phoenix","name":"Phoenix","geolat":33.4483,"geolong":-112.073},{"id":37,"timezone":"America/Los_Angeles","name":"Portland","geolat":45.527,"geolong":-122.685},{"id":38,"timezone":"America/Los_Angeles","name":"San Diego","geolat":32.7153,"geolong":-117.156},{"id":23,"timezone":"America/Los_Angeles","name":"San Francisco","geolat":37.7587,"geolong":-122.433},{"id":41,"timezone":"America/Los_Angeles","name":"Seattle","geolat":47.6036,"geolong":-122.326},{"id":31,"timezone":"America/New_York","name":"Washington, DC","geolat":38.8964,"geolong":-77.0447}]}
File without changes
@@ -0,0 +1 @@
1
+ {"response":"ok"}
@@ -0,0 +1 @@
1
+ {"user":{"id":31786,"firstname":"John","lastname":"Connor","city":{"id":38,"name":"San Diego","shortname":"San Diego","geolat":32.7153,"geolong":-117.156},"gender":"none","settings":{"feeds_key":"9c0cf605ddd2251495640129c7c40c6e"},"checkin":{"id":707746,"shout":null,"display":"John C. @ Santana's Mexican Grill (Bay Park)","created":"Wed, 12 Aug 09 10:21:33 +0000","venue":{"id":84689,"name":"Santana's Mexican Grill (Bay Park)","address":"1975 Morena Blvd","crossstreet":"Napier St","geolat":32.782,"geolong":-117.207}}}}
@@ -0,0 +1 @@
1
+ {"venues":[[{"id":10350,"name":"Sandbar","distance":0.1,"address":"3064 Grand Ave","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7281,"geolong":-80.2428,"stats":{"checkins":18}},{"id":10287,"name":"Mr. Moe's","distance":0.1,"address":"3131 Commodore Plaza","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7274,"geolong":-80.2441,"stats":{"checkins":6}},{"id":18315,"name":"Barracuda Bar","distance":0.1,"address":"3035 Fuller St","crossstreet":"at Grand Ave","city":"Miami","state":"FL","zip":33133,"phone":"305 448-1144","geolat":25.7276,"geolong":-80.2432,"stats":{"checkins":4}},{"id":45598,"name":"Boardwalk Tavern & Pizzeria","distance":0.1,"address":"3415 Main Hwy","crossstreet":null,"city":"Coconut Grove","state":"FL","zip":33133,"phone":"305-567-0080","geolat":25.7277,"geolong":-80.2427,"stats":{"checkins":3}}],[{"id":88408,"name":"Barracadu Bar & Grill }i{","distance":0.1,"address":"3035 Fuller St,","crossstreet":"btw Main Hwy and Grand ave","city":"Miami","state":"FL","zip":33133,"phone":"(305) 448-1144","geolat":25.7276,"geolong":-80.2432},{"id":85556,"name":"Barracadu Coconut Grove}i{","distance":0.1,"address":"3035 Fuller St","crossstreet":"btw Main Hwy and Grand ave","city":"Miami","state":"FL","zip":null,"phone":"(305) 448-1144","geolat":25.7276,"geolong":-80.2432},{"id":10147,"name":"Don Quixote","distance":0.1,"address":"3120 Commodore Plaza","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7271,"geolong":-80.2447},{"id":10219,"name":"Hungry Sailor","distance":0.1,"address":"3424 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7276,"geolong":-80.2428},{"id":10391,"name":"Tavern In The Grove","distance":0.1,"address":"3416 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7276,"geolong":-80.2427},{"id":10356,"name":"Senor Frogs","distance":0.1,"address":"3480 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7267,"geolong":-80.2442},{"id":10252,"name":"Life","distance":0.2,"address":"3342 Virginia St","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7289,"geolong":-80.2415},{"id":84676,"name":"InfiniHQ","distance":0.2,"address":"3339 Virginia St","crossstreet":"at Oak Ave","city":"Miami","state":"FL","zip":33133,"phone":3057284641,"geolat":25.7292,"geolong":-80.2413},{"id":10173,"name":"Flavour","distance":0.2,"address":"2895 McFarlane RD.","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7275,"geolong":-80.2411},{"id":10390,"name":"Taurus Chops","distance":0.2,"address":"3540 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7251,"geolong":-80.245},{"id":10305,"name":"Oxygen Lounge","distance":0.2,"address":"2911 Grand Ave","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7285,"geolong":-80.2406},{"id":10331,"name":"Quench","distance":0.3,"address":"2801 Florida Ave","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":"305 448-8150","geolat":25.7291,"geolong":-80.2395},{"id":10224,"name":"Improv Comedy Club","distance":0.3,"address":"3390 Mary St","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7282,"geolong":-80.2393},{"id":80526,"name":"The Jewlicious Pad","distance":0.4,"address":"Grand Ave","crossstreet":null,"city":"Coconut Grove","state":"FL","zip":null,"phone":null,"twitter":"jewgonewild","geolat":25.7278,"geolong":-80.2499},{"id":10124,"name":"Cocont Grove Expo Center","distance":0.4,"address":"2700 south bayshore drive","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7282,"geolong":-80.2379},{"id":66946,"name":"Flordia","distance":0.4,"address":"650 williamstreet","crossstreet":"Sr mia","city":"Miami","state":"FL","zip":null,"phone":null,"geolat":25.7263,"geolong":-80.2511},{"id":83833,"name":"Doubletree Coconut Grove","distance":0.6,"address":"2649 South Bayshore Drive","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":"305-858-2500","geolat":25.7312,"geolong":-80.2353},{"id":86452,"name":"Scottys Landing","distance":0.6,"address":"3381 pan American drive","crossstreet":null,"city":"Coconut grove","state":"FL","zip":33133,"phone":null,"geolat":25.7278,"geolong":-80.2342},{"id":18241,"name":"Monty's","distance":0.8,"address":"2550 South Bayshore Drive","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":"305 858-1431","geolat":25.7321,"geolong":-80.2326},{"id":85554,"name":"Berries in the Grove }i{","distance":0.8,"address":"2884 S.W. 27th Ave","crossstreet":"btw US1 and Coconut ave","city":"Miami","state":"FL","zip":33133,"phone":"(305) 448-2111","geolat":25.7382,"geolong":-80.2381}]]}
@@ -0,0 +1 @@
1
+ {"venues":{"group":[{"id":84676,"name":"InfiniHQ","distance":0.3,"address":"3339 Virginia St","crossstreet":"at Oak Ave","city":"Miami","state":"FL","zip":33133,"phone":3057284641,"geolat":25.7292,"geolong":-80.2413},{"id":10252,"name":"Life","distance":0.3,"address":"3342 Virginia St","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7289,"geolong":-80.2415},{"id":10350,"name":"Sandbar","distance":0.3,"address":"3064 Grand Ave","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7281,"geolong":-80.2428},{"id":10305,"name":"Oxygen Lounge","distance":0.3,"address":"2911 Grand Ave","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7285,"geolong":-80.2406},{"id":45598,"name":"Boardwalk Tavern & Pizzeria","distance":0.3,"address":"3415 Main Hwy","crossstreet":null,"city":"Coconut Grove","state":"FL","zip":33133,"phone":"305-567-0080","geolat":25.7277,"geolong":-80.2427},{"id":88408,"name":"Barracadu Bar & Grill }i{","distance":0.3,"address":"3035 Fuller St,","crossstreet":"btw Main Hwy and Grand ave","city":"Miami","state":"FL","zip":33133,"phone":"(305) 448-1144","geolat":25.7276,"geolong":-80.2432},{"id":85556,"name":"Barracadu Coconut Grove}i{","distance":0.3,"address":"3035 Fuller St","crossstreet":"btw Main Hwy and Grand ave","city":"Miami","state":"FL","zip":null,"phone":"(305) 448-1144","geolat":25.7276,"geolong":-80.2432},{"id":18315,"name":"Barracuda Bar","distance":0.3,"address":"3035 Fuller St","crossstreet":"at Grand Ave","city":"Miami","state":"FL","zip":33133,"phone":"305 448-1144","geolat":25.7276,"geolong":-80.2432},{"id":10219,"name":"Hungry Sailor","distance":0.3,"address":"3424 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7276,"geolong":-80.2428},{"id":10391,"name":"Tavern In The Grove","distance":0.3,"address":"3416 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7276,"geolong":-80.2427},{"id":10331,"name":"Quench","distance":0.3,"address":"2801 Florida Ave","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":"305 448-8150","geolat":25.7291,"geolong":-80.2395},{"id":10287,"name":"Mr. Moe's","distance":0.3,"address":"3131 Commodore Plaza","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7274,"geolong":-80.2441},{"id":10147,"name":"Don Quixote","distance":0.4,"address":"3120 Commodore Plaza","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7271,"geolong":-80.2447},{"id":10173,"name":"Flavour","distance":0.4,"address":"2895 McFarlane RD.","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7275,"geolong":-80.2411},{"id":10356,"name":"Senor Frogs","distance":0.4,"address":"3480 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7267,"geolong":-80.2442},{"id":10224,"name":"Improv Comedy Club","distance":0.4,"address":"3390 Mary St","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7282,"geolong":-80.2393},{"id":10124,"name":"Cocont Grove Expo Center","distance":0.5,"address":"2700 south bayshore drive","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7282,"geolong":-80.2379},{"id":80526,"name":"The Jewlicious Pad","distance":0.5,"address":"Grand Ave","crossstreet":null,"city":"Coconut Grove","state":"FL","zip":null,"phone":null,"twitter":"jewgonewild","geolat":25.7278,"geolong":-80.2499},{"id":10390,"name":"Taurus Chops","distance":0.5,"address":"3540 Main Highway","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":null,"geolat":25.7251,"geolong":-80.245},{"id":83833,"name":"Doubletree Coconut Grove","distance":0.5,"address":"2649 South Bayshore Drive","crossstreet":null,"city":"Miami","state":"FL","zip":33133,"phone":"305-858-2500","geolat":25.7312,"geolong":-80.2353}]}}
@@ -2,48 +2,45 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
  require File.dirname(__FILE__) + '/../init'
3
3
 
4
4
  describe Foursquare do
5
- describe ".checkin" do
5
+ before do
6
+ @username = "user@example.com"
7
+ @password = "secret"
8
+ end
9
+
10
+ describe "#checkin" do
6
11
  before do
7
- @valid_venue_id = 84689
8
- @invalid_venue_id = 111
9
- @username = "user@example.com"
10
- @password = "secret"
12
+ @valid_vid = 84689
13
+ @invalid_vid = 111
11
14
 
12
15
  # Success
13
16
  FakeWeb.register_uri(:post,
14
- "http://api.playfoursquare.com/v1/checkin.json?vid=#{@valid_venue_id}",
17
+ "http://api.playfoursquare.com/v1/checkin.json?vid=#{@valid_vid}",
15
18
  :body => "Unauthorized",
16
19
  :status => ["401", "Unauthorized"])
17
20
  FakeWeb.register_uri(:post,
18
- "http://user%40example.com:secret@api.playfoursquare.com/v1/checkin.json?vid=#{@valid_venue_id}",
21
+ "http://user%40example.com:secret@api.playfoursquare.com/v1/checkin.json?vid=#{@valid_vid}",
19
22
  :body => fakeweb_read('checkin_success.json'))
20
23
 
21
24
  # Failure
22
25
  FakeWeb.register_uri(:post,
23
- "http://api.playfoursquare.com/v1/checkin.json?vid=#{@invalid_venue_id}",
26
+ "http://api.playfoursquare.com/v1/checkin.json?vid=#{@invalid_vid}",
24
27
  :body => "Unauthorized",
25
28
  :status => ["401", "Unauthorized"])
26
29
  FakeWeb.register_uri(:post,
27
- "http://user%40example.com:secret@api.playfoursquare.com/v1/checkin.json?vid=#{@invalid_venue_id}",
30
+ "http://user%40example.com:secret@api.playfoursquare.com/v1/checkin.json?vid=#{@invalid_vid}",
28
31
  :body => fakeweb_read('checkin_failure.json'))
29
32
  end
30
-
31
- it "should require a venue_id" do
32
- lambda {
33
- Foursquare.new(@username, @password).checkin
34
- }.should raise_error(ArgumentError)
35
- end
36
-
33
+
37
34
  it "should raise an error if user is invalid" do
38
35
  lambda {
39
- Foursquare.new("bork@pork.com", "arglebargle").checkin(@valid_venue_id)
36
+ Foursquare.new("bork@pork.com", "arglebargle").checkin(@valid_vid)
40
37
  }.should raise_error
41
38
  end
42
-
39
+
43
40
  describe "to a valid venue, with a valid user" do
44
41
  it "should check in and return check in data" do
45
42
  @foursquare = Foursquare.new(@username, @password)
46
- checkin = @foursquare.checkin(@valid_venue_id)
43
+ checkin = @foursquare.checkin(:vid => @valid_vid)
47
44
  checkin.should == {
48
45
  "mayor" => {"type"=>"nochange", "message"=>"Casey W. is The Mayor of Santana's Bay Park."},
49
46
  "scoring" => {
@@ -54,7 +51,7 @@ describe Foursquare do
54
51
  "friends" => {"position"=>1, "message"=>"#1 amongst friends"}
55
52
  },
56
53
  },
57
- "id" => 701707,
54
+ "id" => 701707,
58
55
  "badges" => {
59
56
  "badge" => {"name"=>"Newbie", "text"=>"Congrats on your first check-in!", "icon"=>"http://playfoursquare.com/images/badges/newbie_on.png", "id"=>54494}
60
57
  },
@@ -63,26 +60,214 @@ describe Foursquare do
63
60
  }
64
61
  end
65
62
  end
66
-
63
+
67
64
  describe "with an invalid venue" do
68
65
  it "should raise an error" do
69
66
  lambda {
70
67
  @foursquare = Foursquare.new(@username, @password)
71
- @foursquare.checkin(@invalid_venue_id).should == "foo"
68
+ @foursquare.checkin(:vid => @invalid_vid).should == "foo"
72
69
  }.should raise_error(Foursquare::VenueNotFoundError)
73
70
  end
74
71
  end
75
72
  end
76
73
 
77
- describe ".city" do
74
+ describe ".cities" do
75
+ before do
76
+ FakeWeb.register_uri(:get,
77
+ "http://api.playfoursquare.com/v1/cities.json",
78
+ :body => fakeweb_read('cities.json'))
79
+ end
80
+
81
+ it "should return all cities currently active on Foursquare" do
82
+ cities = [
83
+ {"name"=>"Amsterdam", "geolong"=>4.90067, "geolat"=>52.3789, "timezone"=>"Europe/Amsterdam", "id"=>56},
84
+ {"name"=>"Atlanta", "geolong"=>-84.3888, "geolat"=>33.7525, "timezone"=>"America/New_York", "id"=>46},
85
+ {"name"=>"Austin", "geolong"=>-97.7428, "geolat"=>30.2669, "timezone"=>"America/Chicago", "id"=>42},
86
+ {"name"=>"Boston", "geolong"=>-71.0603, "geolat"=>42.3583, "timezone"=>"America/New_York", "id"=>24},
87
+ {"name"=>"Chicago", "geolong"=>-87.6181, "geolat"=>41.8858, "timezone"=>"America/Chicago", "id"=>32},
88
+ {"name"=>"Dallas / Fort Worth", "geolong"=>-96.7676, "geolat"=>32.7887, "timezone"=>"America/Chicago", "id"=>43},
89
+ {"name"=>"Denver", "geolong"=>-105.026, "geolat"=>39.734, "timezone"=>"America/Denver", "id"=>25},
90
+ {"name"=>"Detroit", "geolong"=>-83.0484, "geolat"=>42.3333, "timezone"=>"America/New_York", "id"=>47},
91
+ {"name"=>"Houston", "geolong"=>-95.3594, "geolat"=>29.7594, "timezone"=>"America/Chicago", "id"=>48},
92
+ {"name"=>"Las Vegas", "geolong"=>-115.122, "geolat"=>36.1721, "timezone"=>"America/Los_Angeles", "id"=>49},
93
+ {"name"=>"Los Angeles", "geolong"=>-118.251, "geolat"=>34.0443, "timezone"=>"America/Los_Angeles", "id"=>34},
94
+ {"name"=>"Miami", "geolong"=>-80.2436, "geolat"=>25.7323, "timezone"=>"America/New_York", "id"=>39},
95
+ {"name"=>"Minneapolis / St. Paul", "geolong"=>-93.2642, "geolat"=>44.9609, "timezone"=>"America/Chicago", "id"=>51},
96
+ {"name"=>"New York City", "geolong"=>-73.9983, "geolat"=>40.7255, "timezone"=>"America/New_York", "id"=>22},
97
+ {"name"=>"Philadelphia", "geolong"=>-75.2731, "geolat"=>39.8694, "timezone"=>"America/New_York", "id"=>33},
98
+ {"name"=>"Phoenix", "geolong"=>-112.073, "geolat"=>33.4483, "timezone"=>"America/Phoenix", "id"=>53},
99
+ {"name"=>"Portland", "geolong"=>-122.685, "geolat"=>45.527, "timezone"=>"America/Los_Angeles", "id"=>37},
100
+ {"name"=>"San Diego", "geolong"=>-117.156, "geolat"=>32.7153, "timezone"=>"America/Los_Angeles", "id"=>38},
101
+ {"name"=>"San Francisco", "geolong"=>-122.433, "geolat"=>37.7587, "timezone"=>"America/Los_Angeles", "id"=>23},
102
+ {"name"=>"Seattle", "geolong"=>-122.326, "geolat"=>47.6036, "timezone"=>"America/Los_Angeles", "id"=>41},
103
+ {"name"=>"Washington, DC", "geolong"=>-77.0447, "geolat"=>38.8964, "timezone"=>"America/New_York", "id"=>31}
104
+ ]
105
+ Foursquare.cities.should == cities
106
+ end
107
+ end
108
+
109
+ describe ".tips" do
110
+ # Having problems with the tips resource respect coordinates
78
111
  end
79
112
 
80
- describe ".tip" do
113
+ describe "#user" do
114
+ it "should return user data for an arbitrary user" do
115
+ FakeWeb.register_uri(:get,
116
+ "http://api.playfoursquare.com/v1/user.json?uid=31786",
117
+ :body => fakeweb_read('user.json'))
118
+
119
+ @foursquare = Foursquare.new(@username, @password)
120
+ @foursquare.user(:uid => 31786).should == {
121
+ "city" => {"shortname"=>"San Diego",
122
+ "name"=>"San Diego",
123
+ "geolong"=>-117.156,
124
+ "geolat"=>32.7153, "id"=>38},
125
+ "gender"=>"none",
126
+ "lastname"=>"Connor",
127
+ "id"=>31786,
128
+ "checkin"=>{"shout"=>nil,
129
+ "id"=>707746,
130
+ "display"=>"John C. @ Santana's Mexican Grill (Bay Park)",
131
+ "venue"=>{"address"=>"1975 Morena Blvd",
132
+ "name"=>"Santana's Mexican Grill (Bay Park)",
133
+ "geolong"=>-117.207,
134
+ "geolat"=>32.782,
135
+ "crossstreet"=>"Napier St",
136
+ "id"=>84689},
137
+ "created"=>"Wed, 12 Aug 09 10:21:33 +0000"},
138
+ "firstname"=>"John",
139
+ "settings"=>{"feeds_key"=>"9c0cf605ddd2251495640129c7c40c6e"}}
140
+ end
141
+
142
+ it "should return user data for the authenticated user" do
143
+ FakeWeb.register_uri(:get,
144
+ "http://api.playfoursquare.com/v1/user.json",
145
+ :body => fakeweb_read('user.json'))
146
+
147
+ @foursquare = Foursquare.new(@username, @password)
148
+ @foursquare.user.should == {
149
+ "city" => {"shortname"=>"San Diego",
150
+ "name"=>"San Diego",
151
+ "geolong"=>-117.156,
152
+ "geolat"=>32.7153, "id"=>38},
153
+ "gender"=>"none",
154
+ "lastname"=>"Connor",
155
+ "id"=>31786,
156
+ "checkin"=>{"shout"=>nil,
157
+ "id"=>707746,
158
+ "display"=>"John C. @ Santana's Mexican Grill (Bay Park)",
159
+ "venue"=>{"address"=>"1975 Morena Blvd",
160
+ "name"=>"Santana's Mexican Grill (Bay Park)",
161
+ "geolong"=>-117.207,
162
+ "geolat"=>32.782,
163
+ "crossstreet"=>"Napier St",
164
+ "id"=>84689},
165
+ "created"=>"Wed, 12 Aug 09 10:21:33 +0000"},
166
+ "firstname"=>"John",
167
+ "settings"=>{"feeds_key"=>"9c0cf605ddd2251495640129c7c40c6e"}}
168
+ end
81
169
  end
82
170
 
83
- describe ".user" do
171
+ describe "#user" do
172
+ it "should return authenticated user's data" do
173
+
174
+ end
84
175
  end
85
-
176
+
86
177
  describe ".venue" do
178
+ before do
179
+ FakeWeb.register_uri(:get,
180
+ "http://api.playfoursquare.com/v1/venues.json?geolat=25.7323&geolong=80.2436",
181
+ :body => fakeweb_read('venues_unauthenticated.json'))
182
+ end
183
+
184
+ it "should raise an error unless geolat and geolong are passed" do
185
+ lambda {
186
+ Foursquare.venues
187
+ }.should raise_error(ArgumentError)
188
+ end
189
+
190
+ it "should return a list of nearby venues" do
191
+ venues = [
192
+ {"city"=>"Miami", "address"=>"3339 Virginia St", "name"=>"InfiniHQ", "zip"=>33133, "geolong"=>-80.2413, "geolat"=>25.7292, "crossstreet"=>"at Oak Ave", "id"=>84676, "phone"=>3057284641, "state"=>"FL", "distance"=>0.3},
193
+ {"city"=>"Miami", "address"=>"3342 Virginia St", "name"=>"Life", "zip"=>33133, "geolong"=>-80.2415, "geolat"=>25.7289, "crossstreet"=>nil, "id"=>10252, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
194
+ {"city"=>"Miami", "address"=>"3064 Grand Ave", "name"=>"Sandbar", "zip"=>33133, "geolong"=>-80.2428, "geolat"=>25.7281, "crossstreet"=>nil, "id"=>10350, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
195
+ {"city"=>"Miami", "address"=>"2911 Grand Ave", "name"=>"Oxygen Lounge", "zip"=>33133, "geolong"=>-80.2406, "geolat"=>25.7285, "crossstreet"=>nil, "id"=>10305, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
196
+ {"city"=>"Coconut Grove", "address"=>"3415 Main Hwy", "name"=>"Boardwalk Tavern & Pizzeria", "zip"=>33133, "geolong"=>-80.2427, "geolat"=>25.7277, "crossstreet"=>nil, "id"=>45598, "phone"=>"305-567-0080", "state"=>"FL", "distance"=>0.3},
197
+ {"city"=>"Miami", "address"=>"3035 Fuller St,", "name"=>"Barracadu Bar & Grill }i{", "zip"=>33133, "geolong"=>-80.2432, "geolat"=>25.7276, "crossstreet"=>"btw Main Hwy and Grand ave", "id"=>88408, "phone"=>"(305) 448-1144", "state"=>"FL", "distance"=>0.3},
198
+ {"city"=>"Miami", "address"=>"3035 Fuller St", "name"=>"Barracadu Coconut Grove}i{", "zip"=>nil, "geolong"=>-80.2432, "geolat"=>25.7276, "crossstreet"=>"btw Main Hwy and Grand ave", "id"=>85556, "phone"=>"(305) 448-1144", "state"=>"FL", "distance"=>0.3},
199
+ {"city"=>"Miami", "address"=>"3035 Fuller St", "name"=>"Barracuda Bar", "zip"=>33133, "geolong"=>-80.2432, "geolat"=>25.7276, "crossstreet"=>"at Grand Ave", "id"=>18315, "phone"=>"305 448-1144", "state"=>"FL", "distance"=>0.3},
200
+ {"city"=>"Miami", "address"=>"3424 Main Highway", "name"=>"Hungry Sailor", "zip"=>33133, "geolong"=>-80.2428, "geolat"=>25.7276, "crossstreet"=>nil, "id"=>10219, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
201
+ {"city"=>"Miami", "address"=>"3416 Main Highway", "name"=>"Tavern In The Grove", "zip"=>33133, "geolong"=>-80.2427, "geolat"=>25.7276, "crossstreet"=>nil, "id"=>10391, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
202
+ {"city"=>"Miami", "address"=>"2801 Florida Ave", "name"=>"Quench", "zip"=>33133, "geolong"=>-80.2395, "geolat"=>25.7291, "crossstreet"=>nil, "id"=>10331, "phone"=>"305 448-8150", "state"=>"FL", "distance"=>0.3},
203
+ {"city"=>"Miami", "address"=>"3131 Commodore Plaza", "name"=>"Mr. Moe's", "zip"=>33133, "geolong"=>-80.2441, "geolat"=>25.7274, "crossstreet"=>nil, "id"=>10287, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
204
+ {"city"=>"Miami", "address"=>"3120 Commodore Plaza", "name"=>"Don Quixote", "zip"=>33133, "geolong"=>-80.2447, "geolat"=>25.7271, "crossstreet"=>nil, "id"=>10147, "phone"=>nil, "state"=>"FL", "distance"=>0.4},
205
+ {"city"=>"Miami", "address"=>"2895 McFarlane RD.", "name"=>"Flavour", "zip"=>33133, "geolong"=>-80.2411, "geolat"=>25.7275, "crossstreet"=>nil, "id"=>10173, "phone"=>nil, "state"=>"FL", "distance"=>0.4},
206
+ {"city"=>"Miami", "address"=>"3480 Main Highway", "name"=>"Senor Frogs", "zip"=>33133, "geolong"=>-80.2442, "geolat"=>25.7267, "crossstreet"=>nil, "id"=>10356, "phone"=>nil, "state"=>"FL", "distance"=>0.4},
207
+ {"city"=>"Miami", "address"=>"3390 Mary St", "name"=>"Improv Comedy Club", "zip"=>33133, "geolong"=>-80.2393, "geolat"=>25.7282, "crossstreet"=>nil, "id"=>10224, "phone"=>nil, "state"=>"FL", "distance"=>0.4},
208
+ {"city"=>"Miami", "address"=>"2700 south bayshore drive", "name"=>"Cocont Grove Expo Center", "zip"=>33133, "geolong"=>-80.2379, "geolat"=>25.7282, "crossstreet"=>nil, "id"=>10124, "phone"=>nil, "state"=>"FL", "distance"=>0.5},
209
+ {"city"=>"Coconut Grove", "address"=>"Grand Ave", "name"=>"The Jewlicious Pad", "zip"=>nil, "geolong"=>-80.2499, "geolat"=>25.7278, "crossstreet"=>nil, "id"=>80526, "phone"=>nil, "twitter"=>"jewgonewild", "state"=>"FL", "distance"=>0.5},
210
+ {"city"=>"Miami", "address"=>"3540 Main Highway", "name"=>"Taurus Chops", "zip"=>33133, "geolong"=>-80.245, "geolat"=>25.7251, "crossstreet"=>nil, "id"=>10390, "phone"=>nil, "state"=>"FL", "distance"=>0.5},
211
+ {"city"=>"Miami", "address"=>"2649 South Bayshore Drive", "name"=>"Doubletree Coconut Grove", "zip"=>33133, "geolong"=>-80.2353, "geolat"=>25.7312, "crossstreet"=>nil, "id"=>83833, "phone"=>"305-858-2500", "state"=>"FL", "distance"=>0.5}
212
+ ]
213
+ Foursquare.venues(:geolat => 25.7323, :geolong => 80.2436)
214
+ end
215
+ end
216
+
217
+ describe "#venue" do
218
+ before do
219
+ FakeWeb.register_uri(:get,
220
+ "http://user%40example.com:secret@api.playfoursquare.com/v1/venues.json?geolat=25.7323&geolong=80.2436",
221
+ :body => fakeweb_read('venues_authenticated.json'))
222
+ end
223
+
224
+ it "should return venues with user metadata" do
225
+ venues_with_user_data = [
226
+ {"city"=>"Miami", "address"=>"3064 Grand Ave", "name"=>"Sandbar", "zip"=>33133, "stats"=>{"checkins"=>18}, "geolong"=>-80.2428, "geolat"=>25.7281, "crossstreet"=>nil, "id"=>10350, "phone"=>nil, "state"=>"FL", "distance"=>0.1},
227
+ {"city"=>"Miami", "address"=>"3131 Commodore Plaza", "name"=>"Mr. Moe's", "zip"=>33133, "stats"=>{"checkins"=>6}, "geolong"=>-80.2441, "geolat"=>25.7274, "crossstreet"=>nil, "id"=>10287, "phone"=>nil, "state"=>"FL", "distance"=>0.1},
228
+ {"city"=>"Miami", "address"=>"3035 Fuller St", "name"=>"Barracuda Bar", "zip"=>33133, "stats"=>{"checkins"=>4}, "geolong"=>-80.2432, "geolat"=>25.7276, "crossstreet"=>"at Grand Ave", "id"=>18315, "phone"=>"305 448-1144", "state"=>"FL", "distance"=>0.1},
229
+ {"city"=>"Coconut Grove", "address"=>"3415 Main Hwy", "name"=>"Boardwalk Tavern & Pizzeria", "zip"=>33133, "stats"=>{"checkins"=>3}, "geolong"=>-80.2427, "geolat"=>25.7277, "crossstreet"=>nil, "id"=>45598, "phone"=>"305-567-0080", "state"=>"FL", "distance"=>0.1},
230
+ {"city"=>"Miami", "address"=>"3035 Fuller St,", "name"=>"Barracadu Bar & Grill }i{", "zip"=>33133, "geolong"=>-80.2432, "geolat"=>25.7276, "crossstreet"=>"btw Main Hwy and Grand ave", "id"=>88408, "phone"=>"(305) 448-1144", "state"=>"FL", "distance"=>0.1},
231
+ {"city"=>"Miami", "address"=>"3035 Fuller St", "name"=>"Barracadu Coconut Grove}i{", "zip"=>nil, "geolong"=>-80.2432, "geolat"=>25.7276, "crossstreet"=>"btw Main Hwy and Grand ave", "id"=>85556, "phone"=>"(305) 448-1144", "state"=>"FL", "distance"=>0.1},
232
+ {"city"=>"Miami", "address"=>"3120 Commodore Plaza", "name"=>"Don Quixote", "zip"=>33133, "geolong"=>-80.2447, "geolat"=>25.7271, "crossstreet"=>nil, "id"=>10147, "phone"=>nil, "state"=>"FL", "distance"=>0.1},
233
+ {"city"=>"Miami", "address"=>"3424 Main Highway", "name"=>"Hungry Sailor", "zip"=>33133, "geolong"=>-80.2428, "geolat"=>25.7276, "crossstreet"=>nil, "id"=>10219, "phone"=>nil, "state"=>"FL", "distance"=>0.1},
234
+ {"city"=>"Miami", "address"=>"3416 Main Highway", "name"=>"Tavern In The Grove", "zip"=>33133, "geolong"=>-80.2427, "geolat"=>25.7276, "crossstreet"=>nil, "id"=>10391, "phone"=>nil, "state"=>"FL", "distance"=>0.1},
235
+ {"city"=>"Miami", "address"=>"3480 Main Highway", "name"=>"Senor Frogs", "zip"=>33133, "geolong"=>-80.2442, "geolat"=>25.7267, "crossstreet"=>nil, "id"=>10356, "phone"=>nil, "state"=>"FL", "distance"=>0.1},
236
+ {"city"=>"Miami", "address"=>"3342 Virginia St", "name"=>"Life", "zip"=>33133, "geolong"=>-80.2415, "geolat"=>25.7289, "crossstreet"=>nil, "id"=>10252, "phone"=>nil, "state"=>"FL", "distance"=>0.2},
237
+ {"city"=>"Miami", "address"=>"3339 Virginia St", "name"=>"InfiniHQ", "zip"=>33133, "geolong"=>-80.2413, "geolat"=>25.7292, "crossstreet"=>"at Oak Ave", "id"=>84676, "phone"=>3057284641, "state"=>"FL", "distance"=>0.2},
238
+ {"city"=>"Miami", "address"=>"2895 McFarlane RD.", "name"=>"Flavour", "zip"=>33133, "geolong"=>-80.2411, "geolat"=>25.7275, "crossstreet"=>nil, "id"=>10173, "phone"=>nil, "state"=>"FL", "distance"=>0.2},
239
+ {"city"=>"Miami", "address"=>"3540 Main Highway", "name"=>"Taurus Chops", "zip"=>33133, "geolong"=>-80.245, "geolat"=>25.7251, "crossstreet"=>nil, "id"=>10390, "phone"=>nil, "state"=>"FL", "distance"=>0.2},
240
+ {"city"=>"Miami", "address"=>"2911 Grand Ave", "name"=>"Oxygen Lounge", "zip"=>33133, "geolong"=>-80.2406, "geolat"=>25.7285, "crossstreet"=>nil, "id"=>10305, "phone"=>nil, "state"=>"FL", "distance"=>0.2},
241
+ {"city"=>"Miami", "address"=>"2801 Florida Ave", "name"=>"Quench", "zip"=>33133, "geolong"=>-80.2395, "geolat"=>25.7291, "crossstreet"=>nil, "id"=>10331, "phone"=>"305 448-8150", "state"=>"FL", "distance"=>0.3},
242
+ {"city"=>"Miami", "address"=>"3390 Mary St", "name"=>"Improv Comedy Club", "zip"=>33133, "geolong"=>-80.2393, "geolat"=>25.7282, "crossstreet"=>nil, "id"=>10224, "phone"=>nil, "state"=>"FL", "distance"=>0.3},
243
+ {"city"=>"Coconut Grove", "address"=>"Grand Ave", "name"=>"The Jewlicious Pad", "zip"=>nil, "geolong"=>-80.2499, "geolat"=>25.7278, "crossstreet"=>nil, "id"=>80526, "phone"=>nil, "twitter"=>"jewgonewild", "state"=>"FL", "distance"=>0.4},
244
+ {"city"=>"Miami", "address"=>"2700 south bayshore drive", "name"=>"Cocont Grove Expo Center", "zip"=>33133, "geolong"=>-80.2379, "geolat"=>25.7282, "crossstreet"=>nil, "id"=>10124, "phone"=>nil, "state"=>"FL", "distance"=>0.4},
245
+ {"city"=>"Miami", "address"=>"650 williamstreet", "name"=>"Flordia", "zip"=>nil, "geolong"=>-80.2511, "geolat"=>25.7263, "crossstreet"=>"Sr mia", "id"=>66946, "phone"=>nil, "state"=>"FL", "distance"=>0.4},
246
+ {"city"=>"Miami", "address"=>"2649 South Bayshore Drive", "name"=>"Doubletree Coconut Grove", "zip"=>33133, "geolong"=>-80.2353, "geolat"=>25.7312, "crossstreet"=>nil, "id"=>83833, "phone"=>"305-858-2500", "state"=>"FL", "distance"=>0.6},
247
+ {"city"=>"Coconut grove", "address"=>"3381 pan American drive", "name"=>"Scottys Landing", "zip"=>33133, "geolong"=>-80.2342, "geolat"=>25.7278, "crossstreet"=>nil, "id"=>86452, "phone"=>nil, "state"=>"FL", "distance"=>0.6},
248
+ {"city"=>"Miami", "address"=>"2550 South Bayshore Drive", "name"=>"Monty's", "zip"=>33133, "geolong"=>-80.2326, "geolat"=>25.7321, "crossstreet"=>nil, "id"=>18241, "phone"=>"305 858-1431", "state"=>"FL", "distance"=>0.8},
249
+ {"city"=>"Miami", "address"=>"2884 S.W. 27th Ave", "name"=>"Berries in the Grove }i{", "zip"=>33133, "geolong"=>-80.2381, "geolat"=>25.7382, "crossstreet"=>"btw US1 and Coconut ave", "id"=>85554, "phone"=>"(305) 448-2111", "state"=>"FL", "distance"=>0.8}
250
+ ]
251
+
252
+ @foursquare = Foursquare.new(@username, @password)
253
+ @foursquare.venues(:geolat => "25.7323", :geolong => "80.2436").should == venues_with_user_data
254
+ end
255
+ end
256
+
257
+ describe ".available?" do
258
+ it "it should return true when foursquare is up" do
259
+ FakeWeb.register_uri(:get,
260
+ "http://api.playfoursquare.com/v1/test.json",
261
+ :body => fakeweb_read('test_success.json'))
262
+
263
+ Foursquare.should be_available
264
+ end
265
+
266
+ it "should return false when foursquare is down" do
267
+ FakeWeb.register_uri(:get,
268
+ "http://api.playfoursquare.com/v1/test.json",
269
+ :body => fakeweb_read('test_failure.json'))
270
+ Foursquare.should_not be_available
271
+ end
87
272
  end
88
273
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdrkeene-foursquare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keene
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -07:00
12
+ date: 2009-08-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,10 +30,10 @@ extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
32
  - LICENSE
33
- - README
33
+ - README.markdown
34
34
  files:
35
35
  - LICENSE
36
- - README
36
+ - README.markdown
37
37
  - Rakefile
38
38
  - VERSION
39
39
  - foursquare.gemspec
@@ -41,11 +41,16 @@ files:
41
41
  - lib/foursquare.rb
42
42
  - spec/fixtures/checkin_failure.json
43
43
  - spec/fixtures/checkin_success.json
44
+ - spec/fixtures/cities.json
45
+ - spec/fixtures/test_failure.json
46
+ - spec/fixtures/test_success.json
47
+ - spec/fixtures/user.json
48
+ - spec/fixtures/venues_authenticated.json
49
+ - spec/fixtures/venues_unauthenticated.json
44
50
  - spec/foursquare_spec.rb
45
51
  - spec/spec_helper.rb
46
52
  has_rdoc: false
47
53
  homepage: http://github.com/cmdrkeene/foursquare
48
- licenses:
49
54
  post_install_message:
50
55
  rdoc_options:
51
56
  - --charset=UTF-8
@@ -66,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
71
  requirements: []
67
72
 
68
73
  rubyforge_project:
69
- rubygems_version: 1.3.5
74
+ rubygems_version: 1.2.0
70
75
  signing_key:
71
76
  specification_version: 3
72
77
  summary: Ruby API for Foursquare (playfoursquare.com)
data/README DELETED
@@ -1,11 +0,0 @@
1
- = A Ruby API for Foursquare (playfoursquare.com)
2
-
3
-
4
- == Supported Actions
5
-
6
- == Check In
7
-
8
- To check into a venue by id:
9
-
10
- @foursquare = Foursquare.new(username, password)
11
- @foursquare.check_in(12345) # => {"score" => {...}, ...}