diff --git a/lib/instapaper/api/bookmarks.rb b/lib/instapaper/api/bookmarks.rb index 5448f9a..103cd4d 100644 --- a/lib/instapaper/api/bookmarks.rb +++ b/lib/instapaper/api/bookmarks.rb @@ -7,11 +7,11 @@ module Instapaper module Bookmarks # Lists the user's unread bookmarks, and can also synchronize reading positions. # @option limit: Optional. A number between 1 and 500, default 25. - # @option folder_id: Optional. Possible values are unread (default), starred, archive, or a folder_id value from /api/1/folders/list. + # @option folder_id: Optional. Possible values are unread (default), starred, archive, or a folder_id value from /api/1.1/folders/list. # @option have: Optional. A concatenation of bookmark_id values that the client already has from the specified folder. See below. # @option highlights: Optional. A '-' delimited list of highlight IDs that the client already has from the specified bookmarks. def bookmarks(options = {}) - perform_post_with_object('/api/1/bookmarks/list', options, Instapaper::BookmarkList) + perform_post_with_object('/api/1.1/bookmarks/list', options, Instapaper::BookmarkList) end # Updates the user's reading progress on a single article. @@ -19,58 +19,58 @@ module Instapaper # @param progress [Float] The user's progress, as a floating-point number between 0.0 and 1.0, defined as the top edge of the user's current viewport, expressed as a percentage of the article's total length. # @param progress_timestamp [Integer] The Unix timestamp value of the time that the progress was recorded. def update_read_progress(bookmark_id, progress, progress_timestamp = Time.now) - perform_post_with_object('/api/1/bookmarks/update_read_progress', {bookmark_id: bookmark_id, progress: progress, progress_timestamp: progress_timestamp.to_i}, Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/update_read_progress', {bookmark_id: bookmark_id, progress: progress, progress_timestamp: progress_timestamp.to_i}, Instapaper::Bookmark) end # Adds a new unread bookmark to the user's account. # @param url [String] The url of the bookmark. def add_bookmark(url, options = {}) - perform_post_with_object('/api/1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark) end # Permanently deletes the specified bookmark. # This is NOT the same as Archive. Please be clear to users if you're going to do this. # @param bookmark_id [String] The id of the bookmark. def delete_bookmark(bookmark_id) - perform_post_with_objects('/api/1/bookmarks/delete', {bookmark_id: bookmark_id}, Array) + perform_post_with_objects('/api/1.1/bookmarks/delete', {bookmark_id: bookmark_id}, Array) end # Stars the specified bookmark. # @param bookmark_id [String] The id of the bookmark. def star_bookmark(bookmark_id) - perform_post_with_object('/api/1/bookmarks/star', {bookmark_id: bookmark_id}, Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/star', {bookmark_id: bookmark_id}, Instapaper::Bookmark) end # Un-stars the specified bookmark. # @param bookmark_id [String] The id of the bookmark. def unstar_bookmark(bookmark_id) - perform_post_with_object('/api/1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark) end # Moves the specified bookmark to the Archive. # @param bookmark_id [String] The id of the bookmark. def archive_bookmark(bookmark_id) - perform_post_with_object('/api/1/bookmarks/archive', {bookmark_id: bookmark_id}, Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/archive', {bookmark_id: bookmark_id}, Instapaper::Bookmark) end # Moves the specified bookmark to the top of the Unread folder. # @param bookmark_id [String] The id of the bookmark. def unarchive_bookmark(bookmark_id) - perform_post_with_object('/api/1/bookmarks/unarchive', {bookmark_id: bookmark_id}, Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/unarchive', {bookmark_id: bookmark_id}, Instapaper::Bookmark) end # Moves the specified bookmark to a user-created folder. # @param bookmark_id [String] The id of the bookmark. # @param folder_id [String] The id of the folder to move the bookmark to. def move_bookmark(bookmark_id, folder_id) - perform_post_with_object('/api/1/bookmarks/move', {bookmark_id: bookmark_id, folder_id: folder_id}, Instapaper::Bookmark) + perform_post_with_object('/api/1.1/bookmarks/move', {bookmark_id: bookmark_id, folder_id: folder_id}, Instapaper::Bookmark) end # Returns the specified bookmark's processed text-view HTML, which is # always text/html encoded as UTF-8. # @param bookmark_id [String] The id of the bookmark. def get_text(bookmark_id) - perform_post_with_unparsed_response('/api/1/bookmarks/get_text', bookmark_id: bookmark_id) + perform_post_with_unparsed_response('/api/1.1/bookmarks/get_text', bookmark_id: bookmark_id) end end end diff --git a/spec/instapaper/api/bookmarks_spec.rb b/spec/instapaper/api/bookmarks_spec.rb index 763fa68..362d128 100644 --- a/spec/instapaper/api/bookmarks_spec.rb +++ b/spec/instapaper/api/bookmarks_spec.rb @@ -5,13 +5,13 @@ describe Instapaper::Client::Bookmarks do describe '#bookmarks' do before do - stub_post('/api/1/bookmarks/list') + stub_post('/api/1.1/bookmarks/list') .to_return(body: fixture('bookmarks_list.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.bookmarks - expect(a_post('/api/1/bookmarks/list')) + expect(a_post('/api/1.1/bookmarks/list')) .to have_been_made end @@ -32,13 +32,13 @@ describe Instapaper::Client::Bookmarks do describe '#update_read_progress' do before do @time = Time.now - stub_post('/api/1/bookmarks/update_read_progress') + stub_post('/api/1.1/bookmarks/update_read_progress') .to_return(body: fixture('bookmarks_update_read_progress.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.update_read_progress(123, 0.5, @time) - expect(a_post('/api/1/bookmarks/update_read_progress').with(body: {bookmark_id: '123', progress: '0.5', progress_timestamp: @time.to_i.to_s})) + expect(a_post('/api/1.1/bookmarks/update_read_progress').with(body: {bookmark_id: '123', progress: '0.5', progress_timestamp: @time.to_i.to_s})) .to have_been_made end @@ -51,13 +51,13 @@ describe Instapaper::Client::Bookmarks do describe '#add_bookmark' do before do - stub_post('/api/1/bookmarks/add') + stub_post('/api/1.1/bookmarks/add') .to_return(body: fixture('bookmarks_add.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.add_bookmark('http://someurl.com', title: 'This is the title', description: 'This is the description') - expect(a_post('/api/1/bookmarks/add').with(body: {url: 'http://someurl.com', title: 'This is the title', description: 'This is the description'})) + expect(a_post('/api/1.1/bookmarks/add').with(body: {url: 'http://someurl.com', title: 'This is the title', description: 'This is the description'})) .to have_been_made end @@ -69,13 +69,13 @@ describe Instapaper::Client::Bookmarks do describe '#delete_bookmark' do before do - stub_post('/api/1/bookmarks/delete') + stub_post('/api/1.1/bookmarks/delete') .to_return(body: '[]', headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.delete_bookmark(123) - expect(a_post('/api/1/bookmarks/delete').with(body: {bookmark_id: '123'})) + expect(a_post('/api/1.1/bookmarks/delete').with(body: {bookmark_id: '123'})) .to have_been_made end @@ -88,13 +88,13 @@ describe Instapaper::Client::Bookmarks do describe '#star_bookmark' do before do - stub_post('/api/1/bookmarks/star') + stub_post('/api/1.1/bookmarks/star') .to_return(body: fixture('bookmarks_star.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.star_bookmark(123) - expect(a_post('/api/1/bookmarks/star').with(body: {bookmark_id: '123'})) + expect(a_post('/api/1.1/bookmarks/star').with(body: {bookmark_id: '123'})) .to have_been_made end @@ -107,13 +107,13 @@ describe Instapaper::Client::Bookmarks do describe '#unstar_bookmark' do before do - stub_post('/api/1/bookmarks/unstar') + stub_post('/api/1.1/bookmarks/unstar') .to_return(body: fixture('bookmarks_unstar.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.unstar_bookmark(123) - expect(a_post('/api/1/bookmarks/unstar').with(body: {bookmark_id: '123'})) + expect(a_post('/api/1.1/bookmarks/unstar').with(body: {bookmark_id: '123'})) .to have_been_made end @@ -126,13 +126,13 @@ describe Instapaper::Client::Bookmarks do describe '#archive_bookmark' do before do - stub_post('/api/1/bookmarks/archive') + stub_post('/api/1.1/bookmarks/archive') .to_return(body: fixture('bookmarks_archive.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.archive_bookmark(123) - expect(a_post('/api/1/bookmarks/archive').with(body: {bookmark_id: '123'})) + expect(a_post('/api/1.1/bookmarks/archive').with(body: {bookmark_id: '123'})) .to have_been_made end @@ -144,13 +144,13 @@ describe Instapaper::Client::Bookmarks do describe '#unarchive_bookmark' do before do - stub_post('/api/1/bookmarks/unarchive') + stub_post('/api/1.1/bookmarks/unarchive') .to_return(body: fixture('bookmarks_unarchive.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.unarchive_bookmark(123) - expect(a_post('/api/1/bookmarks/unarchive').with(body: {bookmark_id: '123'})) + expect(a_post('/api/1.1/bookmarks/unarchive').with(body: {bookmark_id: '123'})) .to have_been_made end @@ -162,13 +162,13 @@ describe Instapaper::Client::Bookmarks do describe '#move_bookmark' do before do - stub_post('/api/1/bookmarks/move') + stub_post('/api/1.1/bookmarks/move') .to_return(body: fixture('bookmarks_move.json'), headers: {content_type: 'application/json; charset=utf-8'}) end it 'gets the correct resource' do client.move_bookmark(123, 12_345) - expect(a_post('/api/1/bookmarks/move').with(body: {bookmark_id: '123', folder_id: '12345'})) + expect(a_post('/api/1.1/bookmarks/move').with(body: {bookmark_id: '123', folder_id: '12345'})) .to have_been_made end @@ -180,13 +180,13 @@ describe Instapaper::Client::Bookmarks do describe '#get_text' do before do - stub_post('/api/1/bookmarks/get_text') + stub_post('/api/1.1/bookmarks/get_text') .to_return(body: fixture('bookmarks_get_text.txt'), headers: {content_type: 'text/html; charset=utf-8'}) end it 'gets the correct resource' do client.get_text(123) - expect(a_post('/api/1/bookmarks/get_text').with(body: {bookmark_id: '123'})) + expect(a_post('/api/1.1/bookmarks/get_text').with(body: {bookmark_id: '123'})) .to have_been_made end