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

Feature/deletelistvenue #66

Open
wants to merge 2 commits 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
9 changes: 6 additions & 3 deletions lib/foursquare2/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ def add_list_item(list_id, options={})
# Delete an item from a list: https://developer.foursquare.com/docs/lists/deleteitem
#
# @param [String] list_id - The id of the list to delete item from
# @param [String] item_id = The id of the item to delete from list
# @param [Hash] options (choose one)
# @option options String :itemId - Used to remove an item from a list
# @option options String :venueId - Used to remove all instances of a venue from a list
# @option options String :tipId - Used to remove a tip from a list

def delete_list_item(list_id, item_id)
def delete_list_item(list_id, options={})
response = connection.post do |req|
req.url "lists/#{list_id}/deleteitem", :itemId => item_id
req.url "lists/#{list_id}/deleteitem", options
end
return_error_or_body(response, response.body.response.item)
end
Expand Down
9 changes: 8 additions & 1 deletion test/test_lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ class TestLists < Test::Unit::TestCase
should "delete an item from a list" do
item_id = 'v4ba19cb0f964a520c2c337e3'
stub_post("https://api.foursquare.com/v2/lists/#{@list_id}/deleteitem?oauth_token=#{@client.oauth_token}&itemId=#{item_id}", "lists/list_item.json")
item = @client.delete_list_item(@list_id, item_id)
item = @client.delete_list_item(@list_id, :itemId => item_id)
item.id.should == item_id
end

should "delete a venue from a list" do
venue_id = 'v4ba19cb0f964a520c2c337e3'
stub_post("https://api.foursquare.com/v2/lists/#{@list_id}/deleteitem?oauth_token=#{@client.oauth_token}&venueId=#{venue_id}", "lists/list_item.json")
venue = @client.delete_list_item(@list_id, :venueId => venue_id)
venue.id.should == venue_id
end

should "move an item on a list" do
item_id = 't4d404fc934f42d43b2624385'
before_id = 'v4a01c477f964a520f9701fe3'
Expand Down