module Blockfrost.Types.Shared.PolicyId
where
import Data.Aeson (FromJSON, ToJSON)
import Data.String (IsString (..))
import Data.Text (Text)
import qualified Data.Text
import GHC.Generics
import Servant.API (Capture, FromHttpApiData (..), ToHttpApiData (..))
import Servant.Docs (DocCapture (..), ToCapture (..), ToSample (..), samples)
newtype PolicyId = PolicyId Text
deriving stock (PolicyId -> PolicyId -> Bool
(PolicyId -> PolicyId -> Bool)
-> (PolicyId -> PolicyId -> Bool) -> Eq PolicyId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyId -> PolicyId -> Bool
$c/= :: PolicyId -> PolicyId -> Bool
== :: PolicyId -> PolicyId -> Bool
$c== :: PolicyId -> PolicyId -> Bool
Eq, Int -> PolicyId -> ShowS
[PolicyId] -> ShowS
PolicyId -> String
(Int -> PolicyId -> ShowS)
-> (PolicyId -> String) -> ([PolicyId] -> ShowS) -> Show PolicyId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyId] -> ShowS
$cshowList :: [PolicyId] -> ShowS
show :: PolicyId -> String
$cshow :: PolicyId -> String
showsPrec :: Int -> PolicyId -> ShowS
$cshowsPrec :: Int -> PolicyId -> ShowS
Show, (forall x. PolicyId -> Rep PolicyId x)
-> (forall x. Rep PolicyId x -> PolicyId) -> Generic PolicyId
forall x. Rep PolicyId x -> PolicyId
forall x. PolicyId -> Rep PolicyId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyId x -> PolicyId
$cfrom :: forall x. PolicyId -> Rep PolicyId x
Generic)
deriving newtype (ByteString -> Either Text PolicyId
Text -> Either Text PolicyId
(Text -> Either Text PolicyId)
-> (ByteString -> Either Text PolicyId)
-> (Text -> Either Text PolicyId)
-> FromHttpApiData PolicyId
forall a.
(Text -> Either Text a)
-> (ByteString -> Either Text a)
-> (Text -> Either Text a)
-> FromHttpApiData a
parseQueryParam :: Text -> Either Text PolicyId
$cparseQueryParam :: Text -> Either Text PolicyId
parseHeader :: ByteString -> Either Text PolicyId
$cparseHeader :: ByteString -> Either Text PolicyId
parseUrlPiece :: Text -> Either Text PolicyId
$cparseUrlPiece :: Text -> Either Text PolicyId
FromHttpApiData, PolicyId -> ByteString
PolicyId -> Builder
PolicyId -> Text
(PolicyId -> Text)
-> (PolicyId -> Builder)
-> (PolicyId -> ByteString)
-> (PolicyId -> Text)
-> ToHttpApiData PolicyId
forall a.
(a -> Text)
-> (a -> Builder)
-> (a -> ByteString)
-> (a -> Text)
-> ToHttpApiData a
toQueryParam :: PolicyId -> Text
$ctoQueryParam :: PolicyId -> Text
toHeader :: PolicyId -> ByteString
$ctoHeader :: PolicyId -> ByteString
toEncodedUrlPiece :: PolicyId -> Builder
$ctoEncodedUrlPiece :: PolicyId -> Builder
toUrlPiece :: PolicyId -> Text
$ctoUrlPiece :: PolicyId -> Text
ToHttpApiData, Value -> Parser [PolicyId]
Value -> Parser PolicyId
(Value -> Parser PolicyId)
-> (Value -> Parser [PolicyId]) -> FromJSON PolicyId
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [PolicyId]
$cparseJSONList :: Value -> Parser [PolicyId]
parseJSON :: Value -> Parser PolicyId
$cparseJSON :: Value -> Parser PolicyId
FromJSON, [PolicyId] -> Encoding
[PolicyId] -> Value
PolicyId -> Encoding
PolicyId -> Value
(PolicyId -> Value)
-> (PolicyId -> Encoding)
-> ([PolicyId] -> Value)
-> ([PolicyId] -> Encoding)
-> ToJSON PolicyId
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [PolicyId] -> Encoding
$ctoEncodingList :: [PolicyId] -> Encoding
toJSONList :: [PolicyId] -> Value
$ctoJSONList :: [PolicyId] -> Value
toEncoding :: PolicyId -> Encoding
$ctoEncoding :: PolicyId -> Encoding
toJSON :: PolicyId -> Value
$ctoJSON :: PolicyId -> Value
ToJSON)
mkPolicyId :: Text -> PolicyId
mkPolicyId :: Text -> PolicyId
mkPolicyId = Text -> PolicyId
PolicyId
unPolicyId :: PolicyId -> Text
unPolicyId :: PolicyId -> Text
unPolicyId (PolicyId Text
a) = Text
a
instance IsString PolicyId where
fromString :: String -> PolicyId
fromString = Text -> PolicyId
mkPolicyId (Text -> PolicyId) -> (String -> Text) -> String -> PolicyId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Data.Text.pack
instance ToCapture (Capture "policy_id" PolicyId) where
toCapture :: Proxy (Capture "policy_id" PolicyId) -> DocCapture
toCapture Proxy (Capture "policy_id" PolicyId)
_ = String -> String -> DocCapture
DocCapture String
"policy_id" String
"Specific policy_id"
instance ToSample PolicyId where
toSamples :: Proxy PolicyId -> [(Text, PolicyId)]
toSamples = [(Text, PolicyId)] -> Proxy PolicyId -> [(Text, PolicyId)]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, PolicyId)] -> Proxy PolicyId -> [(Text, PolicyId)])
-> [(Text, PolicyId)] -> Proxy PolicyId -> [(Text, PolicyId)]
forall a b. (a -> b) -> a -> b
$ [PolicyId] -> [(Text, PolicyId)]
forall a. [a] -> [(Text, a)]
samples [
PolicyId
"476039a0949cf0b22f6a800f56780184c44533887ca6e821007840c3"
]