-- | 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 :: MonadBlockfrost m => Project -> MetadataAPI (AsClientT m)
metadataClient :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> MetadataAPI (AsClientT m)
metadataClient = forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall route.
CardanoAPI route
-> route
   :- ("metadata"
       :> (Tag "Cardano \187 Metadata" :> ToServantApi MetadataAPI))
_metadata forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient

getTxMetadataLabels_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [TxMeta]
getTxMetadataLabels_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [TxMeta]
getTxMetadataLabels_ = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> MetadataAPI (AsClientT m)
metadataClient

-- | List of all used transaction metadata labels.
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
getTxMetadataLabels' :: MonadBlockfrost m => Paged -> SortOrder -> m [TxMeta]
getTxMetadataLabels' :: forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [TxMeta]
getTxMetadataLabels' Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [TxMeta]
getTxMetadataLabels_ Project
p Paged
pg SortOrder
s)

-- | List of all used transaction metadata labels.
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getTxMetadataLabels :: MonadBlockfrost m => m [TxMeta]
getTxMetadataLabels :: forall (m :: * -> *). MonadBlockfrost m => m [TxMeta]
getTxMetadataLabels = forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [TxMeta]
getTxMetadataLabels' forall a. Default a => a
def forall a. Default a => a
def

getTxMetadataByLabelJSON_ :: MonadBlockfrost m => Project -> Text -> Paged -> SortOrder -> m [TxMetaJSON]
getTxMetadataByLabelJSON_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Text -> Paged -> SortOrder -> m [TxMetaJSON]
getTxMetadataByLabelJSON_ = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> MetadataAPI (AsClientT m)
metadataClient

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

-- | Transaction metadata per label (JSON @Value@)
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getTxMetadataByLabelJSON :: MonadBlockfrost m => Text -> m [TxMetaJSON]
getTxMetadataByLabelJSON :: forall (m :: * -> *). MonadBlockfrost m => Text -> m [TxMetaJSON]
getTxMetadataByLabelJSON Text
t = forall (m :: * -> *).
MonadBlockfrost m =>
Text -> Paged -> SortOrder -> m [TxMetaJSON]
getTxMetadataByLabelJSON' Text
t forall a. Default a => a
def forall a. Default a => a
def

getTxMetadataByLabelCBOR_ :: MonadBlockfrost m => Project -> Text -> Paged -> SortOrder -> m [TxMetaCBOR]
getTxMetadataByLabelCBOR_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Text -> Paged -> SortOrder -> m [TxMetaCBOR]
getTxMetadataByLabelCBOR_ = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> MetadataAPI (AsClientT m)
metadataClient

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

-- | Transaction metadata per label (CBOR @ByteString@)
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getTxMetadataByLabelCBOR :: MonadBlockfrost m => Text -> m [TxMetaCBOR]
getTxMetadataByLabelCBOR :: forall (m :: * -> *). MonadBlockfrost m => Text -> m [TxMetaCBOR]
getTxMetadataByLabelCBOR Text
t = forall (m :: * -> *).
MonadBlockfrost m =>
Text -> Paged -> SortOrder -> m [TxMetaCBOR]
getTxMetadataByLabelCBOR' Text
t forall a. Default a => a
def forall a. Default a => a
def