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