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:
parent
617bccaa81
commit
41c5ba7309
@ -8,7 +8,8 @@
|
||||
incoming messages
|
||||
* `TelegramBotAPIMessageDeserializeOnlySerializer` was created. It **MUST NOT** be used to serialize messages
|
||||
* 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
|
||||
|
||||
|
@ -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.types.ChatIdentifier
|
||||
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 kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
@ -12,7 +14,9 @@ import kotlinx.serialization.internal.ArrayListSerializer
|
||||
data class GetChatAdministrators(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<List<RawChatMember>> {
|
||||
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
||||
override fun method(): String = "getChatAdministrators"
|
||||
override fun resultDeserializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer())
|
||||
override fun resultDeserializer(): KSerializer<List<ChatMember>> = ArrayListSerializer(
|
||||
ChatMemberSerializerWithoutDeserialization
|
||||
)
|
||||
}
|
||||
|
@ -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.types.*
|
||||
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.*
|
||||
|
||||
@Serializable
|
||||
@ -11,7 +13,7 @@ data class GetChatMember(
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatMemberRequest<RawChatMember> {
|
||||
) : ChatMemberRequest<ChatMember> {
|
||||
override fun method(): String = "getChatMember"
|
||||
override fun resultDeserializer(): KSerializer<RawChatMember> = RawChatMember.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<ChatMember> = ChatMemberDeserializationStrategy
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.Cha
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class RawChatMember(
|
||||
internal data class RawChatMember(
|
||||
val user: User,
|
||||
private val status: String,
|
||||
private val until_date: TelegramDate? = null,
|
||||
|
@ -1,7 +1,24 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
interface ChatMember {
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user