Fix getToken implementation
This commit is contained in:
parent
dab976890f
commit
545a90e2a0
4 changed files with 17 additions and 6 deletions
|
@ -480,7 +480,7 @@ class Scrapper {
|
|||
|
||||
suspend fun getToken(): TokenResponse {
|
||||
return when (isEduOne) {
|
||||
true -> studentPlus.getToken()
|
||||
true -> studentPlus.getToken(studentId, diaryId, unitId)
|
||||
else -> student.getToken()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,8 +184,10 @@ internal class StudentPlusRepository(
|
|||
return api.getRegisteredDevices(key)
|
||||
}
|
||||
|
||||
suspend fun getToken(): TokenResponse {
|
||||
val res = api.getDeviceRegistrationToken()
|
||||
suspend fun getToken(studentId: Int, diaryId: Int, unitId: Int): TokenResponse {
|
||||
val key = getEncodedKey(studentId, diaryId, unitId)
|
||||
api.createDeviceRegistrationToken(mapOf("key" to key))
|
||||
val res = api.getDeviceRegistrationToken(key)
|
||||
return res.copy(
|
||||
qrCodeImage = Jsoup.parse(res.qrCodeImage)
|
||||
.select("img")
|
||||
|
|
|
@ -82,8 +82,15 @@ internal interface StudentPlusService {
|
|||
@Query("key") key: String,
|
||||
): List<Device>
|
||||
|
||||
@POST("api/RejestracjaUrzadzeniaToken")
|
||||
suspend fun createDeviceRegistrationToken(
|
||||
@Body body: Map<String, String>,
|
||||
)
|
||||
|
||||
@GET("api/RejestracjaUrzadzeniaToken")
|
||||
suspend fun getDeviceRegistrationToken(): TokenResponse
|
||||
suspend fun getDeviceRegistrationToken(
|
||||
@Query("key") key: String,
|
||||
): TokenResponse
|
||||
|
||||
@GET("api/Zebrania")
|
||||
suspend fun getConferences(
|
||||
|
|
|
@ -8,8 +8,10 @@ import org.junit.Test
|
|||
class SchoolPlusTest : BaseLocalTest() {
|
||||
|
||||
private val school by lazy {
|
||||
runBlocking { getStudentPlusRepo(SchoolPlusTest::class.java, "SzkolaPlus.json")
|
||||
.getSchool(1, 2, 3) }
|
||||
runBlocking {
|
||||
getStudentPlusRepo(SchoolPlusTest::class.java, "SzkolaPlus.json")
|
||||
.getSchool(1, 2, 3)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue