-- | Cardano Metadata endpoints

{-# OPTIONS_HADDOCK hide #-}

module Blockfrost.API.Cardano.Metadata
  where

import Data.Text (Text)
import Servant.API
import Servant.API.Generic
import Servant.Docs (DocCapture (..), ToCapture (..))

import Blockfrost.Types.Cardano.Metadata
import Blockfrost.Util.Pagination
import Blockfrost.Util.Sorting

data MetadataAPI route =
  MetadataAPI
    {
      forall route.
MetadataAPI route
-> route
   :- (Summary "Transaction metadata labels"
       :> (Description "List of all used transaction metadata labels."
           :> ("txs"
               :> ("labels"
                   :> (Pagination :> (Sorting :> Get '[JSON] [TxMeta]))))))
_txMetadataLabels
        :: route
        :- Summary "Transaction metadata labels"
        :> Description "List of all used transaction metadata labels."
        :> "txs"
        :> "labels"
        :> Pagination
        :> Sorting
        :> Get '[JSON] [TxMeta]
    , forall route.
MetadataAPI route
-> route
   :- (Summary "Transaction metadata content in JSON"
       :> (Description "Transaction metadata per label."
           :> ("txs"
               :> ("labels"
                   :> (Capture "label" Text
                       :> (Pagination :> (Sorting :> Get '[JSON] [TxMetaJSON])))))))
_txMetadataByLabelJSON
        :: route
        :- Summary "Transaction metadata content in JSON"
        :> Description "Transaction metadata per label."
        :> "txs"
        :> "labels"
        :> Capture "label" Text
        :> Pagination
        :> Sorting
        :> Get '[JSON] [TxMetaJSON]
    , forall route.
MetadataAPI route
-> route
   :- (Summary "Transaction metadata content in CBOR"
       :> (Description "Transaction metadata per label."
           :> ("txs"
               :> ("labels"
                   :> (Capture "label" Text
                       :> ("cbor"
                           :> (Pagination :> (Sorting :> Get '[JSON] [TxMetaCBOR]))))))))
_txMetadataByLabelCBOR
        :: route
        :- Summary "Transaction metadata content in CBOR"
        :> Description "Transaction metadata per label."
        :> "txs"
        :> "labels"
        :> Capture "label" Text
        :> "cbor"
        :> Pagination
        :> Sorting
        :> Get '[JSON] [TxMetaCBOR]
    } deriving ((forall x. MetadataAPI route -> Rep (MetadataAPI route) x)
-> (forall x. Rep (MetadataAPI route) x -> MetadataAPI route)
-> Generic (MetadataAPI route)
forall x. Rep (MetadataAPI route) x -> MetadataAPI route
forall x. MetadataAPI route -> Rep (MetadataAPI route) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall route x. Rep (MetadataAPI route) x -> MetadataAPI route
forall route x. MetadataAPI route -> Rep (MetadataAPI route) x
$cfrom :: forall route x. MetadataAPI route -> Rep (MetadataAPI route) x
from :: forall x. MetadataAPI route -> Rep (MetadataAPI route) x
$cto :: forall route x. Rep (MetadataAPI route) x -> MetadataAPI route
to :: forall x. Rep (MetadataAPI route) x -> MetadataAPI route
Generic)

instance ToCapture (Capture "label" Text) where
  toCapture :: Proxy (Capture "label" Text) -> DocCapture
toCapture Proxy (Capture "label" Text)
_ = String -> String -> DocCapture
DocCapture String
"label" String
"Metadata label"