mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 05:48:19 +01:00
[APIv2] Revert changes in Data.
This commit is contained in:
parent
33c009befe
commit
99ab9d586f
@ -60,16 +60,6 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
|||||||
val profileId
|
val profileId
|
||||||
get() = profile?.id ?: -1
|
get() = profile?.id ?: -1
|
||||||
|
|
||||||
val syncStartDate: Date
|
|
||||||
get() = when (profile?.empty) {
|
|
||||||
true -> profile.getSemesterStart(profile.currentSemester)
|
|
||||||
else -> Date.getToday().stepForward(0, -1, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
val syncEndDate: Date
|
|
||||||
get() = profile?.getSemesterEnd(profile.currentSemester)
|
|
||||||
?: Date.getToday().stepForward(0, 1, 0)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A callback passed to all [Feature]s and [LoginMethod]s
|
* A callback passed to all [Feature]s and [LoginMethod]s
|
||||||
*/
|
*/
|
||||||
|
@ -22,9 +22,12 @@ class VulcanApiAttendance(override val data: DataVulcan, val onSuccess: () -> Un
|
|||||||
data.db.attendanceTypeDao().getAllNow(profileId).toSparseArray(data.attendanceTypes) { it.id }
|
data.db.attendanceTypeDao().getAllNow(profileId).toSparseArray(data.attendanceTypes) { it.id }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val startDate: String = profile.getSemesterStart(profile.currentSemester).stringY_m_d
|
||||||
|
val endDate: String = profile.getSemesterEnd(profile.currentSemester).stringY_m_d
|
||||||
|
|
||||||
apiGet(TAG, VULCAN_API_ENDPOINT_ATTENDANCE, parameters = mapOf(
|
apiGet(TAG, VULCAN_API_ENDPOINT_ATTENDANCE, parameters = mapOf(
|
||||||
"DataPoczatkowa" to data.syncStartDate.stringY_m_d,
|
"DataPoczatkowa" to startDate,
|
||||||
"DataKoncowa" to data.syncEndDate.stringY_m_d,
|
"DataKoncowa" to endDate,
|
||||||
"IdOddzial" to data.studentClassId,
|
"IdOddzial" to data.studentClassId,
|
||||||
"IdUczen" to data.studentId,
|
"IdUczen" to data.studentId,
|
||||||
"IdOkresKlasyfikacyjny" to data.studentSemesterId
|
"IdOkresKlasyfikacyjny" to data.studentSemesterId
|
||||||
|
@ -26,13 +26,19 @@ class VulcanApiEvents(override val data: DataVulcan, private val isHomework: Boo
|
|||||||
|
|
||||||
init { data.profile?.also { profile ->
|
init { data.profile?.also { profile ->
|
||||||
|
|
||||||
|
val startDate: String = when (profile.empty) {
|
||||||
|
true -> profile.getSemesterStart(profile.currentSemester).stringY_m_d
|
||||||
|
else -> Date.getToday().stepForward(0, -1, 0).stringY_m_d
|
||||||
|
}
|
||||||
|
val endDate: String = profile.getSemesterEnd(profile.currentSemester).stringY_m_d
|
||||||
|
|
||||||
val endpoint = when (isHomework) {
|
val endpoint = when (isHomework) {
|
||||||
true -> VULCAN_API_ENDPOINT_HOMEWORK
|
true -> VULCAN_API_ENDPOINT_HOMEWORK
|
||||||
else -> VULCAN_API_ENDPOINT_EVENTS
|
else -> VULCAN_API_ENDPOINT_EVENTS
|
||||||
}
|
}
|
||||||
apiGet(TAG, endpoint, parameters = mapOf(
|
apiGet(TAG, endpoint, parameters = mapOf(
|
||||||
"DataPoczatkowa" to data.syncStartDate.stringY_m_d,
|
"DataPoczatkowa" to startDate,
|
||||||
"DataKoncowa" to data.syncEndDate.stringY_m_d,
|
"DataKoncowa" to endDate,
|
||||||
"IdOddzial" to data.studentClassId,
|
"IdOddzial" to data.studentClassId,
|
||||||
"IdUczen" to data.studentId,
|
"IdUczen" to data.studentId,
|
||||||
"IdOkresKlasyfikacyjny" to data.studentSemesterId
|
"IdOkresKlasyfikacyjny" to data.studentSemesterId
|
||||||
|
@ -13,16 +13,24 @@ import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS
|
|||||||
import pl.szczodrzynski.edziennik.data.db.modules.messages.Message
|
import pl.szczodrzynski.edziennik.data.db.modules.messages.Message
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.messages.MessageRecipient
|
import pl.szczodrzynski.edziennik.data.db.modules.messages.MessageRecipient
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
|
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
class VulcanApiMessagesInbox(override val data: DataVulcan, val onSuccess: () -> Unit) : VulcanApi(data) {
|
class VulcanApiMessagesInbox(override val data: DataVulcan, val onSuccess: () -> Unit) : VulcanApi(data) {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "VulcanApiMessagesInbox"
|
const val TAG = "VulcanApiMessagesInbox"
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init { data.profile?.also { profile ->
|
||||||
|
|
||||||
|
val startDate: String = when (profile.empty) {
|
||||||
|
true -> profile.getSemesterStart(profile.currentSemester).stringY_m_d
|
||||||
|
else -> Date.getToday().stepForward(0, -1, 0).stringY_m_d
|
||||||
|
}
|
||||||
|
val endDate: String = profile.getSemesterEnd(profile.currentSemester).stringY_m_d
|
||||||
|
|
||||||
apiGet(TAG, VULCAN_API_ENDPOINT_MESSAGES_RECEIVED, parameters = mapOf(
|
apiGet(TAG, VULCAN_API_ENDPOINT_MESSAGES_RECEIVED, parameters = mapOf(
|
||||||
"DataPoczatkowa" to data.syncStartDate.inUnix,
|
"DataPoczatkowa" to startDate,
|
||||||
"DataKoncowa" to data.syncEndDate.inUnix,
|
"DataKoncowa" to endDate,
|
||||||
"LoginId" to data.studentLoginId,
|
"LoginId" to data.studentLoginId,
|
||||||
"IdUczen" to data.studentId
|
"IdUczen" to data.studentId
|
||||||
)) { json, _ ->
|
)) { json, _ ->
|
||||||
@ -71,5 +79,5 @@ class VulcanApiMessagesInbox(override val data: DataVulcan, val onSuccess: () ->
|
|||||||
data.setSyncNext(ENDPOINT_VULCAN_API_MESSAGES_INBOX, SYNC_ALWAYS)
|
data.setSyncNext(ENDPOINT_VULCAN_API_MESSAGES_INBOX, SYNC_ALWAYS)
|
||||||
onSuccess()
|
onSuccess()
|
||||||
}
|
}
|
||||||
}
|
} ?: onSuccess()}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user