Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for checkins/resolve endpoint #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ See [the documentation](http://rubydoc.info/gems/foursquare2/frames) for a list
See [the documentation](http://rubydoc.info/gems/foursquare2/frames) or [foursquare's endpoint list](http://developer.foursquare.com/docs/index_docs.html) for parameters.

client.checkin
client.resolve_checkin
client.recent_checkins
client.add_checkin
client.add_checkin_comment
Expand Down
14 changes: 14 additions & 0 deletions lib/foursquare2/checkins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ def checkin(checkin_id, options={})
return_error_or_body(response, response.body.response.checkin)
end

# Resolve checkin associated with a short ID at the end of a swarmapp.com link,
# e.g., https://swarmapp.com/c/abc123ZYX
#
# @param [Hash] options
# @option options String :shortId - ID at the end of a swarmapp.com link.

def resolve_checkin(options={})
response = connection.get do |req|
req.url "checkins/resolve", options
end
return_error_or_body(response, response.body.response.checkin)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice 👍



# Retrive a list of recent checkins from friends.
#
# @param [Hash] options
Expand Down
7 changes: 7 additions & 0 deletions test/test_checkins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class TestCheckins < Test::Unit::TestCase
checkin.user.firstName.should == 'Matt'
end

should "resolve a checkin by a short ID" do
stub_get("https://api.foursquare.com/v2/checkins/resolve?shortId=fP44HxXzikm&oauth_token=#{@client.oauth_token}", "checkins/checkin.json")
checkin = @client.resolve_checkin(shortId: 'fP44HxXzikm')
checkin.venue.name.should == 'Bridgestone Arena'
checkin.user.firstName.should == 'Matt'
end

should "fetch recent checkins from friends"do
stub_get("https://api.foursquare.com/v2/checkins/recent?oauth_token=#{@client.oauth_token}&limit=2", "checkins/friend_checkins.json")
checkins = @client.recent_checkins(:limit => 2)
Expand Down