Copyright | (c) Jon Schoning 2015 |
---|---|
Maintainer | jonschoning@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- fromApiToken :: String -> PinboardConfig
- defaultPinboardConfig :: PinboardConfig
- data PinboardConfig = PinboardConfig {
- apiToken :: !ByteString
- maxRequestRateMills :: !Int
- lastRequestTime :: IORef UTCTime
- doThreadDelay :: PinboardConfig -> IO ()
- execLoggingT :: ExecLoggingT
- filterLoggingT :: LogSource -> LogLevel -> Bool
- runPinboard :: (MonadIO m, MonadCatch m, MonadErrorPinboard e) => PinboardConfig -> PinboardT m a -> m (e a)
- runPinboardE :: (MonadIO m, MonadCatch m, MonadErrorPinboard e) => PinboardEnv -> PinboardT m a -> m (e a)
- pinboardJson :: (MonadPinboard m, FromJSON a) => PinboardRequest -> m a
- runPinboardSingleRaw :: PinboardConfig -> PinboardRequest -> IO (Response ByteString)
- runPinboardSingleRawBS :: MonadErrorPinboard e => PinboardConfig -> PinboardRequest -> IO (e ByteString)
- runPinboardSingleJson :: (MonadErrorPinboard e, FromJSON a) => PinboardConfig -> PinboardRequest -> IO (e a)
- sendPinboardRequest :: PinboardEnv -> PinboardRequest -> IO (Response ByteString)
- requestThreadDelay :: PinboardConfig -> IO ()
- newMgr :: IO Manager
- mgrFail :: (Monad m, MonadErrorPinboard e) => PinboardErrorType -> SomeException -> m (e b)
- parseJSONResponse :: (MonadErrorPinboard e, FromJSON a) => Response ByteString -> e a
- decodeJSONResponse :: (MonadErrorPinboard e, FromJSON a) => ByteString -> e a
- checkStatusCodeResponse :: MonadErrorPinboard e => Response a -> e ()
- checkStatusCode :: MonadErrorPinboard e => Int -> e ()
- addErrMsg :: Text -> PinboardError -> PinboardError
- createParserErr :: Text -> PinboardError
- httpStatusPinboardError :: MonadErrorPinboard e => PinboardErrorHTTPCode -> e a
Config
fromApiToken :: String -> PinboardConfig Source #
Create a default PinboardConfig using the supplied apiToken (ex: "use:ABCDEF0123456789ABCD")
The PinboardConfig provides authentication via apiToken
data PinboardConfig Source #
PinboardConfig | |
|
Monadic
runPinboard :: (MonadIO m, MonadCatch m, MonadErrorPinboard e) => PinboardConfig -> PinboardT m a -> m (e a) Source #
Execute computations in the Pinboard monad
runPinboardE :: (MonadIO m, MonadCatch m, MonadErrorPinboard e) => PinboardEnv -> PinboardT m a -> m (e a) Source #
Execute computations in the Pinboard monad (with specified http Manager)
pinboardJson :: (MonadPinboard m, FromJSON a) => PinboardRequest -> m a Source #
Create a Pinboard value from a PinboardRequest w/ json deserialization
Single
runPinboardSingleRawBS :: MonadErrorPinboard e => PinboardConfig -> PinboardRequest -> IO (e ByteString) Source #
runPinboardSingleJson :: (MonadErrorPinboard e, FromJSON a) => PinboardConfig -> PinboardRequest -> IO (e a) Source #
Sending
sendPinboardRequest :: PinboardEnv -> PinboardRequest -> IO (Response ByteString) Source #
Delaying
requestThreadDelay :: PinboardConfig -> IO () Source #
delays the thread, if the time since the previous request is less than the configured maxRequestRateMills
Manager (http-client)
mgrFail :: (Monad m, MonadErrorPinboard e) => PinboardErrorType -> SomeException -> m (e b) Source #
JSON Handling
parseJSONResponse :: (MonadErrorPinboard e, FromJSON a) => Response ByteString -> e a Source #
decodeJSONResponse :: (MonadErrorPinboard e, FromJSON a) => ByteString -> e a Source #
Status Codes
checkStatusCodeResponse :: MonadErrorPinboard e => Response a -> e () Source #
checkStatusCode :: MonadErrorPinboard e => Int -> e () Source #
Error Helpers
addErrMsg :: Text -> PinboardError -> PinboardError Source #
createParserErr :: Text -> PinboardError Source #
httpStatusPinboardError :: MonadErrorPinboard e => PinboardErrorHTTPCode -> e a Source #