1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

RawChatMember is internal

This commit is contained in:
InsanusMokrassar 2019-08-17 22:26:02 +06:00
parent 617bccaa81
commit 41c5ba7309
5 changed files with 31 additions and 7 deletions

View File

@ -8,7 +8,8 @@
incoming messages incoming messages
* `TelegramBotAPIMessageDeserializeOnlySerializer` was created. It **MUST NOT** be used to serialize messages * `TelegramBotAPIMessageDeserializeOnlySerializer` was created. It **MUST NOT** be used to serialize messages
* Update of description * Update of description
* `RawUpdate` not is internal and not available outside of library * `RawUpdate` now is internal and not available outside of library
* `RawChatMember` now is internal and not available outside of library
## 0.17.0 ## 0.17.0

View File

@ -4,6 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequ
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberSerializerWithoutDeserialization
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
@ -12,7 +14,9 @@ import kotlinx.serialization.internal.ArrayListSerializer
data class GetChatAdministrators( data class GetChatAdministrators(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<List<RawChatMember>> { ): ChatRequest, SimpleRequest<List<ChatMember>> {
override fun method(): String = "getChatAdministrators" override fun method(): String = "getChatAdministrators"
override fun resultDeserializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer()) override fun resultDeserializer(): KSerializer<List<ChatMember>> = ArrayListSerializer(
ChatMemberSerializerWithoutDeserialization
)
} }

View File

@ -3,6 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable @Serializable
@ -11,7 +13,7 @@ data class GetChatMember(
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(userIdField) @SerialName(userIdField)
override val userId: UserId override val userId: UserId
) : ChatMemberRequest<RawChatMember> { ) : ChatMemberRequest<ChatMember> {
override fun method(): String = "getChatMember" override fun method(): String = "getChatMember"
override fun resultDeserializer(): KSerializer<RawChatMember> = RawChatMember.serializer() override fun resultDeserializer(): DeserializationStrategy<ChatMember> = ChatMemberDeserializationStrategy
} }

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.Cha
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable @Serializable
data class RawChatMember( internal data class RawChatMember(
val user: User, val user: User,
private val status: String, private val status: String,
private val until_date: TelegramDate? = null, private val until_date: TelegramDate? = null,

View File

@ -1,7 +1,24 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User
import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
interface ChatMember { interface ChatMember {
val user: User val user: User
} }
internal object ChatMemberSerializerWithoutDeserialization : KSerializer<ChatMember> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
override fun deserialize(decoder: Decoder): ChatMember = ChatMemberDeserializationStrategy.deserialize(decoder)
override fun serialize(encoder: Encoder, obj: ChatMember) = throw UnsupportedOperationException()
}
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberDeserializationStrategy")
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException(descriptor.name)
}