-- | Epochs API endpoints

{-# OPTIONS_HADDOCK hide #-}

module Blockfrost.API.Cardano.Epochs
  where

import Servant.API
import Servant.API.Generic

import Blockfrost.Types.Cardano.Epochs
import Blockfrost.Types.Shared
import Blockfrost.Util.Pagination
import Blockfrost.Util.Sorting

data EpochsAPI route =
  EpochsAPI
    {
      forall route.
EpochsAPI route
-> route
   :- (Summary "Latest epoch"
       :> (Description
             "Return the information about the latest, therefore current, epoch."
           :> ("latest" :> Get '[JSON] EpochInfo)))
_latestEpoch
        :: route
        :- Summary "Latest epoch"
        :> Description "Return the information about the latest, therefore current, epoch."
        :> "latest"
        :> Get '[JSON] EpochInfo
    , forall route.
EpochsAPI route
-> route
   :- (Summary "Latest epoch protocol parameters"
       :> (Description
             "Return the protocol parameters for the latest epoch."
           :> ("latest" :> ("parameters" :> Get '[JSON] ProtocolParams))))
_latestEpochProtocolParams
        :: route
        :- Summary "Latest epoch protocol parameters"
        :> Description "Return the protocol parameters for the latest epoch."
        :> "latest"
        :> "parameters"
        :> Get '[JSON] ProtocolParams
    , forall route.
EpochsAPI route
-> route
   :- (Summary "Specific epoch"
       :> (Description "Return the content of the requested epoch."
           :> (Capture "epoch_number" Epoch :> Get '[JSON] EpochInfo)))
_getEpoch
        :: route
        :- Summary "Specific epoch"
        :> Description "Return the content of the requested epoch."
        :> Capture "epoch_number" Epoch
        :> Get '[JSON] EpochInfo
    , forall route.
EpochsAPI route
-> route
   :- (Summary "List of next epochs"
       :> (Description
             "Return the list of epochs following a specific epoch."
           :> (Capture "epoch_number" Epoch
               :> ("next" :> (Pagination :> Get '[JSON] [EpochInfo])))))
_getNextEpochs
        :: route
        :- Summary "List of next epochs"
        :> Description "Return the list of epochs following a specific epoch."
        :> Capture "epoch_number" Epoch
        :> "next"
        :> Pagination
        :> Get '[JSON] [EpochInfo]
     , forall route.
EpochsAPI route
-> route
   :- (Summary "List of previous epochs"
       :> (Description
             "Return the list of epochs preceding a specific epoch."
           :> (Capture "epoch_number" Epoch
               :> ("previous" :> (Pagination :> Get '[JSON] [EpochInfo])))))
_getPreviousEpochs
        :: route
        :- Summary "List of previous epochs"
        :> Description "Return the list of epochs preceding a specific epoch."
        :> Capture "epoch_number" Epoch
        :> "previous"
        :> Pagination
        :> Get '[JSON] [EpochInfo]
     , forall route.
EpochsAPI route
-> route
   :- (Summary "Stake distribution"
       :> (Description
             "Return the active stake distribution for the specified epoch."
           :> (Capture "epoch_number" Epoch
               :> ("stakes" :> (Pagination :> Get '[JSON] [StakeDistribution])))))
_getEpochStake
        :: route
        :- Summary "Stake distribution"
        :> Description "Return the active stake distribution for the specified epoch."
        :> Capture "epoch_number" Epoch
        :> "stakes"
        :> Pagination
        :> Get '[JSON] [StakeDistribution]
     , forall route.
EpochsAPI route
-> route
   :- (Summary "Stake distribution by pool"
       :> (Description
             "Return the active stake distribution for the epoch specified by stake pool."
           :> (Capture "epoch_number" Epoch
               :> ("stakes"
                   :> (Capture "pool_id" PoolId
                       :> (Pagination :> Get '[JSON] [PoolStakeDistribution]))))))
_getEpochStakeByPool
        :: route
        :- Summary "Stake distribution by pool"
        :> Description "Return the active stake distribution for the epoch specified by stake pool."
        :> Capture "epoch_number" Epoch
        :> "stakes"
        :> Capture "pool_id" PoolId
        :> Pagination
        :> Get '[JSON] [PoolStakeDistribution]
     , forall route.
EpochsAPI route
-> route
   :- (Summary "Block distribution"
       :> (Description "Return the blocks minted for the epoch specified."
           :> (Capture "epoch_number" Epoch
               :> ("blocks"
                   :> (Pagination :> (Sorting :> Get '[JSON] [BlockHash]))))))
_getEpochBlocks
        :: route
        :- Summary "Block distribution"
        :> Description "Return the blocks minted for the epoch specified."
        :> Capture "epoch_number" Epoch
        :> "blocks"
        :> Pagination
        :> Sorting
        :> Get '[JSON] [BlockHash]
     , forall route.
EpochsAPI route
-> route
   :- (Summary "Block distribution by pool"
       :> (Description
             "Return the block minted for the epoch specified by stake pool."
           :> (Capture "epoch_number" Epoch
               :> ("blocks"
                   :> (Capture "pool_id" PoolId
                       :> (Pagination :> (Sorting :> Get '[JSON] [BlockHash])))))))
_getEpochBlocksByPool
        :: route
        :- Summary "Block distribution by pool"
        :> Description "Return the block minted for the epoch specified by stake pool."
        :> Capture "epoch_number" Epoch
        :> "blocks"
        :> Capture "pool_id" PoolId
        :> Pagination
        :> Sorting
        :> Get '[JSON] [BlockHash]
    , forall route.
EpochsAPI route
-> route
   :- (Summary "Protocol parameters"
       :> (Description
             "Return the protocol parameters for the specified epoch."
           :> (Capture "epoch_number" Epoch
               :> ("parameters" :> Get '[JSON] ProtocolParams))))
_getEpochProtocolParams
        :: route
        :- Summary "Protocol parameters"
        :> Description "Return the protocol parameters for the specified epoch."
        :> Capture "epoch_number" Epoch
        :> "parameters"
        :> Get '[JSON] ProtocolParams
    } deriving ((forall x. EpochsAPI route -> Rep (EpochsAPI route) x)
-> (forall x. Rep (EpochsAPI route) x -> EpochsAPI route)
-> Generic (EpochsAPI route)
forall x. Rep (EpochsAPI route) x -> EpochsAPI route
forall x. EpochsAPI route -> Rep (EpochsAPI route) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall route x. Rep (EpochsAPI route) x -> EpochsAPI route
forall route x. EpochsAPI route -> Rep (EpochsAPI route) x
$cfrom :: forall route x. EpochsAPI route -> Rep (EpochsAPI route) x
from :: forall x. EpochsAPI route -> Rep (EpochsAPI route) x
$cto :: forall route x. Rep (EpochsAPI route) x -> EpochsAPI route
to :: forall x. Rep (EpochsAPI route) x -> EpochsAPI route
Generic)