-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Package to make APIs
--
-- Please see the README on GitHub at
-- https://github.com/schnecki/api-maker#readme
@package api-maker
@version 0.1.0.0
module Network.HTTP.ApiMaker.HeaderContent
-- | Option for specifying `application/json`.
headerContentTypeJson :: Option scheme
-- | Option for specifying `multipart/form-data`.
headerContentTypeMultipart :: Option scheme
-- | Option for specifying a file.
headerContentDispositionFile :: Text -> Option scheme
module Network.HTTP.ApiMaker.SessionState
-- | Session state contract.
class SessionState st
csrfToken :: SessionState st => Lens' st (Maybe ByteString)
sessionData :: SessionState st => Lens' st (Maybe ByteString)
cookieJarData :: SessionState st => Lens' st (Maybe CookieJar)
-- | Simple session state. This probably is sufficient for the day-to-day
-- use.
data Session
Session :: Maybe ByteString -> Maybe ByteString -> Maybe CookieJar -> Session
[sessCsrfToken] :: Session -> Maybe ByteString
[sessSessionData] :: Session -> Maybe ByteString
[sessCookieJarData] :: Session -> Maybe CookieJar
-- | Empty session state.
emptySession :: Session
instance GHC.Show.Show Network.HTTP.ApiMaker.SessionState.Session
instance Network.HTTP.ApiMaker.SessionState.SessionState Network.HTTP.ApiMaker.SessionState.Session
module Network.HTTP.ApiMaker.Class
-- | Class definition for a Request. Every request should implement
-- this, the rest is then handled by the library. See mkReq to
-- create a request, the functions mkReqM and runRequests
-- to build a SafeReqM monad that shares the same state, session
-- and configuration, and finally runReqM, runSessReqM,
-- runReqWithParamsM and runSessReqWithParamsM to run the
-- monad.
class (HttpMethod (Method r), HttpBody (Body r), HttpResponse (Response r), HttpBodyAllowed (AllowsBody (Method r)) (ProvidesBody (Body r))) => Request cfg r where {
type family Method r :: Type;
type family Body r :: Type;
type family Response r :: Type;
type family Output r :: Type;
}
method :: Request cfg r => cfg -> r -> Method r
url :: Request cfg r => cfg -> r -> Url 'Https
body :: Request cfg r => cfg -> r -> Body r
response :: Request cfg r => cfg -> r -> Proxy (Response r)
option :: Request cfg r => cfg -> r -> Option 'Https
process :: (Request cfg r, MonadHttp m, SessionState st) => cfg -> r -> Response r -> StateT st m (Output r)
-- | Configuration that is passed from request to request to hold the
-- session and default https header options. It also holds a user defined
-- configuration.
data Config cfg
Config :: HttpConfig -> [Option 'Https] -> cfg -> Config cfg
[httpConfig] :: Config cfg -> HttpConfig
[apiDefaultParameters] :: Config cfg -> [Option 'Https]
[apiConfig] :: Config cfg -> cfg
-- | Session state contract.
class SessionState st
csrfToken :: SessionState st => Lens' st (Maybe ByteString)
sessionData :: SessionState st => Lens' st (Maybe ByteString)
cookieJarData :: SessionState st => Lens' st (Maybe CookieJar)
-- | Simple session state. This probably is sufficient for the day-to-day
-- use.
data Session
Session :: Maybe ByteString -> Maybe ByteString -> Maybe CookieJar -> Session
[sessCsrfToken] :: Session -> Maybe ByteString
[sessSessionData] :: Session -> Maybe ByteString
[sessCookieJarData] :: Session -> Maybe CookieJar
-- | Empty session state.
emptySession :: Session
-- | Safely run the request monad.
runSafeReqM :: MonadIO m => Config cfg -> SafeReqM cfg a -> m (Either HttpException a)
askConfig :: SafeReqM cfg (Config cfg)
askApiConfig :: SafeReqM cfg cfg
type SafeReqSt sessionState cfg a = StateT sessionState (SafeReqM cfg) a
type SafeReq cfg a = SafeReqSt Session cfg a
-- | Safe request, e.g. all errors are caught and tured into exceptions.
newtype SafeReqM cfg a
SafeReqM :: ExceptT HttpException (ReaderT (Config cfg) IO) a -> SafeReqM cfg a
instance Control.Monad.IO.Class.MonadIO (Network.HTTP.ApiMaker.Class.SafeReqM cfg)
instance GHC.Base.Monad (Network.HTTP.ApiMaker.Class.SafeReqM cfg)
instance GHC.Base.Applicative (Network.HTTP.ApiMaker.Class.SafeReqM cfg)
instance GHC.Base.Functor (Network.HTTP.ApiMaker.Class.SafeReqM cfg)
instance Control.Monad.Base.MonadBase GHC.Types.IO (Network.HTTP.ApiMaker.Class.SafeReqM cfg)
instance Network.HTTP.Req.MonadHttp (Network.HTTP.ApiMaker.Class.SafeReqM cfg)
module Network.HTTP.ApiMaker.Ops
-- | Call a single request. See runRequest and
-- runStRequests to build and execute a set of requests that share
-- the same state, session and configuration.
mkReq :: (Request cfg request, SessionState st) => request -> SafeReqSt st cfg (Output request)
-- | Run a normal session based request state monad.
runRequests :: StateT Session (SafeReqM cfg) a -> SafeReqM cfg a
-- | Run a user defined session request state monad.
runStRequests :: st -> StateT st (SafeReqM cfg) a -> SafeReqM cfg a
-- | Prepare to run requests.
runReqM :: MonadIO m => SafeReqM () a -> m (Either HttpException a)
-- | Prepare to run requests with addional header options.
runReqWithParamsM :: MonadIO m => [Option 'Https] -> SafeReqM () a -> m (Either HttpException a)
-- | Prepare to run request with config.
runSessReqM :: MonadIO m => cfg -> SafeReqM cfg a -> m (Either HttpException a)
-- | Prepare to run request with config and additional header options.
runSessReqWithParamsM :: MonadIO m => [Option 'Https] -> cfg -> SafeReqM cfg a -> m (Either HttpException a)
module ApiMaker