Commit 1c79f0a5 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API Change][FIX]Reply or replies.

parent 069118b2
......@@ -36,7 +36,7 @@ type AuthorQuery = Text
get :: Maybe Limit
-> Maybe TextQuery
-> Maybe AuthorQuery
-> IO (Either ServantError Reply)
-> IO (Either ServantError Content)
get n q a = do
manager' <- newManager tlsManagerSettings
runClientM (clientIsidore n q a)
......
......@@ -99,7 +99,8 @@ data IsidoreDoc = IsidoreDoc
deriving (Show)
data Reply = Reply { _docs :: [IsidoreDoc]}
data Reply = Replies { _docs :: [IsidoreDoc]}
| Reply { _doc :: IsidoreDoc}
deriving (Show)
instance FromJSON IsidoreDoc where
......@@ -113,15 +114,23 @@ instance FromJSON IsidoreDoc where
i = (o .: "isidore")
data Content = Content { _reply :: Reply }
deriving Show
instance FromJSON Reply where
parseJSON (Object o) = Reply <$> (responseReplies >>= parseJSON)
instance FromJSON Content where
parseJSON (Object o) = Content <$> (responseReplies >>= parseJSON)
where
responseReplies = (o .: "response")
>>= (.: "replies")
>>= (.: "content")
>>= (.: "reply")
instance FromJSON Reply where
parseJSON (Array os) = Replies <$> mapM parseJSON (V.toList os)
parseJSON o = Reply <$> parseJSON o
data Output = JSON
instance ToHttpApiData Output where
......@@ -134,12 +143,12 @@ type Search = "search"
:> QueryParam "output" Output
:> QueryParam "q" T.Text
:> QueryParam "author" T.Text
:> Get '[JSON] Reply
:> Get '[JSON] Content
isidoreAPI :: Proxy IsidoreAPI
isidoreAPI = Proxy
clientIsidore :: Maybe Int -> Maybe T.Text -> Maybe T.Text -> ClientM Reply
clientIsidore :: Maybe Int -> Maybe T.Text -> Maybe T.Text -> ClientM Content
clientIsidore n q a = client isidoreAPI n (Just JSON) q a
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment