1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-16 13:49:26 +00:00

SetWebhook#secretToken

This commit is contained in:
2022-06-21 17:55:21 +06:00
parent 8dfaca7648
commit 1df653f428
4 changed files with 34 additions and 18 deletions

View File

@@ -20,7 +20,8 @@ class MultipartSetWebhookRequest(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) : SetWebhookRequest(), MultipartRequest<Boolean> by MultipartRequestImpl(
SetWebhook(
correctWebhookUrl(url),
@@ -28,7 +29,8 @@ class MultipartSetWebhookRequest(
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
),
mapOf(certificateField to certificate)
)
@@ -39,14 +41,16 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
): MultipartSetWebhookRequest = MultipartSetWebhookRequest(
correctWebhookUrl(url),
certificate,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
)
fun SetWebhook(
@@ -55,14 +59,16 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
): SetWebhook = SetWebhook(
correctWebhookUrl(url),
certificate.fileId,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
)
/**
@@ -79,10 +85,11 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = when (certificate) {
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates)
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken)
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken)
}
/**
@@ -98,14 +105,16 @@ fun SetWebhook(
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null,
dropPendingUpdates: Boolean? = null
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = SetWebhook(
correctWebhookUrl(url),
null,
ipAddress,
maxAllowedConnections,
allowedUpdates,
dropPendingUpdates
dropPendingUpdates,
secretToken
)
/**
@@ -128,7 +137,9 @@ data class SetWebhook internal constructor(
@SerialName(allowedUpdatesField)
val allowedUpdates: List<String>? = null,
@SerialName(dropPendingUpdatesField)
val dropPendingUpdates: Boolean? = null
val dropPendingUpdates: Boolean? = null,
@SerialName(secretTokenField)
val secretToken: String? = null
) : SetWebhookRequest(), DataRequest<Boolean> {
override fun method(): String = "setWebhook"
override val resultDeserializer: DeserializationStrategy<Boolean>

View File

@@ -158,6 +158,7 @@ const val switchPmParameterField = "switch_pm_parameter"
const val maxAllowedConnectionsField = "max_connections"
const val allowedUpdatesField = "allowed_updates"
const val dropPendingUpdatesField = "drop_pending_updates"
const val secretTokenField = "secret_token"
const val hasCustomCertificateField = "has_custom_certificate"
const val pendingUpdateCountField = "pending_update_count"
const val lastErrorDateField = "last_error_date"