Add support for conferences via eduOne
This commit is contained in:
parent
e86fd1b332
commit
91e847ee47
6 changed files with 80 additions and 5 deletions
|
@ -432,7 +432,10 @@ class Scrapper {
|
||||||
else -> student.getNotes()
|
else -> student.getNotes()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getConferences(): List<Conference> = student.getConferences()
|
suspend fun getConferences(): List<Conference> = when (isEduOne) {
|
||||||
|
true -> studentPlus.getConferences(studentId, diaryId, unitId)
|
||||||
|
else -> student.getConferences()
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun getMenu(date: LocalDate): List<Menu> = student.getMenu(date)
|
suspend fun getMenu(date: LocalDate): List<Menu> = student.getMenu(date)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.github.wulkanowy.sdk.scrapper.conferences
|
package io.github.wulkanowy.sdk.scrapper.conferences
|
||||||
|
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.adapter.CustomDateAdapter
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
@ -16,11 +17,11 @@ data class Conference(
|
||||||
val place: String,
|
val place: String,
|
||||||
|
|
||||||
@SerialName("TematZebrania")
|
@SerialName("TematZebrania")
|
||||||
|
@JsonNames("opis")
|
||||||
val topic: String,
|
val topic: String,
|
||||||
|
|
||||||
@SerialName("Agenda")
|
@SerialName("Agenda")
|
||||||
@JsonNames("opis")
|
val agenda: String = "",
|
||||||
val agenda: String,
|
|
||||||
|
|
||||||
@SerialName("ObecniNaZebraniu")
|
@SerialName("ObecniNaZebraniu")
|
||||||
@JsonNames("obecniNaZebraniu")
|
@JsonNames("obecniNaZebraniu")
|
||||||
|
@ -34,6 +35,7 @@ data class Conference(
|
||||||
@JsonNames("id")
|
@JsonNames("id")
|
||||||
val id: Int,
|
val id: Int,
|
||||||
|
|
||||||
@Transient
|
@JsonNames("dataCzas")
|
||||||
|
@Serializable(with = CustomDateAdapter::class)
|
||||||
val date: LocalDateTime = LocalDateTime.now(),
|
val date: LocalDateTime = LocalDateTime.now(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceExcusePlusResponseI
|
||||||
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceExcusesPlusResponse
|
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceExcusesPlusResponse
|
||||||
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceSummary
|
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceSummary
|
||||||
import io.github.wulkanowy.sdk.scrapper.attendance.SentExcuseStatus
|
import io.github.wulkanowy.sdk.scrapper.attendance.SentExcuseStatus
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.conferences.Conference
|
||||||
import io.github.wulkanowy.sdk.scrapper.exams.Exam
|
import io.github.wulkanowy.sdk.scrapper.exams.Exam
|
||||||
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
||||||
import io.github.wulkanowy.sdk.scrapper.exception.VulcanClientError
|
import io.github.wulkanowy.sdk.scrapper.exception.VulcanClientError
|
||||||
|
@ -349,4 +350,9 @@ internal class StudentPlusRepository(
|
||||||
}
|
}
|
||||||
.sortedWith(compareBy({ it.date }, { it.category }))
|
.sortedWith(compareBy({ it.date }, { it.category }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getConferences(studentId: Int, diaryId: Int, unitId: Int): List<Conference> {
|
||||||
|
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||||
|
return api.getConferences(key)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,9 @@ internal interface StudentPlusService {
|
||||||
suspend fun getDeviceRegistrationToken(): TokenResponse
|
suspend fun getDeviceRegistrationToken(): TokenResponse
|
||||||
|
|
||||||
@GET("api/Zebrania")
|
@GET("api/Zebrania")
|
||||||
suspend fun getConferences(): List<Conference>
|
suspend fun getConferences(
|
||||||
|
@Query("key") key: String,
|
||||||
|
): List<Conference>
|
||||||
|
|
||||||
@GET("api/RealizacjaZajec")
|
@GET("api/RealizacjaZajec")
|
||||||
suspend fun getCompletedLessons(
|
suspend fun getCompletedLessons(
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package io.github.wulkanowy.sdk.scrapper.conferences
|
||||||
|
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.BaseLocalTest
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class ConferencesPlusTest : BaseLocalTest() {
|
||||||
|
|
||||||
|
private val conferences by lazy {
|
||||||
|
runBlocking {
|
||||||
|
getStudentPlusRepo(ConferencesPlusTest::class.java, "ZebraniaPlus.json").getConferences(1, 2, 3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getAllConferencesTest() {
|
||||||
|
assertEquals(2, conferences.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getSimpleConference() {
|
||||||
|
with(conferences[0]) {
|
||||||
|
assertEquals("Miejsce", place)
|
||||||
|
assertEquals("Temat", topic)
|
||||||
|
assertEquals("", agenda)
|
||||||
|
assertEquals("", presentOnConference)
|
||||||
|
assertEquals(2, id)
|
||||||
|
assertEquals(getLocalDateTime(2024, 3, 20, 23, 5, 0), date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getFullConference() {
|
||||||
|
with(conferences[1]) {
|
||||||
|
assertEquals("", place)
|
||||||
|
assertEquals("Temat", topic)
|
||||||
|
assertEquals("", agenda)
|
||||||
|
assertEquals("Jan Kowalski", presentOnConference)
|
||||||
|
assertEquals(1, id)
|
||||||
|
assertEquals(getLocalDateTime(2024, 3, 19, 23, 5, 0), date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"dataCzas": "2024-03-20T23:05:00+01:00",
|
||||||
|
"sala": "Miejsce",
|
||||||
|
"opis": "Temat",
|
||||||
|
"zebranieOnline": null,
|
||||||
|
"obecniNaZebraniu": "",
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dataCzas": "2024-03-19T23:05:00+01:00",
|
||||||
|
"sala": "",
|
||||||
|
"opis": "Temat",
|
||||||
|
"zebranieOnline": "",
|
||||||
|
"obecniNaZebraniu": "Jan Kowalski",
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in a new issue