
de.kevcodez.pubg.model.tournament.TournamentResponse.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pubg-api-wrapper Show documentation
Show all versions of pubg-api-wrapper Show documentation
Teaching how to use gradle.
package de.kevcodez.pubg.model.tournament
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import java.time.Instant
@JsonIgnoreProperties(ignoreUnknown = true)
data class TournamentResponse(
@JsonProperty("data")
val tournament: Tournament
) {
lateinit var matches: List
@JsonProperty("included")
private fun unpackMatches(included: JsonNode) {
val includedArray = included as ArrayNode
val parsedMatches = mutableListOf()
includedArray.forEach {
parsedMatches.add(
TournamentMatch(
matchId = it.get("id").textValue(),
createdAt = Instant.parse(it.get("attributes").get("createdAt").textValue())
)
)
}
matches = parsedMatches
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
data class TournamentMatch(
val matchId: String,
val createdAt: Instant
)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy