mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 19:04:38 -06:00
[APIv2/Idziennik] Better request parameter adding.
This commit is contained in:
parent
81c6275255
commit
2ad8a308b3
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package pl.szczodrzynski.edziennik.api.v2.idziennik.data
|
package pl.szczodrzynski.edziennik.api.v2.idziennik.data
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import im.wangchao.mhttp.Request
|
import im.wangchao.mhttp.Request
|
||||||
import im.wangchao.mhttp.Response
|
import im.wangchao.mhttp.Response
|
||||||
@ -83,9 +84,19 @@ open class IdziennikWeb(open val data: DataIdziennik) {
|
|||||||
.userAgent(IDZIENNIK_USER_AGENT)
|
.userAgent(IDZIENNIK_USER_AGENT)
|
||||||
.postJson()
|
.postJson()
|
||||||
.apply {
|
.apply {
|
||||||
|
val json = JsonObject()
|
||||||
parameters.map { (name, value) ->
|
parameters.map { (name, value) ->
|
||||||
addParameter(name, value)
|
when (value) {
|
||||||
|
is JsonObject -> json.add(name, value)
|
||||||
|
is JsonArray -> json.add(name, value)
|
||||||
|
is String -> json.addProperty(name, value)
|
||||||
|
is Int -> json.addProperty(name, value)
|
||||||
|
is Long -> json.addProperty(name, value)
|
||||||
|
is Float -> json.addProperty(name, value)
|
||||||
|
is Char -> json.addProperty(name, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
setJsonBody(json)
|
||||||
}
|
}
|
||||||
.allowErrorCode(HTTP_UNAUTHORIZED)
|
.allowErrorCode(HTTP_UNAUTHORIZED)
|
||||||
.allowErrorCode(HTTP_INTERNAL_ERROR)
|
.allowErrorCode(HTTP_INTERNAL_ERROR)
|
||||||
|
Loading…
Reference in New Issue
Block a user