ru.sadv1r.vk.parser.model.Execute.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vk-parser Show documentation
Show all versions of vk-parser Show documentation
vk.com API implementation
The newest version!
package ru.sadv1r.vk.parser.model
/**
* @author [sadv1r](http://sadv1r.ru)
*/
data class Execute(
private val requests: MutableList = mutableListOf()
) {
fun append(method: String, args: Map): Execute {
requests.add(args
.filterValues { it != null }
.asSequence()
.joinToString(",", "API.$method({", "})") { param ->
"${param.key}:${param.value}"
})
return this
}
fun append(request: String): Execute {
requests.add(request)
return this
}
fun compose(): String = requests.joinToString("%2b", "return ", ";")
fun compose(resultVariable: String): String = requests.joinToString(";", postfix = "return $resultVariable;")
}