2020-10-04 11:06:30 +00:00
|
|
|
package dev.inmo.tgbotapi.requests.chat.get
|
|
|
|
|
2022-05-01 16:13:40 +00:00
|
|
|
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
2020-10-04 11:06:30 +00:00
|
|
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
2024-04-16 13:25:18 +00:00
|
|
|
import dev.inmo.tgbotapi.types.BusinessChatId
|
2022-11-10 09:56:38 +00:00
|
|
|
import dev.inmo.tgbotapi.types.ChatIdWithThreadId
|
2020-10-04 11:06:30 +00:00
|
|
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
|
|
import dev.inmo.tgbotapi.types.chat.ExtendedChatSerializer
|
2022-04-21 18:16:41 +00:00
|
|
|
import dev.inmo.tgbotapi.types.chat.ExtendedChat
|
2020-10-04 11:06:30 +00:00
|
|
|
import dev.inmo.tgbotapi.types.chatIdField
|
|
|
|
import kotlinx.serialization.*
|
|
|
|
|
|
|
|
@Serializable
|
|
|
|
data class GetChat(
|
|
|
|
@SerialName(chatIdField)
|
|
|
|
override val chatId: ChatIdentifier
|
|
|
|
): ChatRequest, SimpleRequest<ExtendedChat> {
|
|
|
|
override fun method(): String = "getChat"
|
2022-11-10 09:56:38 +00:00
|
|
|
@Transient
|
2024-04-16 13:25:18 +00:00
|
|
|
override val resultDeserializer: DeserializationStrategy<ExtendedChat> = when {
|
|
|
|
chatId is ChatIdWithThreadId -> ExtendedChatSerializer.BasedOnForumThread(chatId.threadId)
|
2024-04-18 14:07:33 +00:00
|
|
|
chatId is BusinessChatId -> ExtendedChatSerializer.BasedOnBusinessConnection(chatId.businessConnectionId)
|
2024-04-16 13:25:18 +00:00
|
|
|
else -> ExtendedChatSerializer.Companion
|
2022-11-10 09:56:38 +00:00
|
|
|
}
|
2020-10-04 11:06:30 +00:00
|
|
|
override val requestSerializer: SerializationStrategy<*>
|
|
|
|
get() = serializer()
|
|
|
|
}
|