{-# LANGUAGE OverloadedStrings #-}
module Network.Ipfs.Api.Dag 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 (_dagGet, _dagResolve)
import Network.Ipfs.Api.Internal.Call (call, multipartCall)
import Network.Ipfs.Api.Types (DagPutObj, DagResolveObj,
DagReturnType)
import Network.Ipfs.Client (IpfsT)
get :: MonadIO m => Text -> IpfsT m DagReturnType
get = call . _dagGet
resolve :: MonadIO m => Text -> IpfsT m DagResolveObj
resolve = call . _dagResolve
put :: MonadIO m => Text -> IpfsT m (Maybe DagPutObj)
put = fmap decodeResponse . multipartCall "dag/put"
where
decodeResponse = decode . responseBody