Add downloadable field to document

This commit is contained in:
Paul Brinkmeier 2022-08-23 12:54:29 +02:00
parent 3afe4b5ff9
commit dde97a0658

View File

@ -35,7 +35,7 @@ instance FromJSON GQLError where
parseJSON = withObject "GQLError" $ \v -> GQLError
<$> v .: "message"
data Documents = Documents { getDocuments :: [Document] }
data Documents = Documents { unDocuments :: [Document] }
deriving (Show)
instance FromJSON Documents where
@ -49,6 +49,7 @@ data Document = Document
, documentPublicComment :: Maybe Text
, documentFaculty :: Faculty
, documentLectures :: [Lecture]
, documentDownloadable :: Bool
}
deriving (Show)
@ -60,6 +61,7 @@ instance FromJSON Document where
<*> v .: "publicComment"
<*> v .: "faculty"
<*> v .: "lectures"
<*> v .: "downloadable"
data Faculty = Faculty
{ facultyId :: Text
@ -85,6 +87,6 @@ instance FromJSON Lecture where
serverUrl = https "api.squeak-test.fsmi.uni-karlsruhe.de"
getLectures :: Req (GQLReply Documents)
getLectures = responseBody <$> req POST serverUrl (ReqBodyJson $ GQLQuery q) jsonResponse mempty
where q = "{ documents(filters: []) { results { id date semester publicComment faculty { id displayName } lectures { id displayName } } } }"
getDocuments :: Req (GQLReply Documents)
getDocuments = responseBody <$> req POST serverUrl (ReqBodyJson $ GQLQuery q) jsonResponse mempty
where q = "{ documents(filters: []) { results { id date semester publicComment downloadable faculty { id displayName } lectures { id displayName } } } }"