--------------------------------------------------------------------------------
-- |
-- Module    :  Database.EventStore.Internal.Operation.Authenticate
-- Copyright :  (C) 2018 Yorick Laupa
-- License   :  (see the file LICENSE)
-- Maintainer:  Yorick Laupa <yo.eight@gmail.com>
-- Stability :  experimental
-- Portability: non-portable
--
--------------------------------------------------------------------------------
module Database.EventStore.Internal.Operation.Authenticate
  ( newAuthenticatePkg ) where

--------------------------------------------------------------------------------
import Database.EventStore.Internal.Command
import Database.EventStore.Internal.Prelude
import Database.EventStore.Internal.Settings
import Database.EventStore.Internal.Types

--------------------------------------------------------------------------------
newAuthenticatePkg :: MonadBase IO m => Credentials -> m Package
newAuthenticatePkg :: forall (m :: * -> *). MonadBase IO m => Credentials -> m Package
newAuthenticatePkg Credentials
cred = do
  UUID
uuid <- forall (m :: * -> *). MonadBase IO m => m UUID
newUUID
  let pkg :: Package
pkg = Package { packageCmd :: Command
packageCmd         = Command
authenticateCmd
                    , packageCorrelation :: UUID
packageCorrelation = UUID
uuid
                    , packageData :: ByteString
packageData        = ByteString
""
                    , packageCred :: Maybe Credentials
packageCred        = forall a. a -> Maybe a
Just Credentials
cred
                    }
  forall (f :: * -> *) a. Applicative f => a -> f a
pure Package
pkg