Commit 46cd0d95 authored by Mudada's avatar Mudada

add sources

parent 241037ce
......@@ -18,6 +18,6 @@ basicSearch :: Maybe T.Text -> IO (Either ClientError Documents)
basicSearch rq = do
runIstexAPIClient $
search
(Just "author,title,abstract,publicationDate")
(Just 5)
(Just "author,title,abstract,publicationDate,refBibs")
(Just 5000)
rq
......@@ -19,21 +19,39 @@ import qualified Control.Lens as L
data Author = Author
{
_name :: T.Text,
_affiliations :: [T.Text]
_author_name :: T.Text,
_author_affiliations :: [T.Text]
} deriving (Show, Generic)
L.makeLenses ''Author
instance FromJSON Author where
parseJSON (Object o) =
Author <$> (o .: "name") <*> (o .: "affiliations" <|> pure [])
data Source = Source
{
_source_title :: Maybe T.Text,
_source_authors :: [Author],
_source_publicationDate :: Maybe Int
} deriving (Show, Generic)
L.makeLenses ''Source
instance FromJSON Source where
parseJSON (Object o) =
Source <$>
(o .:? "title")
<*> (o .: "author")
<*> do pPubDate <- (o .:? "publicationDate")
return $ (read . T.unpack) <$> pPubDate
data Document = Document
{
_id :: T.Text,
_title :: Maybe T.Text,
_authors :: [Author],
_abstract :: Maybe T.Text,
_publicationDate :: Maybe Int
_document_id :: T.Text,
_document_title :: Maybe T.Text,
_document_authors :: [Author],
_document_abstract :: Maybe T.Text,
_document_publicationDate :: Maybe Int,
_document_sources :: [Source]
} deriving (Show, Generic)
L.makeLenses ''Document
......@@ -46,11 +64,12 @@ instance FromJSON Document where
<*> (o .:? "abstract")
<*> do pPubDate <- (o .:? "publicationDate")
return $ (read . T.unpack) <$> pPubDate
<*> (o .: "refBibs" <|> pure [])
data Documents = Documents
{
_total :: Int,
_hits :: [Document]
_documents_total :: Int,
_documents_hits :: [Document]
} deriving (Show, Generic)
L.makeLenses ''Documents
instance FromJSON Documents where
......
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