makeRequest
    :: ( FromJSON a
       , MonadWU m)
    => Method
    -> ByteString
    -> m a
makeRequest meth p = do
    cfg <- getWUConfig
    --TODO: consolidate?
    let k = cfg ^. wuAPIKey . apiKeyText . re utf8
    let pathAppend = k <> p
    let bu = cfg ^. wuBaseURI
    let finalURI = bu & uriPathL <>~ ("/" <> pathAppend)
    req <- setURI meth def finalURI
    httpRequest <- _wuHttpRequest <$> getWUConfig
    res <- liftIO $ E.try $ httpRequest req (cfg ^. wuManager)
    body <- either handleHttpException return res
    let parsed = eitherDecode body
    either (throwM . WUParseError . view packed) return parsed
  where
    handleHttpException = throwM . WUHttpException


-------------------------------------------------------------------------------
makeRequest
    :: ( FromJSON a
       , MonadWU m)
    => Method
    -> ByteString
    -> m a
makeRequest meth p = do
    cfg <- getWUConfig
    --TODO: consolidate?
    let k = cfg ^. wuAPIKey . apiKeyText . re utf8
    let pathAppend = k <> p
    let bu = cfg ^. wuBaseURI
    let finalURI = bu & uriPathL <>~ ("/" <> pathAppend)
    req <- setURI meth def finalURI
    httpRequest <- _wuHttpRequest <$> getWUConfig
    res <- liftIO $ E.try $ httpRequest req (cfg ^. wuManager)
    body <- either handleHttpException return res
    let parsed = eitherDecode body
    either (throwM . WUParseError . view packed) return parsed
  where
    handleHttpException = throwM . WUHttpException


-------------------------------------------------------------------------------
makeRequest meth p = do
    cfg <- getWUConfig
    --TODO: consolidate?
    let k = cfg ^. wuAPIKey . apiKeyText . re utf8
    let pathAppend = k <> p
    let bu = cfg ^. wuBaseURI
    let finalURI = bu & uriPathL <>~ ("/" <> pathAppend)
    req <- setURI meth def finalURI
    httpRequest <- _wuHttpRequest <$> getWUConfig
    res <- liftIO $ E.try $ httpRequest req (cfg ^. wuManager)
    body <- either handleHttpException return res
    let parsed = eitherDecode body
    either (throwM . WUParseError . view packed) return parsed
  where
    handleHttpException = throwM . WUHttpException


-------------------------------------------------------------------------------