Copyright | (c) Yiğit Özkavcı 2017 |
---|---|
License | WTFPL |
Maintainer | yigitozkavci8@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
This module controls all the data flow and client interface required to interact with the library.
- type Id = String
- type ApiKey = String
- newtype Client = Client {}
- getClient :: String -> Client
- data Resource
- data Operation
- baseUrl :: String
- getUrl :: Operation -> String
- fetchResource :: Client -> Operation -> IO ByteString
- type ServiceResponse a = Reader Client (IO (Either String a))
- getPage :: Id -> ServiceResponse Page
- getPages :: ServiceResponse [Page]
- getNewsPhotoGallery :: Id -> ServiceResponse NewsPhotoGallery
- getNewsPhotoGalleries :: ServiceResponse [NewsPhotoGallery]
- getColumn :: Id -> ServiceResponse Column
- getColumns :: ServiceResponse [Column]
- getPath :: Id -> ServiceResponse Path
- getPaths :: ServiceResponse [Path]
- getWriter :: Id -> ServiceResponse Writer
- getWriters :: ServiceResponse [Writer]
- getArticle :: Id -> ServiceResponse Article
- getArticles :: ServiceResponse [Article]
- withClient :: Client -> Reader Client a -> a
Documentation
getClient :: String -> Client Source #
This is how you construct the client. Takes apiKey as an argument
Each of these resources represent services. These are used for passing service-spesific data such as endpoint string
For now, Hurriyet API only consists of 2 operations. As we have more, new operations will be added into here
getUrl :: Operation -> String Source #
This method constructs url given the operation. Operation already contains enough data to construct the url
fetchResource :: Client -> Operation -> IO ByteString Source #
Given a client and a operation, this method can conquer the world. But prefers not to and returns a bytestring representing json string of the response body
getPages :: ServiceResponse [Page] Source #
Get all pages
getNewsPhotoGallery :: Id -> ServiceResponse NewsPhotoGallery Source #
Get a single news photo gallery
getNewsPhotoGalleries :: ServiceResponse [NewsPhotoGallery] Source #
Get all news photo galleries
getColumns :: ServiceResponse [Column] Source #
Get all columns
getPaths :: ServiceResponse [Path] Source #
Get all paths
getWriters :: ServiceResponse [Writer] Source #
Get all writers
getArticle :: Id -> ServiceResponse Article Source #
Get single article
getArticles :: ServiceResponse [Article] Source #
Get all articles