{-# LANGUAGE OverloadedStrings #-}
module Network.Ipfs.Api.Block where
import Control.Monad.IO.Class (MonadIO)
import Data.Aeson (decode)
import Data.Text (Text)
import Network.HTTP.Client (responseBody)
import Network.Ipfs.Api.Internal (_blockGet, _blockStat)
import Network.Ipfs.Api.Internal.Call (call, multipartCall)
import Network.Ipfs.Api.Types (BlockObj, BlockReturnType)
import Network.Ipfs.Client (IpfsT)
get :: MonadIO m => Text -> IpfsT m BlockReturnType
get = call . _blockGet
put :: MonadIO m => Text -> IpfsT m (Maybe BlockObj)
put = fmap decodeResponse . multipartCall "block/put"
where
decodeResponse = decode . responseBody
stat :: MonadIO m => Text -> IpfsT m BlockObj
stat = call . _blockStat