From ebfa633d1b30762c5c68ab2ba5343897300eee7b Mon Sep 17 00:00:00 2001 From: Fletcher Richman Date: Thu, 27 Jun 2013 15:11:40 -0600 Subject: [PATCH 1/2] updated delete_list_item method to take an options param, tests passing --- lib/foursquare2/lists.rb | 9 ++++++--- test/test_lists.rb | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/foursquare2/lists.rb b/lib/foursquare2/lists.rb index 60813d0..5baf440 100644 --- a/lib/foursquare2/lists.rb +++ b/lib/foursquare2/lists.rb @@ -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 diff --git a/test/test_lists.rb b/test/test_lists.rb index 2056b41..6d48d10 100644 --- a/test/test_lists.rb +++ b/test/test_lists.rb @@ -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 = 'vgit 4ba19cb0f964a520c2c337e3' + 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' From 283575f14d31235d43396a2b944f4d5a48946e32 Mon Sep 17 00:00:00 2001 From: Fletcher Richman Date: Thu, 27 Jun 2013 15:13:15 -0600 Subject: [PATCH 2/2] fixed typo --- test/test_lists.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_lists.rb b/test/test_lists.rb index 6d48d10..3f5ecea 100644 --- a/test/test_lists.rb +++ b/test/test_lists.rb @@ -54,7 +54,7 @@ class TestLists < Test::Unit::TestCase end should "delete a venue from a list" do - venue_id = 'vgit 4ba19cb0f964a520c2c337e3' + 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