Add basic dynamic routes

This commit is contained in:
2022-08-24 04:42:06 +02:00
parent dde97a0658
commit 96bafd4dca
2 changed files with 21 additions and 3 deletions
+13
View File
@@ -74,9 +74,17 @@ instance FromJSON Faculty where
<$> v .: "id"
<*> v .: "displayName"
data Lectures = Lectures { unLectures :: [Lecture] }
deriving (Show)
instance FromJSON Lectures where
parseJSON = withObject "Lectures" $ \v -> Lectures
<$> v .: "lectures"
data Lecture = Lecture
{ lectureId :: Text
, lectureDisplayName :: Text
, lectureAliases :: [Text]
}
deriving (Show)
@@ -84,9 +92,14 @@ instance FromJSON Lecture where
parseJSON = withObject "Lecture" $ \v -> Lecture
<$> v .: "id"
<*> v .: "displayName"
<*> v .: "aliases"
serverUrl = https "api.squeak-test.fsmi.uni-karlsruhe.de"
getLectures :: Req (GQLReply Lectures)
getLectures = responseBody <$> req POST serverUrl (ReqBodyJson $ GQLQuery q) jsonResponse mempty
where q = "{ lectures { id displayName aliases } }"
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 } } } }"