module Cryptsy.API.Public.OrderData
( GOrderData(..), OrderData
, parseOrderData, orderData
, module Cryptsy.API.Public.Types.OrderBook
, module Cryptsy.API.Public.Types.Monad
, module Cryptsy.API.Public.Types.Num
)
where
import Data.Aeson (FromJSON(..), Value, withObject)
import Data.Aeson.Types (Parser)
import Data.Function (($))
import Data.Functor (fmap, (<$>))
import Data.String (String)
import Data.Traversable (mapM)
import Prelude ()
import Text.Show (Show)
import Data.Text (Text)
import Data.HashMap.Strict (HashMap)
import Cryptsy.API.Public.Internal
import Cryptsy.API.Public.Types.OrderBook
import Cryptsy.API.Public.Types.Monad
import Cryptsy.API.Public.Types.Num
newtype GOrderData p q t =
OrderData { orderBooks :: HashMap Text (GOrderBook p q t) }
deriving Show
type OrderData = GOrderData CryptsyNum CryptsyNum CryptsyNum
instance FromJSON (GOrderBook p q t) => FromJSON (GOrderData p q t) where
parseJSON = parseOrderData parseJSON
parseOrderData :: (Value -> Parser (GOrderBook p q t))
-> Value -> Parser (GOrderData p q t)
parseOrderData parseBook =
withObject "OrderData" $ fmap OrderData <$> mapM parseBook
orderdataURL :: String
orderdataURL = pubURL "orderdata"
orderData :: FromJSON (GOrderData p q t) => PubCryptsy (GOrderData p q t)
orderData = pubCryptsy orderdataURL parseJSON