diff --git a/build.gradle.kts b/build.gradle.kts index 84c66e7..eba1be9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,6 +15,7 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1") implementation("de.thelooter:toml4j:0.8.1") implementation("io.github.cdimascio:dotenv-kotlin:6.5.1") + implementation(files("../Utils-latest.jar")) } tasks.test { diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 3081211..71fae6e 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -75,7 +75,6 @@ fun main() { } str.append("| Geslacht | ${genderString.padEnd(18, ' ')} |\n") - str.append("| Roken | ${(if (it.floor.floorInfo.smokingAllowed ?: true) "✅ Mag" else "❌ Mag niet").padEnd(17, ' ')} |\n") str.append("| Huisdieren | ${(if (it.floor.floorInfo.petsAllowed) "✅ Mogen" else "❌ Mogen niet").padEnd(17, ' ')} |\n") val positionString = "${it.floor.potentialPosition} / ${it.floor.applicantCount}." @@ -88,6 +87,10 @@ fun main() { str.append("| Tijd over | $daysLeft dagen over. |\n") str.append("\n") + + val etage = getEtage(it.offer.assSubjectPersk.first { it.pkHeeftAsp == 52.0 }.waarde!!) + + str.append("![Foto](${etage.photos[0].etagePhoto[0].url})\n\n") str.append("### Message: \n\n${it.floor.floorInfo.description ?: "Deze pannekoeken hebben geen bericht achtergelaten"}\n") str.append("\n\n") diff --git a/src/main/kotlin/getEtage.kt b/src/main/kotlin/getEtage.kt new file mode 100644 index 0000000..613a642 --- /dev/null +++ b/src/main/kotlin/getEtage.kt @@ -0,0 +1,40 @@ +package me.koendev + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import me.koendev.utils.println + +@Serializable +data class Etages( + @SerialName("value") val offers: List, + @SerialName("@odata.count") val count: Int, + @SerialName("isComplete") val isComplete: Boolean +) + +@Serializable +data class Etage( + @SerialName("EtageWocasId") val etageWocasID: String, + @SerialName("Id") val etageID: Int, + @SerialName("Etage_EtagePhoto") val photos: List +) + +@Serializable +data class EtagePhoto( + @SerialName("Id") val id: Int, + @SerialName("EtageId") val etageID: Int, + @SerialName("EtagePhotoId") val etagePhotoID: Int, + @SerialName("EtagePhoto") val etagePhoto: List, +) + +@Serializable +data class EtagePhotoItem( + @SerialName("Id") val id: Int, + @SerialName("Photo") val url: String +) + +fun getEtage(id: String): Etage { + val response = getEndpoint("OData/Etage?\$filter=(EtageWocasId%20eq%20'$id')&\$expand=Etage_EtagePhoto!(\$select=Id,EtagePhotoId,EtageId;\$expand=EtagePhoto!(\$select=Id,Photo))&\$select=Id,EtageWocasId") + + return Json.decodeFromString(response).offers.first() +}