1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

added votes count field to poll

This commit is contained in:
InsanusMokrassar 2020-01-23 16:40:57 +06:00
parent 423efafa04
commit 258ab44bac
2 changed files with 9 additions and 0 deletions

View File

@ -90,6 +90,7 @@ const val lastErrorDateField = "last_error_date"
const val lastErrorMessageField = "last_error_message"
const val votesCountField = "voter_count"
const val isClosedField = "is_closed"
const val totalVoterCountField = "total_voter_count"
const val correctOptionIdField = "correct_option_id"
const val allowsMultipleAnswersField = "allows_multiple_answers"
const val isAnonymousField = "is_anonymous"

View File

@ -10,6 +10,7 @@ sealed class Poll {
abstract val id: PollIdentifier
abstract val question: String
abstract val options: List<PollOption>
abstract val votesCount: Int
abstract val closed: Boolean
abstract val isAnonymous: Boolean
}
@ -22,6 +23,8 @@ data class UnknownPollType(
override val question: String,
@SerialName(optionsField)
override val options: List<PollOption>,
@SerialName(totalVoterCountField)
override val votesCount: Int,
@SerialName(isClosedField)
override val closed: Boolean = false,
@SerialName(isAnonymousField)
@ -37,6 +40,8 @@ data class RegularPoll(
override val question: String,
@SerialName(optionsField)
override val options: List<PollOption>,
@SerialName(totalVoterCountField)
override val votesCount: Int,
@SerialName(isClosedField)
override val closed: Boolean = false,
@SerialName(isAnonymousField)
@ -53,6 +58,8 @@ data class QuizPoll(
override val question: String,
@SerialName(optionsField)
override val options: List<PollOption>,
@SerialName(totalVoterCountField)
override val votesCount: Int,
@SerialName(isClosedField)
override val closed: Boolean = false,
@SerialName(isAnonymousField)
@ -83,6 +90,7 @@ internal object PollSerializer : KSerializer<Poll> {
pollOptionsSerializer,
asJson.getArray(optionsField)
),
asJson.getPrimitive(totalVoterCountField).int,
asJson.getPrimitiveOrNull(isClosedField) ?.booleanOrNull ?: false,
asJson.getPrimitiveOrNull(isAnonymousField) ?.booleanOrNull ?: true,
asJson.toString()