From 2ad8a308b391326258a4ff96ead78988e296b428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 28 Oct 2019 23:21:57 +0100 Subject: [PATCH] [APIv2/Idziennik] Better request parameter adding. --- .../edziennik/api/v2/idziennik/data/IdziennikWeb.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikWeb.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikWeb.kt index f1241c0c..2bae8843 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikWeb.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/IdziennikWeb.kt @@ -4,6 +4,7 @@ package pl.szczodrzynski.edziennik.api.v2.idziennik.data +import com.google.gson.JsonArray import com.google.gson.JsonObject import im.wangchao.mhttp.Request import im.wangchao.mhttp.Response @@ -83,9 +84,19 @@ open class IdziennikWeb(open val data: DataIdziennik) { .userAgent(IDZIENNIK_USER_AGENT) .postJson() .apply { + val json = JsonObject() 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_INTERNAL_ERROR)