Skip to content

Commit

Permalink
support new dashboard call. (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimOrtel authored Jan 10, 2024
1 parent fe0b51e commit 1b3d3e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ import kotlinx.serialization.Serializable
* A dashboard is a collection of courses.
*/
@Serializable
data class Dashboard(val courses: List<CourseWithScore>) {

}
data class Dashboard(val courses: List<CourseWithScore>)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import de.tum.informatics.www1.artemis.native_app.core.data.NetworkResponse
import de.tum.informatics.www1.artemis.native_app.core.data.cookieAuth
import de.tum.informatics.www1.artemis.native_app.core.data.performNetworkCall
import de.tum.informatics.www1.artemis.native_app.core.data.service.KtorProvider
import de.tum.informatics.www1.artemis.native_app.core.model.CourseWithScore
import de.tum.informatics.www1.artemis.native_app.core.model.Dashboard
import de.tum.informatics.www1.artemis.native_app.feature.dashboard.service.DashboardService
import io.ktor.client.call.body
Expand All @@ -24,14 +23,14 @@ internal class DashboardServiceImpl(
): NetworkResponse<Dashboard> {
return performNetworkCall {
//Perform a network call to $serverUrl/api/courses/for-dashboard
val courses: List<CourseWithScore> = ktorProvider.ktorClient.get(serverUrl) {
val dashboard: Dashboard = ktorProvider.ktorClient.get(serverUrl) {
url {
appendPathSegments("api", "courses", "for-dashboard")
}
cookieAuth(authToken)
}.body() //Decode JSON to List<Course>

Dashboard(courses)
dashboard
}
}
}

0 comments on commit 1b3d3e6

Please sign in to comment.