-- | Nut.link services

{-# OPTIONS_HADDOCK hide #-}

module Blockfrost.API.NutLink
  where

import Blockfrost.Types
import Blockfrost.Util.Pagination
import Blockfrost.Util.Sorting
import Data.Text (Text)
import Servant.API
import Servant.API.Generic
import Servant.Docs (DocCapture (..), ToCapture (..))

data NutLinkAPI route =
  NutLinkAPI
    {
      forall route.
NutLinkAPI route
-> route
   :- (Summary "List metadata about specific address"
       :> (Description "List metadata about specific address"
           :> (Capture "address" Address :> Get '[JSON] NutlinkAddress)))
_address
        :: route
        :- Summary "List metadata about specific address"
        :> Description "List metadata about specific address"
        :> Capture "address" Address
        :> Get '[JSON] NutlinkAddress
    , forall route.
NutLinkAPI route
-> route
   :- (Summary "List tickers for a specific metadata oracle"
       :> (Description "List tickers for a specific metadata oracle"
           :> (Capture "address" Address
               :> ("tickers"
                   :> (Pagination
                       :> (Sorting :> Get '[JSON] [NutlinkAddressTicker]))))))
_listAddressTickers
        :: route
        :- Summary "List tickers for a specific metadata oracle"
        :> Description "List tickers for a specific metadata oracle"
        :> Capture "address" Address
        :> "tickers"
        :> Pagination
        :> Sorting
        :> Get '[JSON] [NutlinkAddressTicker]
    , forall route.
NutLinkAPI route
-> route
   :- (Summary "List of records of a specific ticker"
       :> (Description "List of records of a specific ticker"
           :> (Capture "address" Address
               :> ("tickers"
                   :> (Capture "ticker" Text
                       :> (Pagination :> (Sorting :> Get '[JSON] [NutlinkTicker])))))))
_addressTickers
        :: route
        :- Summary "List of records of a specific ticker"
        :> Description "List of records of a specific ticker"
        :> Capture "address" Address
        :> "tickers"
        :> Capture "ticker" Text
        :> Pagination
        :> Sorting
        :> Get '[JSON] [NutlinkTicker]
    , forall route.
NutLinkAPI route
-> route
   :- (Summary "List of records of a specific ticker"
       :> (Description "List of records of a specific ticker"
           :> ("tickers"
               :> (Capture "ticker" Text
                   :> (Pagination
                       :> (Sorting :> Get '[JSON] [(Address, NutlinkTicker)]))))))
_tickers
        :: route
        :- Summary "List of records of a specific ticker"
        :> Description "List of records of a specific ticker"
        :> "tickers"
        :> Capture "ticker" Text
        :> Pagination
        :> Sorting
        :> Get '[JSON] [(Address, NutlinkTicker)]
    } deriving ((forall x. NutLinkAPI route -> Rep (NutLinkAPI route) x)
-> (forall x. Rep (NutLinkAPI route) x -> NutLinkAPI route)
-> Generic (NutLinkAPI route)
forall x. Rep (NutLinkAPI route) x -> NutLinkAPI route
forall x. NutLinkAPI route -> Rep (NutLinkAPI route) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall route x. Rep (NutLinkAPI route) x -> NutLinkAPI route
forall route x. NutLinkAPI route -> Rep (NutLinkAPI route) x
$cfrom :: forall route x. NutLinkAPI route -> Rep (NutLinkAPI route) x
from :: forall x. NutLinkAPI route -> Rep (NutLinkAPI route) x
$cto :: forall route x. Rep (NutLinkAPI route) x -> NutLinkAPI route
to :: forall x. Rep (NutLinkAPI route) x -> NutLinkAPI route
Generic)

instance ToCapture (Capture "ticker" Text) where
  toCapture :: Proxy (Capture "ticker" Text) -> DocCapture
toCapture Proxy (Capture "ticker" Text)
_ = String -> String -> DocCapture
DocCapture String
"ticker" String
"Ticker for the pool record"