module Network.Hawk.Internal.Client.Types where
import Data.Text (Text)
import Data.ByteString (ByteString)
import Data.Time.Clock.POSIX (POSIXTime)
import GHC.Generics
import Network.HTTP.Types.Method (Method)
import Network.Hawk.Internal (Authorization)
import Network.Hawk.Types
data Credentials = Credentials
{ ccId :: ClientId
, ccKey :: Key
, ccAlgorithm :: HawkAlgo
} deriving (Show, Generic)
data Header = Header
{ hdrField :: Authorization
, hdrArtifacts :: HeaderArtifacts
} deriving (Show, Generic)
data Scheme = HTTP | HTTPS deriving (Show, Eq)
data SplitURL = SplitURL
{ urlScheme :: Scheme
, urlHost :: ByteString
, urlPort :: Maybe Int
, urlPath :: ByteString
} deriving (Show, Generic)
defaultPort :: Scheme -> Int
defaultPort HTTP = 80
defaultPort HTTPS = 443
urlPort' :: SplitURL -> Int
urlPort' (SplitURL s _ Nothing _) = defaultPort s
urlPort' (SplitURL _ _ (Just p) _) = p