-- | Pool queries

module Blockfrost.Client.Cardano.Pools
  ( listPools
  , listPools'
  , listPoolsExtended
  , listPoolsExtended'
  , listRetiredPools
  , listRetiredPools'
  , listRetiringPools
  , listRetiringPools'
  , getPool
  , getPoolHistory
  , getPoolHistory'
  , getPoolMetadata
  , getPoolRelays
  , getPoolDelegators
  , getPoolDelegators'
  , getPoolBlocks
  , getPoolBlocks'
  , getPoolUpdates
  , getPoolUpdates'
  ) where

import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types

poolsClient :: MonadBlockfrost m => Project -> PoolsAPI (AsClientT m)
poolsClient :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient = 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
   :- ("pools" :> (Tag "Cardano \187 Pools" :> ToServantApi PoolsAPI))
_pools forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient

listPools_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [PoolId]
listPools_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [PoolId]
listPools_ = forall route.
PoolsAPI route
-> route
   :- (Summary "List of stake pools"
       :> (Description "List of registered stake pools."
           :> (Pagination :> (Sorting :> Get '[JSON] [PoolId]))))
_listPools forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | List registered stake pools.
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
listPools' :: MonadBlockfrost m => Paged -> SortOrder -> m [PoolId]
listPools' :: forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [PoolId]
listPools' 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 [PoolId]
listPools_ Project
p Paged
pg SortOrder
s)

-- | List registered stake pools.
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
listPools :: MonadBlockfrost m => m [PoolId]
listPools :: forall (m :: * -> *). MonadBlockfrost m => m [PoolId]
listPools = forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [PoolId]
listPools' forall a. Default a => a
def forall a. Default a => a
def

listPoolsExtended_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [Pool]
listPoolsExtended_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [Pool]
listPoolsExtended_ = forall route.
PoolsAPI route
-> route
   :- (Summary "List of stake pools with additional information"
       :> (Description
             "List of registered stake pools with additional information."
           :> ("extended"
               :> (Pagination :> (Sorting :> Get '[JSON] [Pool])))))
_listPoolsExtended forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | List registered stake pools with additional info
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
listPoolsExtended' :: MonadBlockfrost m => Paged -> SortOrder -> m [Pool]
listPoolsExtended' :: forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [Pool]
listPoolsExtended' 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 [Pool]
listPoolsExtended_ Project
p Paged
pg SortOrder
s)

-- | List registered stake pools with additional info.
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
listPoolsExtended :: MonadBlockfrost m => m [Pool]
listPoolsExtended :: forall (m :: * -> *). MonadBlockfrost m => m [Pool]
listPoolsExtended = forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [Pool]
listPoolsExtended' forall a. Default a => a
def forall a. Default a => a
def

listRetiredPools_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [PoolEpoch]
listRetiredPools_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [PoolEpoch]
listRetiredPools_ = forall route.
PoolsAPI route
-> route
   :- (Summary "List of retired stake pools"
       :> (Description "List of already retired stake pools."
           :> ("retired"
               :> (Pagination :> (Sorting :> Get '[JSON] [PoolEpoch])))))
_listRetiredPools forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | List retired stake pools.
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
listRetiredPools' :: MonadBlockfrost m => Paged -> SortOrder -> m [PoolEpoch]
listRetiredPools' :: forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [PoolEpoch]
listRetiredPools' 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 [PoolEpoch]
listRetiredPools_ Project
p Paged
pg SortOrder
s)

-- | List retired stake pools.
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
listRetiredPools :: MonadBlockfrost m => m [PoolEpoch]
listRetiredPools :: forall (m :: * -> *). MonadBlockfrost m => m [PoolEpoch]
listRetiredPools = forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [PoolEpoch]
listRetiredPools' forall a. Default a => a
def forall a. Default a => a
def

listRetiringPools_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [PoolEpoch]
listRetiringPools_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [PoolEpoch]
listRetiringPools_ = forall route.
PoolsAPI route
-> route
   :- (Summary "List of retiring stake pools"
       :> (Description
             "List of stake pools retiring in the upcoming epochs"
           :> ("retiring"
               :> (Pagination :> (Sorting :> Get '[JSON] [PoolEpoch])))))
_listRetiringPools forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | List retiring stake pools.
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
listRetiringPools' :: MonadBlockfrost m => Paged -> SortOrder -> m [PoolEpoch]
listRetiringPools' :: forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [PoolEpoch]
listRetiringPools' 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 [PoolEpoch]
listRetiringPools_ Project
p Paged
pg SortOrder
s)

-- | List retiring stake pools.
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
listRetiringPools :: MonadBlockfrost m => m [PoolEpoch]
listRetiringPools :: forall (m :: * -> *). MonadBlockfrost m => m [PoolEpoch]
listRetiringPools = forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [PoolEpoch]
listRetiringPools' forall a. Default a => a
def forall a. Default a => a
def

getPool_ :: MonadBlockfrost m => Project -> PoolId -> m PoolInfo
getPool_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> m PoolInfo
getPool_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Specific stake pool"
       :> (Description "Pool information."
           :> (Capture "pool_id" PoolId :> Get '[JSON] PoolInfo)))
_getPool forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get specific stake pool information
getPool :: MonadBlockfrost m => PoolId -> m PoolInfo
getPool :: forall (m :: * -> *). MonadBlockfrost m => PoolId -> m PoolInfo
getPool PoolId
p = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> m PoolInfo
`getPool_` PoolId
p)

getPoolHistory_ :: MonadBlockfrost m => Project -> PoolId -> Paged -> SortOrder -> m [PoolHistory]
getPoolHistory_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [PoolHistory]
getPoolHistory_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Stake pool history"
       :> (Description "History of stake pool parameters over epochs."
           :> (Capture "pool_id" PoolId
               :> ("history"
                   :> (Pagination :> (Sorting :> Get '[JSON] [PoolHistory]))))))
_getPoolHistory forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get stake pool history
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
getPoolHistory' :: MonadBlockfrost m => PoolId -> Paged -> SortOrder -> m [PoolHistory]
getPoolHistory' :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [PoolHistory]
getPoolHistory' PoolId
pid Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [PoolHistory]
getPoolHistory_ Project
p PoolId
pid Paged
pg SortOrder
s)

-- | Get stake pool history
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getPoolHistory :: MonadBlockfrost m => PoolId -> m [PoolHistory]
getPoolHistory :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> m [PoolHistory]
getPoolHistory PoolId
p = forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [PoolHistory]
getPoolHistory' PoolId
p forall a. Default a => a
def forall a. Default a => a
def

getPoolMetadata_ :: MonadBlockfrost m => Project -> PoolId -> m (Maybe PoolMetadata)
getPoolMetadata_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> m (Maybe PoolMetadata)
getPoolMetadata_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Stake pool metadata"
       :> (Description "Stake pool registration metadata."
           :> (Capture "pool_id" PoolId
               :> ("metadata" :> Get '[JSON] (Maybe PoolMetadata)))))
_getPoolMetadata forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get stake pool metadata
getPoolMetadata :: MonadBlockfrost m => PoolId -> m (Maybe PoolMetadata)
getPoolMetadata :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> m (Maybe PoolMetadata)
getPoolMetadata PoolId
p = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> m (Maybe PoolMetadata)
`getPoolMetadata_` PoolId
p)

getPoolRelays_ :: MonadBlockfrost m => Project -> PoolId -> m [PoolRelay]
getPoolRelays_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> m [PoolRelay]
getPoolRelays_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Stake pool relays"
       :> (Description "Relays of a stake pool."
           :> (Capture "pool_id" PoolId
               :> ("relays" :> Get '[JSON] [PoolRelay]))))
_getPoolRelays forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get stake pool relays
getPoolRelays :: MonadBlockfrost m => PoolId -> m [PoolRelay]
getPoolRelays :: forall (m :: * -> *). MonadBlockfrost m => PoolId -> m [PoolRelay]
getPoolRelays PoolId
p = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> m [PoolRelay]
`getPoolRelays_` PoolId
p)

getPoolDelegators_ :: MonadBlockfrost m => Project -> PoolId -> Paged -> SortOrder -> m [PoolDelegator]
getPoolDelegators_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [PoolDelegator]
getPoolDelegators_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Stake pool delegators"
       :> (Description "List of current stake pools delegators."
           :> (Capture "pool_id" PoolId
               :> ("delegators"
                   :> (Pagination :> (Sorting :> Get '[JSON] [PoolDelegator]))))))
_getPoolDelegators forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get stake pool delegators
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
getPoolDelegators' :: MonadBlockfrost m => PoolId -> Paged -> SortOrder -> m [PoolDelegator]
getPoolDelegators' :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [PoolDelegator]
getPoolDelegators' PoolId
pid Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [PoolDelegator]
getPoolDelegators_ Project
p PoolId
pid Paged
pg SortOrder
s)

-- | Get stake pool delegators
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getPoolDelegators :: MonadBlockfrost m => PoolId -> m [PoolDelegator]
getPoolDelegators :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> m [PoolDelegator]
getPoolDelegators PoolId
p = forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [PoolDelegator]
getPoolDelegators' PoolId
p forall a. Default a => a
def forall a. Default a => a
def

getPoolBlocks_ :: MonadBlockfrost m => Project -> PoolId -> Paged -> SortOrder -> m [BlockHash]
getPoolBlocks_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [BlockHash]
getPoolBlocks_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Stake pool blocks"
       :> (Description "List of stake pool blocks."
           :> (Capture "pool_id" PoolId
               :> ("blocks"
                   :> (Pagination :> (Sorting :> Get '[JSON] [BlockHash]))))))
_getPoolBlocks forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get stake pool blocks
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
getPoolBlocks' :: MonadBlockfrost m => PoolId -> Paged -> SortOrder -> m [BlockHash]
getPoolBlocks' :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [BlockHash]
getPoolBlocks' PoolId
pid Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [BlockHash]
getPoolBlocks_ Project
p PoolId
pid Paged
pg SortOrder
s)

-- | Get stake pool blocks
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getPoolBlocks :: MonadBlockfrost m => PoolId -> m [BlockHash]
getPoolBlocks :: forall (m :: * -> *). MonadBlockfrost m => PoolId -> m [BlockHash]
getPoolBlocks PoolId
p = forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [BlockHash]
getPoolBlocks' PoolId
p forall a. Default a => a
def forall a. Default a => a
def

getPoolUpdates_ :: MonadBlockfrost m => Project -> PoolId -> Paged -> SortOrder -> m [PoolUpdate]
getPoolUpdates_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [PoolUpdate]
getPoolUpdates_ = forall route.
PoolsAPI route
-> route
   :- (Summary "Stake pool updates"
       :> (Description "List of certificate updates to the stake pool."
           :> (Capture "pool_id" PoolId
               :> ("updates"
                   :> (Pagination :> (Sorting :> Get '[JSON] [PoolUpdate]))))))
_getPoolUpdates forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolsAPI (AsClientT m)
poolsClient

-- | Get stake pool updates
-- Allows custom paging and ordering using 'Paged' and 'SortOrder'.
getPoolUpdates' :: MonadBlockfrost m => PoolId -> Paged -> SortOrder -> m [PoolUpdate]
getPoolUpdates' :: forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [PoolUpdate]
getPoolUpdates' PoolId
pid Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PoolId -> Paged -> SortOrder -> m [PoolUpdate]
getPoolUpdates_ Project
p PoolId
pid Paged
pg SortOrder
s)

-- | Get stake pool updates
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getPoolUpdates :: MonadBlockfrost m => PoolId -> m [PoolUpdate]
getPoolUpdates :: forall (m :: * -> *). MonadBlockfrost m => PoolId -> m [PoolUpdate]
getPoolUpdates PoolId
p = forall (m :: * -> *).
MonadBlockfrost m =>
PoolId -> Paged -> SortOrder -> m [PoolUpdate]
getPoolUpdates' PoolId
p forall a. Default a => a
def forall a. Default a => a
def