Add cookie with current school year

This commit is contained in:
Mikołaj Pich 2019-03-20 14:00:07 +01:00
parent 0aea843800
commit bc60169383
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA

View file

@ -2,6 +2,7 @@ package io.github.wulkanowy.api.interceptor
import okhttp3.Interceptor
import okhttp3.Response
import org.threeten.bp.LocalDate.now
import java.net.CookieManager
import java.net.HttpCookie
import java.net.URI
@ -18,7 +19,8 @@ class StudentAndParentInterceptor(
arrayOf(
arrayOf("idBiezacyDziennik", diaryId),
arrayOf("idBiezacyUczen", studentId),
arrayOf("idBiezacyDziennikPrzedszkole", 0)
arrayOf("idBiezacyDziennikPrzedszkole", 0),
arrayOf("biezacyRokSzkolny", if (now().monthValue < 9) now().year - 1 else now().year) // TODO: replace this with a year based on config
).forEach { cookie ->
arrayOf("opiekun", "uczen").forEach { module ->
HttpCookie(cookie[0].toString(), cookie[1].toString()).let {