-- | Metadata queries

module Blockfrost.Client.Cardano.Metadata
  ( getTxMetadataLabels
  , getTxMetadataLabels'
  , getTxMetadataByLabelJSON
  , getTxMetadataByLabelJSON'
  , getTxMetadataByLabelCBOR
  , getTxMetadataByLabelCBOR'
  ) where

import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types
import Data.Text (Text)

metadataClient :: Project -> MetadataAPI (AsClientT BlockfrostClient)
metadataClient :: Project -> MetadataAPI (AsClientT BlockfrostClient)
metadataClient = ((Paged
  -> SortOrder
  -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
 :<|> ((Text
        -> Paged
        -> SortOrder
        -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
       :<|> (Text
             -> Paged
             -> SortOrder
             -> ExceptT
                  BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR])))
-> MetadataAPI (AsClientT BlockfrostClient)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (((Paged
   -> SortOrder
   -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
  :<|> ((Text
         -> Paged
         -> SortOrder
         -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
        :<|> (Text
              -> Paged
              -> SortOrder
              -> ExceptT
                   BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR])))
 -> MetadataAPI (AsClientT BlockfrostClient))
-> (Project
    -> (Paged
        -> SortOrder
        -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
       :<|> ((Text
              -> Paged
              -> SortOrder
              -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
             :<|> (Text
                   -> Paged
                   -> SortOrder
                   -> ExceptT
                        BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR])))
-> Project
-> MetadataAPI (AsClientT BlockfrostClient)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoAPI (AsClientT BlockfrostClient)
-> (Paged
    -> SortOrder
    -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
   :<|> ((Text
          -> Paged
          -> SortOrder
          -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
         :<|> (Text
               -> Paged
               -> SortOrder
               -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]))
forall route.
CardanoAPI route
-> route
   :- ("metadata"
       :> (Tag "Cardano \187 Metadata" :> ToServantApi MetadataAPI))
_metadata (CardanoAPI (AsClientT BlockfrostClient)
 -> (Paged
     -> SortOrder
     -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
    :<|> ((Text
           -> Paged
           -> SortOrder
           -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
          :<|> (Text
                -> Paged
                -> SortOrder
                -> ExceptT
                     BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR])))
-> (Project -> CardanoAPI (AsClientT BlockfrostClient))
-> Project
-> (Paged
    -> SortOrder
    -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
   :<|> ((Text
          -> Paged
          -> SortOrder
          -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
         :<|> (Text
               -> Paged
               -> SortOrder
               -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> CardanoAPI (AsClientT BlockfrostClient)
cardanoClient

getTxMetadataLabels_ :: Project -> Paged -> SortOrder -> BlockfrostClient [TxMeta]
getTxMetadataLabels_ :: Project
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
getTxMetadataLabels_ = MetadataAPI (AsClientT BlockfrostClient)
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
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 (MetadataAPI (AsClientT BlockfrostClient)
 -> Paged
 -> SortOrder
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
-> (Project -> MetadataAPI (AsClientT BlockfrostClient))
-> Project
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> MetadataAPI (AsClientT BlockfrostClient)
metadataClient

-- | List of all used transaction metadata labels.
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getTxMetadataLabels' :: Paged -> SortOrder -> BlockfrostClient [TxMeta]
getTxMetadataLabels' :: Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
getTxMetadataLabels' Paged
pg SortOrder
s = (Project
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta])
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
forall a. (Project -> BlockfrostClient a) -> BlockfrostClient a
go (\Project
p -> Project
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
getTxMetadataLabels_ Project
p Paged
pg SortOrder
s)

-- | List of all used transaction metadata labels.
getTxMetadataLabels :: BlockfrostClient [TxMeta]
getTxMetadataLabels :: ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
getTxMetadataLabels = Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMeta]
getTxMetadataLabels' Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getTxMetadataByLabelJSON_ :: Project -> Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaJSON]
getTxMetadataByLabelJSON_ :: Project
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
getTxMetadataByLabelJSON_ = MetadataAPI (AsClientT BlockfrostClient)
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
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 (MetadataAPI (AsClientT BlockfrostClient)
 -> Text
 -> Paged
 -> SortOrder
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
-> (Project -> MetadataAPI (AsClientT BlockfrostClient))
-> Project
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> MetadataAPI (AsClientT BlockfrostClient)
metadataClient

-- | Transaction metadata per label (JSON @Value@)
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getTxMetadataByLabelJSON' :: Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaJSON]
getTxMetadataByLabelJSON' :: Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
getTxMetadataByLabelJSON' Text
t Paged
pg SortOrder
s = (Project
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON])
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
forall a. (Project -> BlockfrostClient a) -> BlockfrostClient a
go (\Project
p -> Project
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
getTxMetadataByLabelJSON_ Project
p Text
t Paged
pg SortOrder
s)

-- | Transaction metadata per label (JSON @Value@)
getTxMetadataByLabelJSON :: Text -> BlockfrostClient [TxMetaJSON]
getTxMetadataByLabelJSON :: Text
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
getTxMetadataByLabelJSON Text
t = Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaJSON]
getTxMetadataByLabelJSON' Text
t Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getTxMetadataByLabelCBOR_ :: Project -> Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaCBOR]
getTxMetadataByLabelCBOR_ :: Project
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
getTxMetadataByLabelCBOR_ = MetadataAPI (AsClientT BlockfrostClient)
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
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 (MetadataAPI (AsClientT BlockfrostClient)
 -> Text
 -> Paged
 -> SortOrder
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR])
-> (Project -> MetadataAPI (AsClientT BlockfrostClient))
-> Project
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> MetadataAPI (AsClientT BlockfrostClient)
metadataClient

-- | Transaction metadata per label (CBOR @ByteString@)
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getTxMetadataByLabelCBOR' :: Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaCBOR]
getTxMetadataByLabelCBOR' :: Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
getTxMetadataByLabelCBOR' Text
t Paged
pg SortOrder
s = (Project
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR])
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
forall a. (Project -> BlockfrostClient a) -> BlockfrostClient a
go (\Project
p -> Project
-> Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
getTxMetadataByLabelCBOR_ Project
p Text
t Paged
pg SortOrder
s)

-- | Transaction metadata per label (CBOR @ByteString@)
getTxMetadataByLabelCBOR :: Text -> BlockfrostClient [TxMetaCBOR]
getTxMetadataByLabelCBOR :: Text
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
getTxMetadataByLabelCBOR Text
t = Text
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [TxMetaCBOR]
getTxMetadataByLabelCBOR' Text
t Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def