File tree Expand file tree Collapse file tree 7 files changed +47
-7
lines changed Expand file tree Collapse file tree 7 files changed +47
-7
lines changed Original file line number Diff line number Diff line change @@ -466,7 +466,8 @@ candlesLast tf sym opts =
466
466
Generic. pub
467
467
@ 'CandlesLast
468
468
( catMaybes
469
- [ SomeQueryParam " limit" <$> Candles. limit opts,
469
+ [ SomeQueryParam " sort" <$> Candles. ascOrDesc opts,
470
+ SomeQueryParam " limit" <$> Candles. limit opts,
470
471
SomeQueryParam " start" <$> Candles. start opts,
471
472
SomeQueryParam " end" <$> Candles. end opts
472
473
]
@@ -490,7 +491,8 @@ candlesHist tf sym opts =
490
491
Generic. pub
491
492
@ 'CandlesHist
492
493
( catMaybes
493
- [ SomeQueryParam " limit" <$> Candles. limit opts,
494
+ [ SomeQueryParam " sort" <$> Candles. ascOrDesc opts,
495
+ SomeQueryParam " limit" <$> Candles. limit opts,
494
496
SomeQueryParam " start" <$> Candles. start opts,
495
497
SomeQueryParam " end" <$> Candles. end opts
496
498
]
Original file line number Diff line number Diff line change @@ -67,3 +67,8 @@ instance ToRequestParam QuotePerBase where
67
67
. abs
68
68
. from @ (Ratio Natural ) @ Rational
69
69
. unQuotePerBase
70
+
71
+ instance ToRequestParam AscOrDesc where
72
+ toTextParam = \ case
73
+ Asc -> " 1"
74
+ Desc -> " -1"
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ data Request = Request
48
48
)
49
49
50
50
data Options = Options
51
- { limit :: Maybe Natural ,
51
+ { ascOrDesc :: Maybe AscOrDesc ,
52
+ limit :: Maybe Natural ,
52
53
start :: Maybe UTCTime ,
53
54
end :: Maybe UTCTime
54
55
}
@@ -64,7 +65,8 @@ data Options = Options
64
65
optsDef :: Options
65
66
optsDef =
66
67
Options
67
- { limit = Just 10000 ,
68
+ { ascOrDesc = Nothing ,
69
+ limit = Just 10000 ,
68
70
start = Nothing ,
69
71
end = Nothing
70
72
}
Original file line number Diff line number Diff line change @@ -108,10 +108,22 @@ spec = before sysEnv $ do
108
108
res <- tryAny . Bfx. netWorth env $ CurrencyCode " BTC"
109
109
res `shouldSatisfy` isRight
110
110
it " candlesLast succeeds" . const $ do
111
- res <- tryAny $ Bfx. candlesLast Ctf1h adaBtc Candles. optsDef
111
+ res <-
112
+ tryAny
113
+ . Bfx. candlesLast Ctf1h adaBtc
114
+ $ Candles. optsDef
115
+ & # ascOrDesc
116
+ .~ Just Desc
112
117
res `shouldSatisfy` isRight
113
118
it " candlesHist succeeds" . const $ do
114
- res <- tryAny $ Bfx. candlesHist Ctf1h adaBtc Candles. optsDef
119
+ res <-
120
+ tryAny
121
+ . Bfx. candlesHist Ctf1h btcUsd
122
+ $ Candles. optsDef
123
+ & # ascOrDesc
124
+ .~ Just Asc
125
+ & # limit
126
+ .~ Just 5
115
127
res `shouldSatisfy` isRight
116
128
it " mkOrder" . const $ do
117
129
let req =
Original file line number Diff line number Diff line change @@ -518,7 +518,6 @@ test-suite functora-test
518
518
build-depends :
519
519
, aes
520
520
, bolt11
521
- , card-lib
522
521
, cfg
523
522
, elm2miso-lib
524
523
, functora
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import Data.Binary.Instances ()
16
16
import Functora.Prelude
17
17
import qualified GHC.Generics as Generics
18
18
import qualified Text.URI as URI
19
+ import Toml (HasCodec , HasItemCodec )
19
20
import qualified Toml
20
21
#if defined(__GHCJS__) || defined(ghcjs_HOST_OS) || defined(wasi_HOST_OS)
21
22
import Data.JSString (JSString )
@@ -237,3 +238,7 @@ instance Toml.HasItemCodec JSString where
237
238
$ Toml. Text
238
239
. from @ JSString @ Text
239
240
#endif
241
+
242
+ deriving via GenericEnum AscOrDesc instance HasCodec AscOrDesc
243
+
244
+ deriving via GenericEnum AscOrDesc instance HasItemCodec AscOrDesc
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ module Functora.Prelude
118
118
Mono ,
119
119
dropAround ,
120
120
dropWhileEnd ,
121
+ AscOrDesc (.. ),
121
122
122
123
-- * DerivingVia
123
124
-- $derivingVia
@@ -1129,6 +1130,20 @@ dropWhileEnd f =
1129
1130
)
1130
1131
mempty
1131
1132
1133
+ data AscOrDesc
1134
+ = Asc
1135
+ | Desc
1136
+ deriving stock
1137
+ ( Eq ,
1138
+ Ord ,
1139
+ Show ,
1140
+ Read ,
1141
+ Data ,
1142
+ Generic ,
1143
+ Enum ,
1144
+ Bounded
1145
+ )
1146
+
1132
1147
-- $derivingVia
1133
1148
-- Newtypes to simplify deriving via.
1134
1149
-- We have to expose default constructors/accessors
You can’t perform that action at this time.
0 commit comments