module Blockfrost.Types.Shared.AssetId
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 AssetId = AssetId Text
deriving stock (AssetId -> AssetId -> Bool
(AssetId -> AssetId -> Bool)
-> (AssetId -> AssetId -> Bool) -> Eq AssetId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetId -> AssetId -> Bool
$c/= :: AssetId -> AssetId -> Bool
== :: AssetId -> AssetId -> Bool
$c== :: AssetId -> AssetId -> Bool
Eq, Int -> AssetId -> ShowS
[AssetId] -> ShowS
AssetId -> String
(Int -> AssetId -> ShowS)
-> (AssetId -> String) -> ([AssetId] -> ShowS) -> Show AssetId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetId] -> ShowS
$cshowList :: [AssetId] -> ShowS
show :: AssetId -> String
$cshow :: AssetId -> String
showsPrec :: Int -> AssetId -> ShowS
$cshowsPrec :: Int -> AssetId -> ShowS
Show, (forall x. AssetId -> Rep AssetId x)
-> (forall x. Rep AssetId x -> AssetId) -> Generic AssetId
forall x. Rep AssetId x -> AssetId
forall x. AssetId -> Rep AssetId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetId x -> AssetId
$cfrom :: forall x. AssetId -> Rep AssetId x
Generic)
deriving newtype (ByteString -> Either Text AssetId
Text -> Either Text AssetId
(Text -> Either Text AssetId)
-> (ByteString -> Either Text AssetId)
-> (Text -> Either Text AssetId)
-> FromHttpApiData AssetId
forall a.
(Text -> Either Text a)
-> (ByteString -> Either Text a)
-> (Text -> Either Text a)
-> FromHttpApiData a
parseQueryParam :: Text -> Either Text AssetId
$cparseQueryParam :: Text -> Either Text AssetId
parseHeader :: ByteString -> Either Text AssetId
$cparseHeader :: ByteString -> Either Text AssetId
parseUrlPiece :: Text -> Either Text AssetId
$cparseUrlPiece :: Text -> Either Text AssetId
FromHttpApiData, AssetId -> ByteString
AssetId -> Builder
AssetId -> Text
(AssetId -> Text)
-> (AssetId -> Builder)
-> (AssetId -> ByteString)
-> (AssetId -> Text)
-> ToHttpApiData AssetId
forall a.
(a -> Text)
-> (a -> Builder)
-> (a -> ByteString)
-> (a -> Text)
-> ToHttpApiData a
toQueryParam :: AssetId -> Text
$ctoQueryParam :: AssetId -> Text
toHeader :: AssetId -> ByteString
$ctoHeader :: AssetId -> ByteString
toEncodedUrlPiece :: AssetId -> Builder
$ctoEncodedUrlPiece :: AssetId -> Builder
toUrlPiece :: AssetId -> Text
$ctoUrlPiece :: AssetId -> Text
ToHttpApiData, Value -> Parser [AssetId]
Value -> Parser AssetId
(Value -> Parser AssetId)
-> (Value -> Parser [AssetId]) -> FromJSON AssetId
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AssetId]
$cparseJSONList :: Value -> Parser [AssetId]
parseJSON :: Value -> Parser AssetId
$cparseJSON :: Value -> Parser AssetId
FromJSON, [AssetId] -> Encoding
[AssetId] -> Value
AssetId -> Encoding
AssetId -> Value
(AssetId -> Value)
-> (AssetId -> Encoding)
-> ([AssetId] -> Value)
-> ([AssetId] -> Encoding)
-> ToJSON AssetId
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AssetId] -> Encoding
$ctoEncodingList :: [AssetId] -> Encoding
toJSONList :: [AssetId] -> Value
$ctoJSONList :: [AssetId] -> Value
toEncoding :: AssetId -> Encoding
$ctoEncoding :: AssetId -> Encoding
toJSON :: AssetId -> Value
$ctoJSON :: AssetId -> Value
ToJSON)
mkAssetId :: Text -> AssetId
mkAssetId :: Text -> AssetId
mkAssetId = Text -> AssetId
AssetId
unAssetId :: AssetId -> Text
unAssetId :: AssetId -> Text
unAssetId (AssetId Text
a) = Text
a
instance IsString AssetId where
fromString :: String -> AssetId
fromString = Text -> AssetId
mkAssetId (Text -> AssetId) -> (String -> Text) -> String -> AssetId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Data.Text.pack
instance ToCapture (Capture "asset" AssetId) where
toCapture :: Proxy (Capture "asset" AssetId) -> DocCapture
toCapture Proxy (Capture "asset" AssetId)
_ = String -> String -> DocCapture
DocCapture String
"asset" String
"Concatenation of the policy_id and hex-encoded asset_name"
instance ToSample AssetId where
toSamples :: Proxy AssetId -> [(Text, AssetId)]
toSamples = [(Text, AssetId)] -> Proxy AssetId -> [(Text, AssetId)]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AssetId)] -> Proxy AssetId -> [(Text, AssetId)])
-> [(Text, AssetId)] -> Proxy AssetId -> [(Text, AssetId)]
forall a b. (a -> b) -> a -> b
$ [AssetId] -> [(Text, AssetId)]
forall a. [a] -> [(Text, a)]
samples [
AssetId
"b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
, AssetId
"6804edf9712d2b619edb6ac86861fe93a730693183a262b165fcc1ba1bc99cad"
]