[API/Mobidziennik] Add API key and fix tasks not finishing

This commit is contained in:
Kacper Ziubryniewicz 2019-12-14 14:06:43 +01:00
parent 3defe2d343
commit 13279a915d
4 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,8 @@ import pl.szczodrzynski.edziennik.utils.Utils.d
class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface {
companion object {
private const val TAG = "Mobidziennik"
const val API_KEY = "szkolny_eu_72c7dbc8b97f1e5dd2d118cacf51c2b8543d15c0f65b7a59979adb0a1296b235d7febb826dd2a28688def6efe0811b924b04d7f3c7b7d005354e06dc56815d57"
}
val internalErrorList = mutableListOf<Int>()

View File

@ -26,7 +26,7 @@ open class MobidziennikWeb(open val data: DataMobidziennik) {
val profile
get() = data.profile
fun webGet(tag: String, endpoint: String, method: Int = GET, payload: List<Pair<String, String>>? = null, onSuccess: (text: String) -> Unit) {
fun webGet(tag: String, endpoint: String, method: Int = GET, onSuccess: (text: String) -> Unit) {
val url = "https://${data.loginServerName}.mobidziennik.pl$endpoint"
d(tag, "Request: Mobidziennik/Web - $url")

View File

@ -9,6 +9,7 @@ import im.wangchao.mhttp.Response
import im.wangchao.mhttp.callback.TextCallbackHandler
import pl.szczodrzynski.edziennik.api.v2.*
import pl.szczodrzynski.edziennik.api.v2.edziennik.mobidziennik.DataMobidziennik
import pl.szczodrzynski.edziennik.api.v2.edziennik.mobidziennik.Mobidziennik
import pl.szczodrzynski.edziennik.api.v2.models.ApiError
import pl.szczodrzynski.edziennik.getUnixDate
import pl.szczodrzynski.edziennik.isNotNullNorEmpty
@ -92,6 +93,7 @@ class MobidziennikLoginWeb(val data: DataMobidziennik, val onSuccess: () -> Unit
.addParameter("login", data.loginUsername)
.addParameter("haslo", data.loginPassword)
.addParameter("token", data.app.config.sync.tokenMobidziennik)
.addParameter("ta_api", Mobidziennik.API_KEY)
.post()
.callback(callback)
.build()

View File

@ -337,6 +337,7 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
}
try {
DataNotifications(this)
onSuccess()
} catch (e: Exception) {
error(ApiError(TAG, EXCEPTION_NOTIFY)
.withThrowable(e))