-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ccf801
commit 718e2d5
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/faforever/icebreaker/web/JsonApiResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.faforever.icebreaker.web | ||
|
||
import com.faforever.icebreaker.service.Session | ||
|
||
data class JsonApiResponse( | ||
val data: DataObject<*>, | ||
) { | ||
data class DataObject<T>( | ||
val type: String, | ||
val id: String, | ||
val attributes: T, | ||
) | ||
} | ||
|
||
fun Session.toJsonApiResponse() = | ||
JsonApiResponse( | ||
data = JsonApiResponse.DataObject( | ||
type = "iceSession", | ||
id = id, | ||
attributes = mapOf<String, Any>( | ||
"servers" to servers, | ||
), | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters