module Dormouse.Client.Class
  ( MonadDormouseClient(..)
  , HasDormouseClientConfig(..)
  , DormouseClientConfig(..)
  ) where

import Data.Word ( Word8 )
import Dormouse.Client.Payload ( RawRequestPayload(..) )
import Dormouse.Client.Types ( HttpRequest(..), HttpResponse(..) )
import Dormouse.Url ( IsUrl )
import Network.HTTP.Client ( Manager )
import Streamly ( SerialT )

  | The configuration options required to run Dormouse
newtype DormouseClientConfig = DormouseClientConfig { clientManager :: Manager }

-- | Describes the capability to retrieve a Dormouse Config
class HasDormouseClientConfig a where
  getDormouseClientConfig :: a -> DormouseClientConfig

instance HasDormouseClientConfig DormouseClientConfig where
  getDormouseClientConfig = id

    describes the capability to send HTTP requests and receive an HTTP response
class Monad m => MonadDormouseClient m where
  -- | Sends a supplied HTTP request and retrieves a response within the supplied monad @m@
  send :: IsUrl url => HttpRequest url method RawRequestPayload contentTag acceptTag -> (HttpResponse (SerialT IO Word8) -> IO (HttpResponse b)) -> m (HttpResponse b)

 | Describes the capability to retrieve a Dormouse Config
 | Sends a supplied HTTP request and retrieves a response within the supplied monad @m@
module Dormouse.Client.Class
  ( MonadDormouseClient(..)
  , HasDormouseClientConfig(..)
  , DormouseClientConfig(..)
  ) where

import Data.Word ( Word8 )
import Dormouse.Client.Payload ( RawRequestPayload(..) )
import Dormouse.Client.Types ( HttpRequest(..), HttpResponse(..) )
import Dormouse.Url ( IsUrl )
import Network.HTTP.Client ( Manager )
import Streamly ( SerialT )

  | The configuration options required to run Dormouse
newtype DormouseClientConfig = DormouseClientConfig { clientManager :: Manager }

class HasDormouseClientConfig a where
  getDormouseClientConfig :: a -> DormouseClientConfig

instance HasDormouseClientConfig DormouseClientConfig where
  getDormouseClientConfig = id

    describes the capability to send HTTP requests and receive an HTTP response
class Monad m => MonadDormouseClient m where
  send :: IsUrl url => HttpRequest url method RawRequestPayload contentTag acceptTag -> (HttpResponse (SerialT IO Word8) -> IO (HttpResponse b)) -> m (HttpResponse b)
