hledger-stockquotes 0.1.3.0 → 0.1.3.1
raw patch · 3 files changed
+11/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- hledger-stockquotes.cabal +1/−1
- src/Web/AlphaVantage.hs +4/−3
CHANGELOG.md view
@@ -4,6 +4,12 @@ +## v0.1.3.1++* AlphaVantage changed the message field for API errors to `Error Message` so+ we now try to parse this field out of the response as well.++ ## v0.1.3.0 * Change `Prices` volume field from `Integer` to `Scientific` to support
hledger-stockquotes.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hledger-stockquotes-version: 0.1.3.0+version: 0.1.3.1 synopsis: Generate HLedger Price Directives From Daily Stock Quotes. description: @hledger-stockquotes@ is an addon for <https://hledger.org/ hledger> that reads your journal file, pulls the historical stock prices for commodities,
src/Web/AlphaVantage.hs view
@@ -71,13 +71,14 @@ deriving (Show, Read, Eq, Generic, Functor) --- | Check for errors by attempting to parse a @Note@ or @Information@--- field. If one does not exist, parse the inner type.+-- | Check for errors by attempting to parse a @Error Message@, @Note@ or+-- @Information@ field. If one does not exist, parse the inner type. instance (FromJSON a) => FromJSON (AlphaVantageResponse a) where parseJSON = withObject "AlphaVantageResponse" $ \v -> do+ mbErrorMessage <- v .:? "Error Message" mbErrorNote <- v .:? "Note" mbErrorInfo <- v .:? "Information"- case mbErrorNote <|> mbErrorInfo of+ case mbErrorMessage <|> mbErrorNote <|> mbErrorInfo of Nothing -> ApiResponse <$> parseJSON (Object v) Just note -> return $ ApiError note