gowalla 0.0.1 → 0.1.0

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.
@@ -1,41 +1,41 @@
1
1
  {
2
- "accept_url": "/friendships/accept?user_id=1707",
3
- "activity_url": "/users/1707/events",
4
- "bio": "Web designer and Ruby developer.",
5
- "events_url": "/users/1707/events",
6
- "fb_id": 605681706,
7
- "first_name": "Wynn",
8
- "friends_count": 27,
9
- "friends_only": false,
10
- "friends_url": "/users/1707/friends",
11
- "hometown": "Aubrey, TX",
12
- "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/1707-standard.jpg?1262011383",
13
- "is_friend": false,
14
- "items_count": 5,
15
- "items_url": "/users/1707/items",
16
- "last_name": "Netherland",
17
- "last_visit": {
18
- "comment": "Closing every account I have ",
19
- "created_at": "2010/01/26 15:31:46 +0000",
20
- "spot": {
21
- "image_url": "http://static.gowalla.com/categories/186-standard.png",
22
- "name": "Bank Of America",
23
- "small_image_url": "http://static.gowalla.com/categories/186-small-standard.png",
24
- "url": "/spots/164052"
25
- }
26
- },
27
- "name": "Wynn Netherland",
28
- "pins_count": 3,
29
- "pins_url": "/users/1707/pins",
30
- "reject_url": "/friendships/reject?user_id=1707",
31
- "request_url": "/friendships/request?user_id=1707",
32
- "stamps_count": 15,
33
- "stamps_url": "/users/1707/stamps",
34
- "top_spots_url": "/users/1707/top_spots",
35
- "twitter_username": "pengwynn",
36
- "url": "/users/1707",
37
- "username": "pengwynn",
38
- "vaulted_kinds_count": 0,
39
- "visited_spots_count": 15,
40
- "website": "http://wynnnetherland.com"
41
- }
2
+ "pins_count": 19,
3
+ "items_count": 10,
4
+ "stamps_count": 486,
5
+ "friends_url": "/users/1/friends",
6
+ "first_name": "Scott",
7
+ "vaulted_kinds_count": 53,
8
+ "friends_count": 416,
9
+ "fb_id": 505421674,
10
+ "request_url": "/friendships/request?user_id=1",
11
+ "activity_url": "/users/1/events",
12
+ "name": "Scott Raymond",
13
+ "hometown": "Austin, Texas",
14
+ "stamps_url": "/users/1/stamps",
15
+ "twitter_username": null,
16
+ "events_url": "/users/1/events",
17
+ "pins_url": "/users/1/pins",
18
+ "accept_url": "/friendships/accept?user_id=1",
19
+ "last_visit": {
20
+ "spot": {
21
+ "name": "Tropisueño",
22
+ "image_url": "http://static.gowalla.com/categories/15-standard.png",
23
+ "url": "/spots/19199",
24
+ "small_image_url": "http://static.gowalla.com/categories/15-small-standard.png"
25
+ },
26
+ "comment": "This is a test...",
27
+ "created_at": "2010/02/10 01:41:16 +0000"
28
+ },
29
+ "url": "/users/1",
30
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/1-standard.jpg?1263521844",
31
+ "website": "",
32
+ "items_url": "/users/1/items",
33
+ "is_friend": false,
34
+ "last_name": "Raymond",
35
+ "username": "sco",
36
+ "friends_only": false,
37
+ "reject_url": "/friendships/reject?user_id=1",
38
+ "visited_spots_count": 486,
39
+ "bio": "CTO & co-founder of Gowalla. Ruby/Cocoa/JavaScript developer. Game designer. Author. Indoorsman.",
40
+ "top_spots_url": "/users/1/top_spots"
41
+ }
data/test/test_gowalla.rb CHANGED
@@ -2,13 +2,122 @@ require 'helper'
2
2
 
3
3
  class TestGowalla < Test::Unit::TestCase
4
4
 
5
- context "When hitting the Gowalla API authenticated" do
5
+ context "When using the documented Gowalla API" do
6
6
  setup do
7
- @client = Gowalla::Client.new('pengwynn', '0U812')
7
+ @client = Gowalla::Client.new(:username => 'pengwynn', :password => '0U812', :api_key => 'gowallawallabingbang')
8
8
  end
9
9
 
10
+ context "and working with Spots" do
11
+ should "Retrieve a list of spots within a specified distance of a location" do
12
+ stub_get("http://pengwynn:0U812@api.gowalla.com/spots?lat=%2B33.237593417&lng=-96.960559033&radius=50", "spots.json")
13
+ spots = @client.list_spots(:lat => 33.237593417, :lng => -96.960559033, :radius => 50)
14
+ spots.first.name.should == 'Gnomb Bar'
15
+ spots.first.radius_meters.should == 50
16
+ end
17
+
18
+ should "Retrieve information about a specific spot" do
19
+ stub_get('http://pengwynn:0U812@api.gowalla.com/spots/18568', 'spot.json')
20
+ spot = @client.spot(18568)
21
+ spot.name.should == "Wahoo's"
22
+ spot.twitter_username.should == 'Wahoos512'
23
+ spot.categories.first.name.should == 'Mexican'
24
+ end
25
+
26
+ should "retrieve a list of check-ins at a particular spot. Shows only the activity that is visible to a given user" do
27
+ stub_get('http://pengwynn:0U812@api.gowalla.com/spots/452593/events', 'events.json')
28
+ events = @client.spot_events(452593)
29
+ events.first[:type].should == 'visit'
30
+ events.first.user.username.should == 'whurley'
31
+ end
32
+
33
+ should "retrieve a list of items available at a particular spot" do
34
+ stub_get('http://pengwynn:0U812@api.gowalla.com/spots/18568/items', 'items.json')
35
+ items = @client.spot_items(18568)
36
+ items.first.issue_number.should == 23121
37
+ items.first.name.should == 'Espresso'
38
+ end
39
+
40
+ should "lists all spot categories" do
41
+ stub_get("http://pengwynn:0U812@api.gowalla.com/categories", "categories.json")
42
+ categories = @client.categories
43
+ categories.size.should == 9
44
+ categories.first.name.should == 'Architecture & Buildings'
45
+ categories.first.description.should == 'Bridge, Corporate, Home, Church, etc.'
46
+ categories.first.categories.size.should == 15
47
+ categories.first.categories.first.name.should == 'Bridge'
48
+ end
49
+
50
+ should "retrieve information about a specific category" do
51
+ stub_get("http://pengwynn:0U812@api.gowalla.com/categories/1", "category.json")
52
+ category = @client.category(1)
53
+ category.name.should == 'Coffee Shop'
54
+ category.id.should == 1
55
+ end
56
+ end
57
+
58
+ context "and working with Users" do
59
+
60
+ should "retrieve information about a specific user" do
61
+ stub_get('http://pengwynn:0U812@api.gowalla.com/users/sco', 'user.json')
62
+ user = @client.user('sco')
63
+ user.bio.should == "CTO & co-founder of Gowalla. Ruby/Cocoa/JavaScript developer. Game designer. Author. Indoorsman."
64
+ user.stamps_count.should == 486
65
+ end
66
+
67
+ should "retrieve a list of the stamps the user has collected" do
68
+ stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/stamps?limit=20', 'stamps.json')
69
+ stamps = @client.stamps(1707)
70
+ stamps.size.should == 15
71
+ stamps.first.name.should == 'Bank Of America'
72
+ stamps.first.tier.should == 2
73
+ end
74
+
75
+ should "retrieve a list of spots the user has visited most often" do
76
+ stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/top_spots', 'top_spots.json')
77
+ top_spots = @client.top_spots(1707)
78
+ top_spots.size.should == 10
79
+ top_spots.first.name.should == 'Bank Of America'
80
+ top_spots.first.visits_count.should == "1"
81
+ end
82
+
83
+ end
84
+
85
+ context "and working with Items" do
86
+ should "retrieve information about a specific item" do
87
+ stub_get('http://pengwynn:0U812@api.gowalla.com/items/607583', 'item.json')
88
+ item = @client.item(607583)
89
+ item.issue_number.should == 13998
90
+ item.name.should == 'Sweets'
91
+ item.events.first.spot.name.should == 'Jerusalem Bakery'
92
+ end
93
+ end
94
+
95
+ context "and working with Trips" do
96
+ should "retrieve a list of trips" do
97
+ stub_get('http://pengwynn:0U812@api.gowalla.com/trips', 'trips.json')
98
+ trips = @client.trips
99
+ trips.first.featured?.should == true
100
+ trips.first.spots.first.url.should == '/spots/164009'
101
+ end
102
+
103
+ should "retrieve information about a specific trip" do
104
+ stub_get('http://pengwynn:0U812@api.gowalla.com/trips/1', 'trip.json')
105
+ trip = @client.trip(1)
106
+ trip.creator.name.should == 'Team Gowalla'
107
+ trip.map_bounds.east.should == -63.457031000000001
108
+ end
109
+ end
110
+
111
+ end
112
+
113
+ context "When using the UNDOCUMENTED Gowalla API" do
114
+ setup do
115
+ @client = Gowalla::Client.new(:username => 'pengwynn', :password => '0U812', :api_key => 'gowallawallabingbang')
116
+ end
117
+
118
+
10
119
  should "retrieve details for the current user" do
11
- stub_get('http://pengwynn:0U812@api.gowalla.com/users/me', 'me.json')
120
+ stub_get('http://pengwynn:0U812@api.gowalla.com/users/pengwynn', 'me.json')
12
121
  user = @client.user
13
122
  user.can_post_to_twitter?.should == true
14
123
  user.can_post_to_facebook?.should == true
@@ -28,15 +137,15 @@ class TestGowalla < Test::Unit::TestCase
28
137
  should "retrieve events for a user" do
29
138
  stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/events', 'events.json')
30
139
  events = @client.events(1707)
31
- events.first.comment.should == 'Closing every account I have '
32
- events.last.spot.name.should == 'Grape Creek Vineyards'
140
+ events.first[:type].should == 'visit'
141
+ events.first.user.username.should == 'whurley'
33
142
  end
34
143
 
35
144
  should "retrieve events for a user's friends" do
36
145
  stub_get('http://pengwynn:0U812@api.gowalla.com/visits/recent', 'events.json')
37
146
  events = @client.friends_events
38
- events.first.comment.should == 'Closing every account I have '
39
- events.last.spot.name.should == 'Grape Creek Vineyards'
147
+ events.first[:type].should == 'visit'
148
+ events.first.user.username.should == 'whurley'
40
149
  end
41
150
 
42
151
  should "retrieve friend requests for a user" do
@@ -54,8 +163,8 @@ class TestGowalla < Test::Unit::TestCase
54
163
  should "retrieve items for a user" do
55
164
  stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/items', 'items.json')
56
165
  items = @client.items(1707)
57
- items.size.should == 5
58
- items.first.name.should == 'Stationery'
166
+ items.first.issue_number.should == 23121
167
+ items.first.name.should == 'Espresso'
59
168
  end
60
169
 
61
170
  should "retrieve pins for a user" do
@@ -65,22 +174,6 @@ class TestGowalla < Test::Unit::TestCase
65
174
  pins.first.name.should == 'Ranger'
66
175
  end
67
176
 
68
- should "retrieve stamps for a user" do
69
- stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/stamps', 'stamps.json')
70
- stamps = @client.stamps(1707)
71
- stamps.size.should == 15
72
- stamps.first.name.should == 'Bank Of America'
73
- stamps.first.tier.should == 2
74
- end
75
-
76
- should "retrieve top spots for a user" do
77
- stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/top_spots', 'top_spots.json')
78
- top_spots = @client.top_spots(1707)
79
- top_spots.size.should == 10
80
- top_spots.first.name.should == 'Bank Of America'
81
- top_spots.first.visits_count.should == "1"
82
- end
83
-
84
177
  should "retrieve visited spots for a user" do
85
178
  stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/visited_spots', 'visited_spots.json')
86
179
  visited_spots = @client.visited_spots(1707)
@@ -89,83 +182,107 @@ class TestGowalla < Test::Unit::TestCase
89
182
  end
90
183
 
91
184
  should_eventually "request a friendship with a user" do
92
-
185
+ # POST http://api.gowalla.com/friendships/accept?user_id=104421
93
186
  end
94
187
 
95
188
  should_eventually "accept a friendship with a user" do
96
189
 
97
190
  end
98
191
 
99
- should "retrieve details for a trip" do
100
- stub_get('http://pengwynn:0U812@api.gowalla.com/trips/1', 'trip.json')
101
- trip = @client.trip(1)
102
- trip.creator.name.should == 'Team Gowalla'
103
- trip.map_bounds.east.should == -63.457031000000001
104
- end
105
-
106
192
  should "retrieve details for a spot" do
107
193
  stub_get('http://pengwynn:0U812@api.gowalla.com/spots/452593', 'spot.json')
108
194
  spot = @client.spot(452593)
109
- spot.name.should == 'Paloma Creek Elementary'
110
- spot.categories.first.name.should == 'Other - College & Education'
111
- end
112
-
113
- should "retrieve events for a spot" do
114
- stub_get('http://pengwynn:0U812@api.gowalla.com/spots/452593/events', 'events.json')
115
- events = @client.spot_events(452593)
116
- events.first.comment.should == 'Closing every account I have '
117
- events.last.spot.name.should == 'Grape Creek Vineyards'
195
+ spot.name.should == "Wahoo's"
196
+ spot.twitter_username.should == 'Wahoos512'
197
+ spot.categories.first.name.should == 'Mexican'
118
198
  end
199
+
119
200
 
120
201
  should_eventually "drop an item" do
121
-
202
+ # POST http://api.gowalla.com/items/899654/drop
203
+ # BODY spot_url=/spots/472093
122
204
  end
123
205
 
124
206
  should_eventually "pick up an item" do
125
207
 
126
208
  end
127
209
 
128
-
129
- end
130
-
131
- context "when hitting the Gowalla API unauthenticated" do
132
-
133
210
 
134
- should "retrieve details for a user" do
135
- stub_get('/users/1707', 'user.json')
136
- user = Gowalla.user(1707)
137
- user.bio.should == "Web designer and Ruby developer."
138
- user.stamps_count.should == 15
211
+
212
+ should "find featured spots by latitude and longitude" do
213
+ stub_get("http://pengwynn:0U812@api.gowalla.com/spots?featured=1&lat=%2B33.237593417&lng=-96.960559033", "spots.json")
214
+ spots = @client.featured_spots(:lat => 33.237593417, :lng => -96.960559033)
215
+ spots.first.name.should == 'Gnomb Bar'
216
+ spots.first.radius_meters.should == 50
139
217
  end
140
218
 
141
- should "retrieve events for a user" do
142
- stub_get('/users/1707/events', 'events.json')
143
- events = Gowalla.events(1707)
144
- events.first.comment.should == 'Closing every account I have '
145
- events.last.spot.name.should == 'Grape Creek Vineyards'
219
+ should "find bookmarked spots by latitude and longitude" do
220
+ stub_get("http://pengwynn:0U812@api.gowalla.com/spots?bookmarked=1&lat=%2B33.237593417&lng=-96.960559033", "spots.json")
221
+ spots = @client.bookmarked_spots(:lat => 33.237593417, :lng => -96.960559033)
222
+ spots.first.name.should == 'Gnomb Bar'
223
+ spots.first.radius_meters.should == 50
146
224
  end
147
225
 
148
- should "retrieve details for a trip" do
149
- stub_get('/trips/1', 'trip.json')
150
- trip = Gowalla.trip(1)
151
- trip.creator.name.should == 'Team Gowalla'
152
- trip.map_bounds.east.should == -63.457031000000001
226
+ should "find spots by category, latitude, and longitude" do
227
+ stub_get("http://pengwynn:0U812@api.gowalla.com/spots?category_id=13&lat=%2B33.237593417&lng=-96.960559033", "spots.json")
228
+ spots = @client.list_spots(:lat => 33.237593417, :lng => -96.960559033, :category_id => 13)
229
+ spots.first.name.should == 'Gnomb Bar'
230
+ spots.first.radius_meters.should == 50
153
231
  end
154
232
 
155
- should "retrieve details for a spot" do
156
- stub_get('/spots/452593', 'spot.json')
157
- spot = Gowalla.spot(452593)
158
- spot.name.should == 'Paloma Creek Elementary'
159
- spot.categories.first.name.should == 'Other - College & Education'
233
+ should "find trips by latitude and longitude" do
234
+ stub_get("http://pengwynn:0U812@api.gowalla.com/trips?user_url=%2Fusers%2F1707&lat=%2B33.23404216&lng=-96.95513802", "find_trips.json")
235
+ trips = @client.trips(:lat => 33.234042160, :lng => -96.955138020, :user_id => 1707)
236
+ trips.first.name.should == 'Dallas Championship Chase'
237
+ trips.first.spots.size.should == 3
238
+ trips.first.published?.should == true
239
+ end
240
+
241
+ should "find featured trips by latitude, longitude, and user" do
242
+ stub_get("http://pengwynn:0U812@api.gowalla.com/trips?context=featured&user_url=%2Fusers%2F1707&lat=%2B33.23404216&lng=-96.95513802", "find_trips.json")
243
+ trips = @client.featured_trips(:lat => 33.234042160, :lng => -96.955138020, :user_id => 1707, :context => 'featured')
244
+ trips.first.name.should == 'Dallas Championship Chase'
245
+ trips.first.spots.size.should == 3
246
+ trips.first.published?.should == true
247
+ end
248
+
249
+ should "find friends trips by latitude, longitude, and user" do
250
+ stub_get("http://pengwynn:0U812@api.gowalla.com/trips?context=friends&user_url=%2Fusers%2F1707&lat=%2B33.23404216&lng=-96.95513802", "find_trips.json")
251
+ trips = @client.friends_trips(:lat => 33.234042160, :lng => -96.955138020, :user_id => 1707, :context => 'featured')
252
+ trips.first.name.should == 'Dallas Championship Chase'
253
+ trips.first.spots.size.should == 3
254
+ trips.first.published?.should == true
255
+ end
256
+
257
+
258
+
259
+ should_eventually "create a spot" do
260
+ # POST http://api.gowalla.com/spots
261
+ # BODY lat=33.23404216&name=TreeFrog%20Studios&category_url=/categories/217&description=Children%20and%20family%20photography%20studio&lng=-96.95513802000001
160
262
  end
161
263
 
162
- should "retrieve events for a spot" do
163
- stub_get('/spots/452593/events', 'events.json')
164
- events = Gowalla.spot_events(452593)
165
- events.first.comment.should == 'Closing every account I have '
166
- events.last.spot.name.should == 'Grape Creek Vineyards'
264
+ should_eventually "check in at a spot" do
265
+ # POST http://api.gowalla.com/visits?spot_id=472093
266
+ # BODY fb_id=605681706&lat=33.23404216&accuracy=2055&post_to_facebook=0&fb_session_key=976e56d6baa517cfe77eadfc-605681706&lng=-96.95513802000001&comment=Testing%20Gowalla%20API%20&post_to_twitter=1
167
267
  end
168
268
 
269
+
270
+ end
271
+
272
+ should "configure api_key, username, and password for easy access" do
273
+
274
+ Gowalla.configure do |config|
275
+ config.api_key = 'api_key'
276
+ config.username = 'username'
277
+ config.password = 'password'
278
+ end
279
+
280
+ @client = Gowalla::Client.new
281
+
282
+ stub_get('http://username:password@api.gowalla.com/trips', 'trips.json')
283
+ trips = @client.trips
284
+
285
+ @client.username.should == 'username'
169
286
  end
170
287
 
171
288
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gowalla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-29 00:00:00 -06:00
12
+ date: 2010-02-09 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -89,21 +89,31 @@ files:
89
89
  - Rakefile
90
90
  - VERSION
91
91
  - changelog.md
92
+ - gowalla.gemspec
92
93
  - lib/gowalla.rb
93
94
  - lib/gowalla/client.rb
95
+ - test/fixtures/categories.json
96
+ - test/fixtures/category.json
97
+ - test/fixtures/challenges.json
94
98
  - test/fixtures/events.json
99
+ - test/fixtures/find_spots.json
100
+ - test/fixtures/find_trips.json
95
101
  - test/fixtures/friend_requests.json
96
102
  - test/fixtures/friends.json
97
103
  - test/fixtures/friends_recent.json
104
+ - test/fixtures/item.json
98
105
  - test/fixtures/items.json
99
106
  - test/fixtures/me.json
107
+ - test/fixtures/new_spot.json
100
108
  - test/fixtures/pins.json
101
109
  - test/fixtures/potential_twitter_friends.json
102
110
  - test/fixtures/spot.json
103
111
  - test/fixtures/spots.json
112
+ - test/fixtures/spots_by_category.json
104
113
  - test/fixtures/stamps.json
105
114
  - test/fixtures/top_spots.json
106
115
  - test/fixtures/trip.json
116
+ - test/fixtures/trips.json
107
117
  - test/fixtures/user.json
108
118
  - test/fixtures/visited_spots.json
109
119
  - test/helper.rb