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 ...@@ -36,7 +36,7 @@ type AuthorQuery = Text
get :: Maybe Limit get :: Maybe Limit
-> Maybe TextQuery -> Maybe TextQuery
-> Maybe AuthorQuery -> Maybe AuthorQuery
-> IO (Either ServantError Reply) -> IO (Either ServantError Content)
get n q a = do get n q a = do
manager' <- newManager tlsManagerSettings manager' <- newManager tlsManagerSettings
runClientM (clientIsidore n q a) runClientM (clientIsidore n q a)
......
...@@ -99,7 +99,8 @@ data IsidoreDoc = IsidoreDoc ...@@ -99,7 +99,8 @@ data IsidoreDoc = IsidoreDoc
deriving (Show) deriving (Show)
data Reply = Reply { _docs :: [IsidoreDoc]} data Reply = Replies { _docs :: [IsidoreDoc]}
| Reply { _doc :: IsidoreDoc}
deriving (Show) deriving (Show)
instance FromJSON IsidoreDoc where instance FromJSON IsidoreDoc where
...@@ -113,15 +114,23 @@ instance FromJSON IsidoreDoc where ...@@ -113,15 +114,23 @@ instance FromJSON IsidoreDoc where
i = (o .: "isidore") i = (o .: "isidore")
data Content = Content { _reply :: Reply }
deriving Show
instance FromJSON Reply where instance FromJSON Content where
parseJSON (Object o) = Reply <$> (responseReplies >>= parseJSON) parseJSON (Object o) = Content <$> (responseReplies >>= parseJSON)
where where
responseReplies = (o .: "response") responseReplies = (o .: "response")
>>= (.: "replies") >>= (.: "replies")
>>= (.: "content") >>= (.: "content")
>>= (.: "reply") >>= (.: "reply")
instance FromJSON Reply where
parseJSON (Array os) = Replies <$> mapM parseJSON (V.toList os)
parseJSON o = Reply <$> parseJSON o
data Output = JSON data Output = JSON
instance ToHttpApiData Output where instance ToHttpApiData Output where
...@@ -134,12 +143,12 @@ type Search = "search" ...@@ -134,12 +143,12 @@ type Search = "search"
:> QueryParam "output" Output :> QueryParam "output" Output
:> QueryParam "q" T.Text :> QueryParam "q" T.Text
:> QueryParam "author" T.Text :> QueryParam "author" T.Text
:> Get '[JSON] Reply :> Get '[JSON] Content
isidoreAPI :: Proxy IsidoreAPI isidoreAPI :: Proxy IsidoreAPI
isidoreAPI = Proxy 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 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