{-# LANGUAGE DataKinds     #-}
{-# LANGUAGE TypeOperators #-}

module CoinbasePro.Unauthenticated
   ( products
   , aggregateOrderBook
   , fullOrderBook
   , trades
   , candles
   , stats
   , currencies
   , time
   ) where

import           Data.Time.Clock                           (UTCTime)
import           Servant.Client                            (ClientM)

import           CoinbasePro.Headers                       (userAgent)
import           CoinbasePro.MarketData.AggregateOrderBook (AggregateOrderBook)
import           CoinbasePro.MarketData.FullOrderBook      (FullOrderBook)
import           CoinbasePro.MarketData.Types              (AggregateBookLevel (..),
                                                            CBTime,
                                                            FullBookLevel (..),
                                                            Product, Trade)
import           CoinbasePro.Types                         (Candle,
                                                            CandleGranularity,
                                                            Currency, ProductId,
                                                            TwentyFourHourStats)
import qualified CoinbasePro.Unauthenticated.API           as API


-- | https://docs.pro.coinbase.com/#get-products
products :: ClientM [Product]
products :: ClientM [Product]
products = CBRequest [Product]
API.products UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#get-product-order-book
aggregateOrderBook :: ProductId -> Maybe AggregateBookLevel -> ClientM AggregateOrderBook
aggregateOrderBook :: ProductId -> Maybe AggregateBookLevel -> ClientM AggregateOrderBook
aggregateOrderBook ProductId
prid Maybe AggregateBookLevel
agg = ProductId
-> Maybe AggregateBookLevel -> CBRequest AggregateOrderBook
API.aggregateOrderBook ProductId
prid Maybe AggregateBookLevel
agg UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#get-product-order-book
fullOrderBook :: ProductId -> ClientM FullOrderBook
fullOrderBook :: ProductId -> ClientM FullOrderBook
fullOrderBook ProductId
prid = ProductId -> Maybe FullBookLevel -> CBRequest FullOrderBook
API.fullOrderBook ProductId
prid (FullBookLevel -> Maybe FullBookLevel
forall a. a -> Maybe a
Just FullBookLevel
FullBookLevel) UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#get-trades
trades :: ProductId -> ClientM [Trade]
trades :: ProductId -> ClientM [Trade]
trades ProductId
prid = ProductId -> CBRequest [Trade]
API.trades ProductId
prid UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#get-historic-rates
candles :: ProductId -> Maybe UTCTime -> Maybe UTCTime -> CandleGranularity -> ClientM [Candle]
candles :: ProductId
-> Maybe UTCTime
-> Maybe UTCTime
-> CandleGranularity
-> ClientM [Candle]
candles ProductId
prid Maybe UTCTime
start Maybe UTCTime
end CandleGranularity
cg = ProductId
-> Maybe UTCTime
-> Maybe UTCTime
-> CandleGranularity
-> CBRequest [Candle]
API.candles ProductId
prid Maybe UTCTime
start Maybe UTCTime
end CandleGranularity
cg UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#get-24hr-stats
stats :: ProductId -> ClientM TwentyFourHourStats
stats :: ProductId -> ClientM TwentyFourHourStats
stats ProductId
prid = ProductId -> CBRequest TwentyFourHourStats
API.stats ProductId
prid UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#get-currencies
currencies :: ClientM [Currency]
currencies :: ClientM [Currency]
currencies = CBRequest [Currency]
API.currencies UserAgent
userAgent


-- | https://docs.pro.coinbase.com/#time
time :: ClientM CBTime
time :: ClientM CBTime
time = CBRequest CBTime
API.time UserAgent
userAgent