Module: Instapaper::API::Bookmarks

Included in:
Instapaper::API
Defined in:
lib/instapaper/api/bookmarks.rb

Overview

Defines methods related to bookmarks

Instance Method Summary collapse

Instance Method Details

#add_bookmark(url, options = {}) ⇒ Object

Adds a new unread bookmark to the user's account.

Parameters:

  • url (String)

    The url of the bookmark.


27
28
29
# File 'lib/instapaper/api/bookmarks.rb', line 27

def add_bookmark(url, options = {})
  perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)
end

#archive_bookmark(bookmark_id) ⇒ Object

Moves the specified bookmark to the Archive.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.


52
53
54
# File 'lib/instapaper/api/bookmarks.rb', line 52

def archive_bookmark(bookmark_id)
  perform_post_with_object('/api/1.1/bookmarks/archive', {bookmark_id: bookmark_id}, Instapaper::Bookmark)
end

#bookmarks(options = {}) ⇒ Object

Lists the user's unread bookmarks, and can also synchronize reading positions.

Parameters:

  • limit: (Hash)

    a customizable set of options

  • folder_id: (Hash)

    a customizable set of options

  • have: (Hash)

    a customizable set of options

  • highlights: (Hash)

    a customizable set of options


13
14
15
# File 'lib/instapaper/api/bookmarks.rb', line 13

def bookmarks(options = {})
  perform_post_with_object('/api/1.1/bookmarks/list', options, Instapaper::BookmarkList)
end

#delete_bookmark(bookmark_id) ⇒ Object

Permanently deletes the specified bookmark. This is NOT the same as Archive. Please be clear to users if you're going to do this.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.


34
35
36
# File 'lib/instapaper/api/bookmarks.rb', line 34

def delete_bookmark(bookmark_id)
  perform_post_with_objects('/api/1.1/bookmarks/delete', {bookmark_id: bookmark_id}, Array)
end

#get_text(bookmark_id) ⇒ Object

Returns the specified bookmark's processed text-view HTML, which is always text/html encoded as UTF-8.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.


72
73
74
# File 'lib/instapaper/api/bookmarks.rb', line 72

def get_text(bookmark_id)
  perform_post_with_unparsed_response('/api/1.1/bookmarks/get_text', bookmark_id: bookmark_id)
end

#move_bookmark(bookmark_id, folder_id) ⇒ Object

Moves the specified bookmark to a user-created folder.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.

  • folder_id (String)

    The id of the folder to move the bookmark to.


65
66
67
# File 'lib/instapaper/api/bookmarks.rb', line 65

def move_bookmark(bookmark_id, folder_id)
  perform_post_with_object('/api/1.1/bookmarks/move', {bookmark_id: bookmark_id, folder_id: folder_id}, Instapaper::Bookmark)
end

#star_bookmark(bookmark_id) ⇒ Object

Stars the specified bookmark.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.


40
41
42
# File 'lib/instapaper/api/bookmarks.rb', line 40

def star_bookmark(bookmark_id)
  perform_post_with_object('/api/1.1/bookmarks/star', {bookmark_id: bookmark_id}, Instapaper::Bookmark)
end

#unarchive_bookmark(bookmark_id) ⇒ Object

Moves the specified bookmark to the top of the Unread folder.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.


58
59
60
# File 'lib/instapaper/api/bookmarks.rb', line 58

def unarchive_bookmark(bookmark_id)
  perform_post_with_object('/api/1.1/bookmarks/unarchive', {bookmark_id: bookmark_id}, Instapaper::Bookmark)
end

#unstar_bookmark(bookmark_id) ⇒ Object

Un-stars the specified bookmark.

Parameters:

  • bookmark_id (String)

    The id of the bookmark.


46
47
48
# File 'lib/instapaper/api/bookmarks.rb', line 46

def unstar_bookmark(bookmark_id)
  perform_post_with_object('/api/1.1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark)
end

#update_read_progress(bookmark_id, progress, progress_timestamp = Time.now) ⇒ Object

Updates the user's reading progress on a single article.

Parameters:

  • bookmark_id (String)

    The id of the bookmark to update.

  • 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.

  • progress_timestamp (Integer) (defaults to: Time.now)

    The Unix timestamp value of the time that the progress was recorded.


21
22
23
# File 'lib/instapaper/api/bookmarks.rb', line 21

def update_read_progress(bookmark_id, progress, progress_timestamp = Time.now)
  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