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
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
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. 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
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 -> Builder
PolicyId -> ByteString
PolicyId -> Text
forall a.
(a -> Text)
-> (a -> Builder)
-> (a -> ByteString)
-> (a -> Text)
-> (a -> Builder)
-> ToHttpApiData a
toEncodedQueryParam :: PolicyId -> Builder
$ctoEncodedQueryParam :: PolicyId -> Builder
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, Maybe PolicyId
Value -> Parser [PolicyId]
Value -> Parser PolicyId
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe PolicyId
$comittedField :: Maybe PolicyId
parseJSONList :: Value -> Parser [PolicyId]
$cparseJSONList :: Value -> Parser [PolicyId]
parseJSON :: Value -> Parser PolicyId
$cparseJSON :: Value -> Parser PolicyId
FromJSON, [PolicyId] -> Encoding
[PolicyId] -> Value
PolicyId -> Bool
PolicyId -> Encoding
PolicyId -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: PolicyId -> Bool
$comitField :: PolicyId -> Bool
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 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 = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples [
PolicyId
"476039a0949cf0b22f6a800f56780184c44533887ca6e821007840c3"
]