1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

RequestPollKeyboardButton#requestPoll is required parameter for now

This commit is contained in:
InsanusMokrassar 2020-01-23 22:09:06 +06:00
parent 9dc3e1ecc6
commit 1a258ae912
2 changed files with 7 additions and 3 deletions

View File

@ -41,7 +41,7 @@ data class RequestLocationKeyboardButton(
data class RequestPollKeyboardButton(
override val text: String,
@SerialName(requestPollField)
val requestPoll: KeyboardButtonPollType = RegularKeyboardButtonPollType
val requestPoll: KeyboardButtonPollType
) : KeyboardButton()
@Serializer(KeyboardButton::class)

View File

@ -43,9 +43,13 @@ internal object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPol
* Crutch due to the fact that direct serialization of objects currently does not work perfectly
*/
override fun serialize(encoder: Encoder, obj: KeyboardButtonPollType) {
UnknownKeyboardButtonPollType.serializer().serialize(
JsonObjectSerializer.serialize(
encoder,
(obj as? UnknownKeyboardButtonPollType) ?: UnknownKeyboardButtonPollType(obj.type)
JsonObject(
mapOf(
typeField to JsonPrimitive(obj.type)
)
)
)
}
}