1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-03-03 09:22:22 +00:00

add OwnedGifts sealed interface

This commit is contained in:
2026-02-24 12:37:07 +06:00
parent c9be5041b8
commit 26c11d9d6b
10 changed files with 648 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.business_connection.GetBusinessAccountGifts
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.OwnedGifts
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
import dev.inmo.tgbotapi.types.gifts.OwnedGift
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlin.runCatching
@@ -21,7 +22,7 @@ public suspend fun TelegramBot.getBusinessAccountGifts(
sortByPrice: Boolean = false,
offset: String? = null,
limit: Int? = null
): OwnedGifts<GiftSentOrReceivedEvent.ReceivedInBusinessAccount> = execute(
): OwnedGifts<OwnedGift.OwnedByBusinessAccount> = execute(
GetBusinessAccountGifts(
businessConnectionId,
excludeUnsaved,
@@ -71,7 +72,7 @@ public fun TelegramBot.getBusinessAccountGiftsFlow(
initialOffset: String? = null,
limit: Int? = null,
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
): Flow<OwnedGifts<GiftSentOrReceivedEvent.ReceivedInBusinessAccount>> = flow {
): Flow<OwnedGifts<OwnedGift.OwnedByBusinessAccount>> = flow {
var currentOffset = initialOffset
do {
val response = runCatching {

View File

@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.gifts.GetChatGifts
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.OwnedGifts
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
import dev.inmo.tgbotapi.types.gifts.OwnedGift
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
@@ -20,7 +21,7 @@ public suspend fun TelegramBot.getChatGifts(
sortByPrice: Boolean = false,
offset: String? = null,
limit: Int? = null
): OwnedGifts<GiftSentOrReceivedEvent> = execute(
): OwnedGifts<OwnedGift.Common> = execute(
GetChatGifts(
chatId,
excludeUnsaved,
@@ -49,7 +50,7 @@ public fun TelegramBot.getChatGiftsFlow(
initialOffset: String? = null,
limit: Int? = null,
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
): Flow<OwnedGifts<GiftSentOrReceivedEvent>> = flow {
): Flow<OwnedGifts<OwnedGift.Common>> = flow {
var currentOffset = initialOffset
do {
val response = runCatching {

View File

@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.gifts.GetUserGifts
import dev.inmo.tgbotapi.types.OwnedGifts
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
import dev.inmo.tgbotapi.types.gifts.OwnedGift
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
@@ -18,7 +19,7 @@ public suspend fun TelegramBot.getUserGifts(
sortByPrice: Boolean = false,
offset: String? = null,
limit: Int? = null
): OwnedGifts<GiftSentOrReceivedEvent> = execute(
): OwnedGifts<OwnedGift.Common> = execute(
GetUserGifts(
userId,
excludeUnlimited,
@@ -43,7 +44,7 @@ public fun TelegramBot.getUserGiftsFlow(
initialOffset: String? = null,
limit: Int? = null,
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
): Flow<OwnedGifts<GiftSentOrReceivedEvent>> = flow {
): Flow<OwnedGifts<OwnedGift.Common>> = flow {
var currentOffset = initialOffset
do {
val response = runCatching {