Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added Pagination Option for User Events #19

Closed
wants to merge 1 commit into from

2 participants

@tylerhunt

Without this, there's no way to pull down the full history of a user's checkins.

@ehutzelman
Collaborator

integrated, thanks!

@ehutzelman ehutzelman closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 7, 2011
  1. @tylerhunt
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 2 deletions.
  1. +5 −2 lib/gowalla/users.rb
  2. +8 −0 test/users_test.rb
View
7 lib/gowalla/users.rb
@@ -41,9 +41,12 @@ def visited_spots_urls(user_id=self.username)
# Retrieve a list of the user's most recent checkins.
#
# @param [String] user_id (authenticated basic auth user) User ID (screen name)
+ # @option options [Integer] :page Results page number
+ # @option options [Integer] :per_page Results page number
# @return [Hashie::Mash] Array of checkin events
- def user_events(user_id=self.username)
- connection.get("/users/#{user_id}/events").body.activity
+ def user_events(user_id=self.username, options={})
+ query = options.collect { |pair| pair.join('=') }.join('&')
+ connection.get(["/users/#{user_id}/events", query].join('?')).body.activity
end
# Retrieve a list of items the user is carrying
View
8 test/users_test.rb
@@ -52,6 +52,14 @@ class UsersTest < Test::Unit::TestCase
user_events.first.spot.name.should == "Barktoberfest"
end
+ should "retrieve a list of the user's most recent checkins with pagination" do
+ stub_get('https://pengwynn:0U812@api.gowalla.com/users/1707/events?page=2&per_page=50', 'user_events.json')
+ user_events = @client.user_events(1707, :page => 2, :per_page => 50)
+ user_events.size.should == 10
+ user_events.first.url.should == '/checkins/18863224'
+ user_events.first.spot.name.should == "Barktoberfest"
+ end
+
should "retrieve a list of items the user is carrying" do
stub_get('https://pengwynn:0U812@api.gowalla.com/users/sco/items?context=vault', 'items.json')
items = @client.user_items('sco', 'vault')
Something went wrong with that request. Please try again.