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