forked from github/szkolny
[API/Podlasie] Add getting the lucky number.
This commit is contained in:
parent
4389dc9d79
commit
0ac8e1d9c1
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kacper Ziubryniewicz 2020-5-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.api
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.LuckyNumber
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
|
class PodlasieApiLuckyNumber(val data: DataPodlasie, val luckyNumber: Int) {
|
||||||
|
init {
|
||||||
|
val luckyNumberObject = LuckyNumber(
|
||||||
|
profileId = data.profileId,
|
||||||
|
date = Date.getToday(),
|
||||||
|
number = luckyNumber
|
||||||
|
)
|
||||||
|
|
||||||
|
data.luckyNumberList.add(luckyNumberObject)
|
||||||
|
data.metadataList.add(
|
||||||
|
Metadata(
|
||||||
|
data.profileId,
|
||||||
|
Metadata.TYPE_LUCKY_NUMBER,
|
||||||
|
luckyNumberObject.date.value.toLong(),
|
||||||
|
true,
|
||||||
|
data.profile?.empty ?: false
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.DataPodlasie
|
|||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.ENDPOINT_PODLASIE_API_MAIN
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.ENDPOINT_PODLASIE_API_MAIN
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.PodlasieApi
|
import pl.szczodrzynski.edziennik.data.api.edziennik.podlasie.data.PodlasieApi
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
|
||||||
|
import pl.szczodrzynski.edziennik.getInt
|
||||||
import pl.szczodrzynski.edziennik.getJsonArray
|
import pl.szczodrzynski.edziennik.getJsonArray
|
||||||
|
|
||||||
class PodlasieApiMain(override val data: DataPodlasie,
|
class PodlasieApiMain(override val data: DataPodlasie,
|
||||||
@ -23,6 +24,7 @@ class PodlasieApiMain(override val data: DataPodlasie,
|
|||||||
apiGet(TAG, PODLASIE_API_USER_ENDPOINT) { json ->
|
apiGet(TAG, PODLASIE_API_USER_ENDPOINT) { json ->
|
||||||
data.getTeam() // Save the class team when it doesn't exist.
|
data.getTeam() // Save the class team when it doesn't exist.
|
||||||
|
|
||||||
|
json.getInt("LuckyNumber")?.let { PodlasieApiLuckyNumber(data, it) }
|
||||||
json.getJsonArray("Timetable")?.asJsonObjectList()?.let { PodlasieApiTimetable(data, it) }
|
json.getJsonArray("Timetable")?.asJsonObjectList()?.let { PodlasieApiTimetable(data, it) }
|
||||||
json.getJsonArray("Marks")?.asJsonObjectList()?.let { PodlasieApiGrades(data, it) }
|
json.getJsonArray("Marks")?.asJsonObjectList()?.let { PodlasieApiGrades(data, it) }
|
||||||
json.getJsonArray("MarkFinal")?.asJsonObjectList()?.let { PodlasieApiFinalGrades(data, it) }
|
json.getJsonArray("MarkFinal")?.asJsonObjectList()?.let { PodlasieApiFinalGrades(data, it) }
|
||||||
|
Loading…
Reference in New Issue
Block a user