forked from github/szkolny
[API/Vulcan] Add automatic semester date and ID updating.
This commit is contained in:
parent
4763033f24
commit
60a3c38951
@ -7,7 +7,7 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.models.Feature
|
||||
|
||||
const val ENDPOINT_VULCAN_API_STUDENT_LIST = 1000
|
||||
const val ENDPOINT_VULCAN_API_UPDATE_SEMESTER = 1000
|
||||
const val ENDPOINT_VULCAN_API_DICTIONARIES = 1010
|
||||
const val ENDPOINT_VULCAN_API_TIMETABLE = 1020
|
||||
const val ENDPOINT_VULCAN_API_EVENTS = 1030
|
||||
@ -54,7 +54,7 @@ val VulcanFeatures = listOf(
|
||||
), listOf(LOGIN_METHOD_VULCAN_API)),
|
||||
|
||||
Feature(LOGIN_TYPE_VULCAN, FEATURE_ALWAYS_NEEDED, listOf(
|
||||
ENDPOINT_VULCAN_API_STUDENT_LIST to LOGIN_METHOD_VULCAN_API,
|
||||
ENDPOINT_VULCAN_API_UPDATE_SEMESTER to LOGIN_METHOD_VULCAN_API,
|
||||
ENDPOINT_VULCAN_API_DICTIONARIES to LOGIN_METHOD_VULCAN_API
|
||||
), listOf(LOGIN_METHOD_VULCAN_API))
|
||||
/*Feature(LOGIN_TYPE_VULCAN, FEATURE_STUDENT_INFO, listOf(
|
||||
|
@ -36,6 +36,10 @@ class VulcanData(val data: DataVulcan, val onSuccess: () -> Unit) {
|
||||
private fun useEndpoint(endpointId: Int, onSuccess: () -> Unit) {
|
||||
Utils.d(TAG, "Using endpoint $endpointId")
|
||||
when (endpointId) {
|
||||
ENDPOINT_VULCAN_API_UPDATE_SEMESTER -> {
|
||||
data.startProgress(R.string.edziennik_progress_endpoint_student_info)
|
||||
VulcanApiUpdateSemester(data, onSuccess)
|
||||
}
|
||||
ENDPOINT_VULCAN_API_DICTIONARIES -> {
|
||||
data.startProgress(R.string.edziennik_progress_endpoint_dictionaries)
|
||||
VulcanApiDictionaries(data, onSuccess)
|
||||
|
@ -1,13 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2020-1-3.
|
||||
* Copyright (c) Kuba Szczodrzyński 2020-2-1.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.login
|
||||
package pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.api
|
||||
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_NO_STUDENTS_IN_ACCOUNT
|
||||
import pl.szczodrzynski.edziennik.data.api.VULCAN_API_ENDPOINT_STUDENT_LIST
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.ENDPOINT_VULCAN_API_UPDATE_SEMESTER
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.VulcanApi
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
@ -66,6 +67,7 @@ class VulcanApiUpdateSemester(override val data: DataVulcan, val onSuccess: () -
|
||||
dateYearEnd?.let { profile.dateYearEnd = it }
|
||||
}
|
||||
|
||||
data.setSyncNext(ENDPOINT_VULCAN_API_UPDATE_SEMESTER, if (data.studentSemesterNumber == 2) 7*DAY else 2*DAY)
|
||||
onSuccess()
|
||||
}
|
||||
} ?: onSuccess()}
|
@ -13,6 +13,7 @@ import io.github.wulkanowy.signer.android.getPrivateKeyFromCert
|
||||
import pl.szczodrzynski.edziennik.currentTimeUnix
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.api.VulcanApiUpdateSemester
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.getJsonObject
|
||||
import pl.szczodrzynski.edziennik.getString
|
||||
|
Loading…
x
Reference in New Issue
Block a user