Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module is an interface to the Readability's Reader API.
To get more info, visit https://www.readability.com/developers/api/reader.
Before performing any request, you should receive OAuth credentials. To do that,
this module provides newOAuth
as well as xauth
for XAuth authorizations.
The full XAuth authorization process will be like:
let auth = newAuth { oauthConsumerKey = "consumer key" -- usually, your username , oauthConsumerSecret = "consumer token" } credential <- xauth auth "username" "password"
Then you should pass auth and credential to any function in this module.
It's preferable not doing authentication every single time. The best way is to store received credential, so you can use it later.
If you don't have Reader Keys, visit https://www.readability.com/settings/account.
- data OAuth :: *
- newOAuth :: OAuth
- oauthConsumerKey :: OAuth -> ByteString
- oauthConsumerSecret :: OAuth -> ByteString
- xauth :: OAuth -> ByteString -> ByteString -> IO (Maybe Credential)
- oauthAuthorizeEndpoint :: String
- oauthRequestTokenEndpoint :: String
- oauthAccessTokenEndpoint :: String
- data Article = Article {
- content :: Maybe Text
- domain :: Maybe Text
- author :: Maybe Text
- url :: Text
- short_url :: Maybe Text
- title :: Maybe Text
- excerpt :: Maybe Text
- direction :: Maybe Text
- word_count :: Integer
- total_pages :: Maybe Integer
- date_published :: Maybe Text
- dek :: Maybe Text
- lead_image_url :: Maybe Text
- next_page_id :: Maybe Text
- rendered_pages :: Maybe Int
- getArticle :: OAuth -> Credential -> ByteString -> IO (Either String Article)
- data BookmarksFilters = BookmarksFilters {
- bfArchive :: Maybe Bool
- bfFavorite :: Maybe Bool
- bfDomain :: Maybe String
- bfAddedSince :: Maybe DateTime
- bfAddedUntil :: Maybe DateTime
- bfOpenedSince :: Maybe DateTime
- bfOpenedUntil :: Maybe DateTime
- bfArchivedSince :: Maybe DateTime
- bfArchivedUntil :: Maybe DateTime
- bfFavoritedSince :: Maybe DateTime
- bfFavoritedUntil :: Maybe DateTime
- bfUpdatedSince :: Maybe DateTime
- bfUpdatedUntil :: Maybe DateTime
- defaultBookmarksFilters :: BookmarksFilters
- data BookmarksResponse = BookmarksResponse {}
- data BookmarksConditions = BookmarksConditions {
- bc_archive :: Maybe Int
- bc_favorite :: Maybe Int
- bc_domain :: Maybe Text
- bc_added_since :: Maybe Text
- bc_added_until :: Maybe Text
- bc_opened_since :: Maybe Text
- bc_opened_until :: Maybe Text
- bc_archived_since :: Maybe Text
- bc_archived_until :: Maybe Text
- bc_favorited_since :: Maybe Text
- bc_favorited_until :: Maybe Text
- bc_updated_since :: Maybe Text
- bc_updated_until :: Maybe Text
- bc_order :: Maybe Order
- bc_user :: Maybe Text
- bc_page :: Maybe Integer
- bc_per_page :: Maybe Integer
- bc_exclude_accessibility :: Maybe Text
- data BookmarksMeta = BookmarksMeta {}
- data Bookmark = Bookmark {
- b_user_id :: Integer
- b_read_percent :: Text
- b_date_updated :: Text
- b_favorite :: Bool
- b_archive :: Bool
- b_article :: Article
- b_id :: Integer
- b_date_archived :: Maybe Text
- b_date_opened :: Maybe Text
- b_date_added :: Maybe Text
- b_date_favorited :: Maybe Text
- b_article_href :: Text
- b_tags :: [Tag]
- data BookmarkLocation = BookmarkLocation {}
- data Order
- getBookmarks :: OAuth -> Credential -> BookmarksFilters -> Maybe Order -> Maybe Integer -> Maybe Integer -> Maybe Bool -> [String] -> IO (Either String BookmarksResponse)
- addBookmark :: OAuth -> Credential -> ByteString -> Maybe Bool -> Maybe Bool -> Maybe Bool -> IO BookmarkLocation
- getBookmark :: OAuth -> Credential -> Integer -> IO (Either String Bookmark)
- updateBookmark :: OAuth -> Credential -> Integer -> Maybe Bool -> Maybe Bool -> Maybe Double -> IO (Either String Bookmark)
- deleteBookmark :: OAuth -> Credential -> Integer -> IO (Response ByteString)
- getBookmarkTags :: OAuth -> Credential -> Integer -> IO (Either String TagsResponse)
- addBookmarkTags :: OAuth -> Credential -> Integer -> [Text] -> IO (Either String TagsResponse)
- deleteBookmarkTag :: OAuth -> Credential -> Integer -> Integer -> IO (Response ByteString)
- data TagsResponse = TagsResponse {}
- data Tag = Tag {
- t_text :: Text
- t_id :: Integer
- t_applied_count :: Maybe Integer
- t_bookmark_ids :: Maybe [Integer]
- getTags :: OAuth -> Credential -> IO (Either String TagsResponse)
- getTag :: OAuth -> Credential -> Integer -> IO (Either String Tag)
- deleteTag :: OAuth -> Credential -> Integer -> IO (Response ByteString)
- data User = User {}
- getUser :: OAuth -> Credential -> IO (Either String User)
Authentication
OAuth
data OAuth :: *
Data type for OAuth client (consumer).
The constructor for this data type is not exposed.
Instead, you should use the def
method or newOAuth
function to retrieve a default instance,
and then use the records below to make modifications.
This approach allows us to add configuration options without breaking backwards compatibility.
Default value for OAuth datatype. You must specify at least consumer key and secret.
Example usage:
myAuth = newOAuth { oauthConsumerKey = "consumer key" , oauthConsumerSecret = "consumer secret" }
oauthConsumerKey :: OAuth -> ByteString
Consumer key (You MUST specify)
oauthConsumerSecret :: OAuth -> ByteString
Consumer Secret (You MUST specify)
:: OAuth | OAuth client |
-> ByteString | Owner username |
-> ByteString | Owner password |
-> IO (Maybe Credential) | Token and secret |
XAuth is used to receive OAuth token using owner's username and password directly.
In most cases, you should do your best to support OAuth proper.
OAuth Endoints
oauthAuthorizeEndpoint :: String Source
OAuth endpoint
oauthRequestTokenEndpoint :: String Source
OAuth endpoint
oauthAccessTokenEndpoint :: String Source
OAuth endpoint
Article
Types
Article | |
|
Requests
:: OAuth | Client OAuth |
-> Credential | Access token and secret |
-> ByteString | Article id |
-> IO (Either String Article) |
Gets article by id.
This is a GET
request to /articles/{articleId}
endpoint.
Bookmarks
Types
data BookmarksFilters Source
BookmarksFilters | |
|
defaultBookmarksFilters :: BookmarksFilters Source
This is a default value for BookmarksFilters
. All fields are set to Nothing
.
data BookmarksConditions Source
Bookmark | |
|
data BookmarkLocation Source
DateAddedAsc | Sort by date added, asceding |
DateAddedDesc | Sort by date added, desceding (this is default) |
DateUpdatedAsc | Sort by date updated, asceding |
DateUpdatedDesc | Sort by date updated, desceding |
Requests
:: OAuth | |
-> Credential | |
-> BookmarksFilters | |
-> Maybe Order | |
-> Maybe Integer | Page |
-> Maybe Integer | Per page |
-> Maybe Bool | Only deleted |
-> [String] | Tags |
-> IO (Either String BookmarksResponse) |
Get all user bookmarks.
This is a GET
request to /bookmarks
.
:: OAuth | |
-> Credential | |
-> ByteString | Article URL |
-> Maybe Bool | Favorite |
-> Maybe Bool | Archive |
-> Maybe Bool | Allow duplicates |
-> IO BookmarkLocation |
Add bookmark.
This is a POST
request to /bookmarks
.
Get bookmark by id.
This is a GET
request to /bookmarks/{bookmarkId}
.
:: OAuth | |
-> Credential | |
-> Integer | Bookmark id |
-> Maybe Bool | Favorite |
-> Maybe Bool | Archive |
-> Maybe Double | Read percent |
-> IO (Either String Bookmark) |
Update bookmark.
This a POST
request to /bookmarks/{bookmarkId}
.
:: OAuth | |
-> Credential | |
-> Integer | Bookmark id |
-> IO (Response ByteString) |
Delete bookmark by id.
This is a DELETE
request to /bookmarks/{bookmarkId}
.
:: OAuth | |
-> Credential | |
-> Integer | Bookmark id |
-> IO (Either String TagsResponse) |
Get bookmark tags
This is a GET
request to /bookmarks/{bookmarkId}/tags
.
:: OAuth | |
-> Credential | |
-> Integer | Bookmark id |
-> [Text] | Tags |
-> IO (Either String TagsResponse) |
Add tags to bookmark.
This is a POST
request to /bookmarks/{bookmarkId}/tags
.
:: OAuth | |
-> Credential | |
-> Integer | Bookmark id |
-> Integer | Tag id |
-> IO (Response ByteString) |
Delete given tag from bookmark.
This is a DELETE
request to /bookmark/{bookmarkId}/tags/{tagId}
.
Tags
Types
Requests
getTags :: OAuth -> Credential -> IO (Either String TagsResponse) Source
Retrieve all user tags.
This is a GET
request to /tags
.
getTag :: OAuth -> Credential -> Integer -> IO (Either String Tag) Source
Retrieve tag by id.
This is a GET
request to /tags/{tagId}
.
deleteTag :: OAuth -> Credential -> Integer -> IO (Response ByteString) Source
Delete tag by id.
This is a DELETE
request to /tags/{tagId}
.
User
Types
User | |
|