Bring parse call into common logic.
[haskell-cryptsy-api.git] / Cryptsy / API / Public / MarketData / Old.hs
blob37a935b322816a6cfbef4ddcdd1ffabb3d076cb9
1 {-# LANGUAGE FlexibleContexts #-}
2 module Cryptsy.API.Public.MarketData.Old
3 ( getMarketData, marketData, jsonMarketData
4 , module Cryptsy.API.Public.MarketData
6 where
8 -- aeson
9 import Data.Aeson (withObject)
11 -- base
12 import Control.Applicative (pure)
14 -- this pacakge
15 import Cryptsy.API.Public
16 import Cryptsy.API.Public.MarketData
18 -- |URL for API call
19 marketdataURL :: String
20 marketdataURL = pubURL "marketdata"
22 {-|
23 "Raw" request, does not convert the JSON value, but simply returns the JSON
24 value bound to the "return" key from the response body.
26 getMarketData :: PubCryptsy Value
27 getMarketData = pubCryptsy marketdataURL pure
29 {-|
30 "Cooked" request, extracts the JSON object bound to the "market" key of the
31 object boudn to the "return" key and converts it.
33 marketData :: (Object -> Parser (GMarketData p q dt t)) -- ^ market data parser
34 -> PubCryptsy (GMarketData p q dt t)
35 marketData parseMarkets = pubCryptsy marketdataURL . onMarkets
36 $ withObject "MarketData" parseMarkets
38 -- |"Cooked" request with implicit parser.
39 jsonMarketData :: FromJSON (GMarketData p q dt t)
40 => PubCryptsy (GMarketData p q dt t)
41 jsonMarketData = pubCryptsy marketdataURL parseJSON