diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/Scrapper.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/Scrapper.kt index eda816e2..6eefd2af 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/Scrapper.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/Scrapper.kt @@ -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() } } diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/StudentPlusRepository.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/StudentPlusRepository.kt index 1f5ea409..423089d9 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/StudentPlusRepository.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/StudentPlusRepository.kt @@ -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") diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/StudentPlusService.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/StudentPlusService.kt index 46fd2026..990f3e82 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/StudentPlusService.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/service/StudentPlusService.kt @@ -82,8 +82,15 @@ internal interface StudentPlusService { @Query("key") key: String, ): List + @POST("api/RejestracjaUrzadzeniaToken") + suspend fun createDeviceRegistrationToken( + @Body body: Map, + ) + @GET("api/RejestracjaUrzadzeniaToken") - suspend fun getDeviceRegistrationToken(): TokenResponse + suspend fun getDeviceRegistrationToken( + @Query("key") key: String, + ): TokenResponse @GET("api/Zebrania") suspend fun getConferences( diff --git a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/school/SchoolPlusTest.kt b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/school/SchoolPlusTest.kt index 3bcc1809..ab3e0951 100644 --- a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/school/SchoolPlusTest.kt +++ b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/school/SchoolPlusTest.kt @@ -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