All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.kevcodez.pubg.model.tournament.TournamentResponse.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
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