highlights return successfully with a GET request

NOTE: This is undocumented and unconfirmed by Instapaper, but was
discovered through trial and error.
This commit is contained in:
stve 2015-10-06 10:15:31 -04:00
parent 13b278932b
commit 45c110f96d
4 changed files with 18 additions and 3 deletions

View file

@ -7,7 +7,7 @@ module Instapaper
# List highlights for a bookmark
# @param bookmark_id [String, Integer]
def highlights(bookmark_id)
perform_post_with_objects("/api/1.1/bookmarks/#{bookmark_id}/highlights", {}, Instapaper::Highlight)
perform_get_with_objects("/api/1.1/bookmarks/#{bookmark_id}/highlights", {}, Instapaper::Highlight)
end
# Create a new highlight

View file

@ -12,6 +12,13 @@ module Instapaper
perform_request_with_objects(:post, path, options, klass)
end
# @param path [String]
# @param options [Hash]
# @param klass [Class]
def perform_get_with_objects(path, options, klass)
perform_request_with_objects(:get, path, options, klass)
end
# @param request_method [Symbol]
# @param path [String]
# @param options [Hash]

View file

@ -5,13 +5,13 @@ describe Instapaper::Client::Highlights do
describe '#highlights' do
before do
stub_post('/api/1.1/bookmarks/123/highlights')
stub_get('/api/1.1/bookmarks/123/highlights')
.to_return(status: 200, body: fixture('highlights_list.json'), headers: {content_type: 'application/json; charset=utf-8'})
end
it 'gets the correct resource' do
client.highlights(123)
expect(a_post('/api/1.1/bookmarks/123/highlights')).to have_been_made
expect(a_get('/api/1.1/bookmarks/123/highlights')).to have_been_made
end
it 'returns an array containing folders on success' do

View file

@ -13,10 +13,18 @@ def a_post(path)
a_request(:post, Instapaper::HTTP::Request::BASE_URL + path)
end
def a_get(path)
a_request(:get, Instapaper::HTTP::Request::BASE_URL + path)
end
def stub_post(path)
stub_request(:post, Instapaper::HTTP::Request::BASE_URL + path)
end
def stub_get(path)
stub_request(:get, Instapaper::HTTP::Request::BASE_URL + path)
end
def fixture_path
File.expand_path('../fixtures', __FILE__)
end