mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
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:
parent
13b278932b
commit
45c110f96d
4 changed files with 18 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ module Instapaper
|
||||||
# List highlights for a bookmark
|
# List highlights for a bookmark
|
||||||
# @param bookmark_id [String, Integer]
|
# @param bookmark_id [String, Integer]
|
||||||
def highlights(bookmark_id)
|
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
|
end
|
||||||
|
|
||||||
# Create a new highlight
|
# Create a new highlight
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@ module Instapaper
|
||||||
perform_request_with_objects(:post, path, options, klass)
|
perform_request_with_objects(:post, path, options, klass)
|
||||||
end
|
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 request_method [Symbol]
|
||||||
# @param path [String]
|
# @param path [String]
|
||||||
# @param options [Hash]
|
# @param options [Hash]
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ describe Instapaper::Client::Highlights do
|
||||||
|
|
||||||
describe '#highlights' do
|
describe '#highlights' do
|
||||||
before 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'})
|
.to_return(status: 200, body: fixture('highlights_list.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'gets the correct resource' do
|
it 'gets the correct resource' do
|
||||||
client.highlights(123)
|
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
|
end
|
||||||
|
|
||||||
it 'returns an array containing folders on success' do
|
it 'returns an array containing folders on success' do
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,18 @@ def a_post(path)
|
||||||
a_request(:post, Instapaper::HTTP::Request::BASE_URL + path)
|
a_request(:post, Instapaper::HTTP::Request::BASE_URL + path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def a_get(path)
|
||||||
|
a_request(:get, Instapaper::HTTP::Request::BASE_URL + path)
|
||||||
|
end
|
||||||
|
|
||||||
def stub_post(path)
|
def stub_post(path)
|
||||||
stub_request(:post, Instapaper::HTTP::Request::BASE_URL + path)
|
stub_request(:post, Instapaper::HTTP::Request::BASE_URL + path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stub_get(path)
|
||||||
|
stub_request(:get, Instapaper::HTTP::Request::BASE_URL + path)
|
||||||
|
end
|
||||||
|
|
||||||
def fixture_path
|
def fixture_path
|
||||||
File.expand_path('../fixtures', __FILE__)
|
File.expand_path('../fixtures', __FILE__)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue