diff --git a/app/build.gradle b/app/build.gradle index df417d05..137ea8a0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -159,7 +159,7 @@ dependencies { //implementation 'com.github.wulkanowy:uonet-request-signer:master-SNAPSHOT' //implementation 'com.github.kuba2k2.uonet-request-signer:android:master-63f094b14a-1' - implementation "org.redundent:kotlin-xml-builder:1.5.3" + //implementation "org.redundent:kotlin-xml-builder:1.5.3" implementation "io.github.wulkanowy:signer-android:0.1.1" diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusMessages.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusMessages.kt index f7e59550..a94124b1 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusMessages.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusMessages.kt @@ -12,13 +12,17 @@ import okhttp3.Cookie import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.parser.Parser -import org.redundent.kotlin.xml.PrintOptions -import org.redundent.kotlin.xml.xml import pl.szczodrzynski.edziennik.api.v2.* import pl.szczodrzynski.edziennik.api.v2.librus.DataLibrus import pl.szczodrzynski.edziennik.api.v2.models.ApiError import pl.szczodrzynski.edziennik.get import pl.szczodrzynski.edziennik.utils.Utils.d +import java.io.StringWriter +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.transform.OutputKeys +import javax.xml.transform.TransformerFactory +import javax.xml.transform.dom.DOMSource +import javax.xml.transform.stream.StreamResult open class LibrusMessages(open val data: DataLibrus) { companion object { @@ -80,7 +84,27 @@ open class LibrusMessages(open val data: DataLibrus) { .secure().httpOnly().build() )) - val requestXml = xml("service") { + + val docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder() + val doc = docBuilder.newDocument() + val serviceElement = doc.createElement("service") + val headerElement = doc.createElement("header") + val dataElement = doc.createElement("data") + for ((key, value) in parameters.orEmpty()) { + val element = doc.createElement(key) + element.appendChild(doc.createTextNode(value.toString())) + dataElement.appendChild(element) + } + serviceElement.appendChild(headerElement) + serviceElement.appendChild(dataElement) + doc.appendChild(serviceElement) + val transformer = TransformerFactory.newInstance().newTransformer() + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes") + val stringWriter = StringWriter() + transformer.transform(DOMSource(doc), StreamResult(stringWriter)) + val requestXml = stringWriter.toString() + + /*val requestXml = xml("service") { "header" { } "data" { for ((key, value) in parameters.orEmpty()) { @@ -92,7 +116,7 @@ open class LibrusMessages(open val data: DataLibrus) { }.toString(PrintOptions( singleLineTextElements = true, useSelfClosingTags = true - )) + ))*/ Request.builder() .url("$LIBRUS_MESSAGES_URL/$endpoint") diff --git a/build.gradle b/build.gradle index 4952a1a8..ecb4159c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { kotlin_version = '1.3.50' release = [ - versionName: "3.9.0-dev", - versionCode: 3090000 + versionName: "3.9.1-dev", + versionCode: 3090100 ] setup = [