module CoinbasePro.Authenticated.Headers
    ( CBAccessKey(..)
    , CBAccessSign(..)
    , CBAccessTimeStamp(..)
    , CBAccessPassphrase(..)
    ) where

import           Data.Aeson         (ToJSON (..), Value (String))
import qualified Data.Aeson         as A
import           Data.ByteString    (ByteString)
import           Data.Text          (Text)
import           Data.Text.Encoding (decodeUtf8)
import           Web.HttpApiData    (ToHttpApiData (..))


newtype CBAccessKey = CBAccessKey Text
    deriving (CBAccessKey -> CBAccessKey -> Bool
(CBAccessKey -> CBAccessKey -> Bool)
-> (CBAccessKey -> CBAccessKey -> Bool) -> Eq CBAccessKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CBAccessKey -> CBAccessKey -> Bool
$c/= :: CBAccessKey -> CBAccessKey -> Bool
== :: CBAccessKey -> CBAccessKey -> Bool
$c== :: CBAccessKey -> CBAccessKey -> Bool
Eq, Int -> CBAccessKey -> ShowS
[CBAccessKey] -> ShowS
CBAccessKey -> String
(Int -> CBAccessKey -> ShowS)
-> (CBAccessKey -> String)
-> ([CBAccessKey] -> ShowS)
-> Show CBAccessKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CBAccessKey] -> ShowS
$cshowList :: [CBAccessKey] -> ShowS
show :: CBAccessKey -> String
$cshow :: CBAccessKey -> String
showsPrec :: Int -> CBAccessKey -> ShowS
$cshowsPrec :: Int -> CBAccessKey -> ShowS
Show)


instance ToHttpApiData CBAccessKey where
    toUrlPiece :: CBAccessKey -> Text
toUrlPiece (CBAccessKey Text
k)   = Text
k
    toQueryParam :: CBAccessKey -> Text
toQueryParam (CBAccessKey Text
k) = Text
k


instance ToJSON CBAccessKey where
    toJSON :: CBAccessKey -> Value
toJSON (CBAccessKey Text
k) = Text -> Value
A.String Text
k


newtype CBAccessSign = CBAccessSign ByteString
    deriving (CBAccessSign -> CBAccessSign -> Bool
(CBAccessSign -> CBAccessSign -> Bool)
-> (CBAccessSign -> CBAccessSign -> Bool) -> Eq CBAccessSign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CBAccessSign -> CBAccessSign -> Bool
$c/= :: CBAccessSign -> CBAccessSign -> Bool
== :: CBAccessSign -> CBAccessSign -> Bool
$c== :: CBAccessSign -> CBAccessSign -> Bool
Eq, Int -> CBAccessSign -> ShowS
[CBAccessSign] -> ShowS
CBAccessSign -> String
(Int -> CBAccessSign -> ShowS)
-> (CBAccessSign -> String)
-> ([CBAccessSign] -> ShowS)
-> Show CBAccessSign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CBAccessSign] -> ShowS
$cshowList :: [CBAccessSign] -> ShowS
show :: CBAccessSign -> String
$cshow :: CBAccessSign -> String
showsPrec :: Int -> CBAccessSign -> ShowS
$cshowsPrec :: Int -> CBAccessSign -> ShowS
Show)


instance ToHttpApiData CBAccessSign where
    toUrlPiece :: CBAccessSign -> Text
toUrlPiece (CBAccessSign ByteString
s)   = ByteString -> Text
decodeUtf8 ByteString
s
    toQueryParam :: CBAccessSign -> Text
toQueryParam (CBAccessSign ByteString
s) = ByteString -> Text
decodeUtf8 ByteString
s


instance ToJSON CBAccessSign where
    toJSON :: CBAccessSign -> Value
toJSON (CBAccessSign ByteString
s) = Text -> Value
A.String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ ByteString -> Text
decodeUtf8 ByteString
s


newtype CBAccessTimeStamp = CBAccessTimeStamp Text
    deriving (CBAccessTimeStamp -> CBAccessTimeStamp -> Bool
(CBAccessTimeStamp -> CBAccessTimeStamp -> Bool)
-> (CBAccessTimeStamp -> CBAccessTimeStamp -> Bool)
-> Eq CBAccessTimeStamp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CBAccessTimeStamp -> CBAccessTimeStamp -> Bool
$c/= :: CBAccessTimeStamp -> CBAccessTimeStamp -> Bool
== :: CBAccessTimeStamp -> CBAccessTimeStamp -> Bool
$c== :: CBAccessTimeStamp -> CBAccessTimeStamp -> Bool
Eq, Int -> CBAccessTimeStamp -> ShowS
[CBAccessTimeStamp] -> ShowS
CBAccessTimeStamp -> String
(Int -> CBAccessTimeStamp -> ShowS)
-> (CBAccessTimeStamp -> String)
-> ([CBAccessTimeStamp] -> ShowS)
-> Show CBAccessTimeStamp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CBAccessTimeStamp] -> ShowS
$cshowList :: [CBAccessTimeStamp] -> ShowS
show :: CBAccessTimeStamp -> String
$cshow :: CBAccessTimeStamp -> String
showsPrec :: Int -> CBAccessTimeStamp -> ShowS
$cshowsPrec :: Int -> CBAccessTimeStamp -> ShowS
Show)


instance ToHttpApiData CBAccessTimeStamp where
    toUrlPiece :: CBAccessTimeStamp -> Text
toUrlPiece (CBAccessTimeStamp Text
ts)   = Text
ts
    toQueryParam :: CBAccessTimeStamp -> Text
toQueryParam (CBAccessTimeStamp Text
ts) = Text
ts


instance ToJSON CBAccessTimeStamp where
    toJSON :: CBAccessTimeStamp -> Value
toJSON (CBAccessTimeStamp Text
ts) = Text -> Value
String Text
ts


newtype CBAccessPassphrase = CBAccessPassphrase Text
    deriving (CBAccessPassphrase -> CBAccessPassphrase -> Bool
(CBAccessPassphrase -> CBAccessPassphrase -> Bool)
-> (CBAccessPassphrase -> CBAccessPassphrase -> Bool)
-> Eq CBAccessPassphrase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CBAccessPassphrase -> CBAccessPassphrase -> Bool
$c/= :: CBAccessPassphrase -> CBAccessPassphrase -> Bool
== :: CBAccessPassphrase -> CBAccessPassphrase -> Bool
$c== :: CBAccessPassphrase -> CBAccessPassphrase -> Bool
Eq, Int -> CBAccessPassphrase -> ShowS
[CBAccessPassphrase] -> ShowS
CBAccessPassphrase -> String
(Int -> CBAccessPassphrase -> ShowS)
-> (CBAccessPassphrase -> String)
-> ([CBAccessPassphrase] -> ShowS)
-> Show CBAccessPassphrase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CBAccessPassphrase] -> ShowS
$cshowList :: [CBAccessPassphrase] -> ShowS
show :: CBAccessPassphrase -> String
$cshow :: CBAccessPassphrase -> String
showsPrec :: Int -> CBAccessPassphrase -> ShowS
$cshowsPrec :: Int -> CBAccessPassphrase -> ShowS
Show)


instance ToJSON CBAccessPassphrase where
    toJSON :: CBAccessPassphrase -> Value
toJSON (CBAccessPassphrase Text
p) = Text -> Value
A.String Text
p


instance ToHttpApiData CBAccessPassphrase where
    toUrlPiece :: CBAccessPassphrase -> Text
toUrlPiece (CBAccessPassphrase Text
p)   = Text
p
    toQueryParam :: CBAccessPassphrase -> Text
toQueryParam (CBAccessPassphrase Text
p) = Text
p