module Diffbot.FrontPage where
import Data.Maybe
import Diffbot.Types
data FrontPage = FrontPage
{ frontPageAll :: Bool
, frontPageContent :: Maybe Content
, frontPageTimeout :: Maybe Int
}
instance Post FrontPage where
content = frontPageContent
setContent c f = f { frontPageContent = c }
instance Timeout FrontPage where
timeout = frontPageTimeout
setTimeout t f = f { frontPageTimeout = t }
instance Request FrontPage where
toReq r = Req { reqApi = "http://www.diffbot.com/api/frontpage"
, reqContent = content r
, reqQuery = mkFrontPageQuery r
}
mkFrontPageQuery :: FrontPage -> [(String, Maybe String)]
mkFrontPageQuery f = catMaybes [ mkQueryBool "all" (frontPageAll f)
, mkQuery "format" (Just "json")
, timeoutQuery f
]
defFrontPage :: FrontPage
defFrontPage = FrontPage { frontPageAll = False
, frontPageContent = Nothing
, frontPageTimeout = Nothing
}