2021-10-03 14:37:14 +00:00
|
|
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|
|
|
|
|
|
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
2022-08-05 10:31:39 +00:00
|
|
|
import dev.inmo.tgbotapi.extensions.utils.preCheckoutQueryUpdateOrNull
|
2021-10-03 14:37:14 +00:00
|
|
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
|
|
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
2022-05-21 19:27:52 +00:00
|
|
|
import kotlinx.coroutines.flow.Flow
|
2021-10-03 14:37:14 +00:00
|
|
|
|
|
|
|
typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery?
|
|
|
|
|
2022-05-21 19:27:52 +00:00
|
|
|
suspend fun BehaviourContext.waitPreCheckoutQueries(
|
2021-10-03 14:37:14 +00:00
|
|
|
initRequest: Request<*>? = null,
|
2022-05-21 19:27:52 +00:00
|
|
|
errorFactory: NullableRequestBuilder<*> = { null }
|
|
|
|
): Flow<PreCheckoutQuery> = expectFlow(
|
2021-10-03 14:37:14 +00:00
|
|
|
initRequest,
|
|
|
|
errorFactory
|
|
|
|
) {
|
2022-08-05 10:31:39 +00:00
|
|
|
it.preCheckoutQueryUpdateOrNull() ?.data.let(::listOfNotNull)
|
2022-05-21 19:27:52 +00:00
|
|
|
}
|