Commit 46cd0d95 authored by Mudada's avatar Mudada

add sources

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