Add missing key query param to mobile devices, school and teachers endpoints
This commit is contained in:
parent
28fc7a7d40
commit
cd31377aed
6 changed files with 53 additions and 34 deletions
|
@ -474,7 +474,7 @@ class Scrapper {
|
|||
}
|
||||
|
||||
suspend fun getRegisteredDevices(): List<Device> = when (isEduOne) {
|
||||
true -> studentPlus.getRegisteredDevices()
|
||||
true -> studentPlus.getRegisteredDevices(studentId, diaryId, unitId)
|
||||
else -> student.getRegisteredDevices()
|
||||
}
|
||||
|
||||
|
@ -488,12 +488,12 @@ class Scrapper {
|
|||
suspend fun unregisterDevice(id: Int): Boolean = student.unregisterDevice(id)
|
||||
|
||||
suspend fun getTeachers(): List<Teacher> = when (isEduOne) {
|
||||
true -> studentPlus.getTeachers()
|
||||
true -> studentPlus.getTeachers(studentId, diaryId, unitId)
|
||||
else -> student.getTeachers()
|
||||
}
|
||||
|
||||
suspend fun getSchool(): School = when (isEduOne) {
|
||||
true -> studentPlus.getSchool()
|
||||
true -> studentPlus.getSchool(studentId, diaryId, unitId)
|
||||
else -> student.getSchool()
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,10 @@ internal class StudentPlusRepository(
|
|||
).mapCompletedLessons(startDate, endDate)
|
||||
}
|
||||
|
||||
suspend fun getRegisteredDevices(): List<Device> = api.getRegisteredDevices()
|
||||
suspend fun getRegisteredDevices(studentId: Int, diaryId: Int, unitId: Int): List<Device> {
|
||||
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||
return api.getRegisteredDevices(key)
|
||||
}
|
||||
|
||||
suspend fun getToken(): TokenResponse {
|
||||
val res = api.getDeviceRegistrationToken()
|
||||
|
@ -406,33 +409,39 @@ internal class StudentPlusRepository(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getTeachers(): List<Teacher> = api.getTeachers().teachers.map {
|
||||
Teacher(
|
||||
name = "${it.firstName} ${it.lastName}".trim(),
|
||||
subject = it.subject,
|
||||
)
|
||||
suspend fun getTeachers(studentId: Int, diaryId: Int, unitId: Int): List<Teacher> {
|
||||
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||
return api.getTeachers(key).teachers.map {
|
||||
Teacher(
|
||||
name = "${it.firstName} ${it.lastName}".trim(),
|
||||
subject = it.subject,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSchool(): School = api.getSchool().let {
|
||||
val streetNumber = it.buildingNumber + it.apartmentNumber.takeIf(String::isNotEmpty)?.let { "/$it" }.orEmpty()
|
||||
val name = buildString {
|
||||
append(it.name)
|
||||
if (it.number.isNotEmpty()) {
|
||||
append(" nr ${it.number}")
|
||||
}
|
||||
if (it.patron.isNotEmpty()) {
|
||||
append(" im. ${it.patron}")
|
||||
}
|
||||
if (it.town.isNotEmpty()) {
|
||||
append(" w ${it.town}")
|
||||
suspend fun getSchool(studentId: Int, diaryId: Int, unitId: Int): School {
|
||||
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||
return api.getSchool(key).let {
|
||||
val streetNumber = it.buildingNumber + it.apartmentNumber.takeIf(String::isNotEmpty)?.let { "/$it" }.orEmpty()
|
||||
val name = buildString {
|
||||
append(it.name)
|
||||
if (it.number.isNotEmpty()) {
|
||||
append(" nr ${it.number}")
|
||||
}
|
||||
if (it.patron.isNotEmpty()) {
|
||||
append(" im. ${it.patron}")
|
||||
}
|
||||
if (it.town.isNotEmpty()) {
|
||||
append(" w ${it.town}")
|
||||
}
|
||||
}
|
||||
School(
|
||||
name = name,
|
||||
address = "${it.street} $streetNumber, ${it.postcode} ${it.town}",
|
||||
contact = it.workPhone,
|
||||
headmaster = it.headmasters.firstOrNull().orEmpty(),
|
||||
pedagogue = "",
|
||||
)
|
||||
}
|
||||
School(
|
||||
name = name,
|
||||
address = "${it.street} $streetNumber, ${it.postcode} ${it.town}",
|
||||
contact = it.workPhone,
|
||||
headmaster = it.headmasters.firstOrNull().orEmpty(),
|
||||
pedagogue = "",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,9 @@ internal interface StudentPlusService {
|
|||
): AttendanceSummaryResponse
|
||||
|
||||
@GET("api/ZarejestrowaneUrzadzenia")
|
||||
suspend fun getRegisteredDevices(): List<Device>
|
||||
suspend fun getRegisteredDevices(
|
||||
@Query("key") key: String,
|
||||
): List<Device>
|
||||
|
||||
@GET("api/RejestracjaUrzadzeniaToken")
|
||||
suspend fun getDeviceRegistrationToken(): TokenResponse
|
||||
|
@ -140,8 +142,12 @@ internal interface StudentPlusService {
|
|||
suspend fun getNotes(@Query("key") key: String): List<Note>
|
||||
|
||||
@GET("api/Nauczyciele")
|
||||
suspend fun getTeachers(): TeacherPlusResponse
|
||||
suspend fun getTeachers(
|
||||
@Query("key") key: String,
|
||||
): TeacherPlusResponse
|
||||
|
||||
@GET("api/Informacje")
|
||||
suspend fun getSchool(): SchoolPlus
|
||||
suspend fun getSchool(
|
||||
@Query("key") key: String,
|
||||
): SchoolPlus
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class DevicesPlusTest : BaseLocalTest() {
|
|||
private val devices by lazy {
|
||||
runBlocking {
|
||||
getStudentPlusRepo(DevicesPlusTest::class.java, "UrzadzeniaPlus.json")
|
||||
.getRegisteredDevices()
|
||||
.getRegisteredDevices(1, 2, 3)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ import org.junit.Test
|
|||
class SchoolPlusTest : BaseLocalTest() {
|
||||
|
||||
private val school by lazy {
|
||||
runBlocking { getStudentPlusRepo(SchoolPlusTest::class.java, "SzkolaPlus.json").getSchool() }
|
||||
runBlocking { getStudentPlusRepo(SchoolPlusTest::class.java, "SzkolaPlus.json")
|
||||
.getSchool(1, 2, 3) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -7,7 +7,10 @@ import org.junit.Test
|
|||
|
||||
class TeachersPlusTest : BaseLocalTest() {
|
||||
private val teachers by lazy {
|
||||
runBlocking { getStudentPlusRepo(TeachersPlusTest::class.java, "NauczycielePlus.json").getTeachers() }
|
||||
runBlocking {
|
||||
getStudentPlusRepo(TeachersPlusTest::class.java, "NauczycielePlus.json")
|
||||
.getTeachers(1, 2, 3)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue