Skip to content

Commit 684ba5b

Browse files
committed
Add Java-style builder methods for optional parameters in SavePreparedInlineMessage & SendGift
1 parent 1ec5a87 commit 684ba5b

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

library/src/main/java/com/pengrad/telegrambot/request/SavePreparedInlineMessage.kt

+12-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ class SavePreparedInlineMessage(
1616
val userId: Long by requestParameter(userId)
1717
val result: InlineQueryResult<*> by requestParameter(result)
1818

19-
@set:JvmName("allowUserChats") var allowUserChats: Boolean? by optionalRequestParameter(customParameterName = "allow_user_chats")
20-
@set:JvmName("allowBotChats") var allowBotChats: Boolean? by optionalRequestParameter(customParameterName = "allow_bot_chats")
21-
@set:JvmName("allowGroupChats") var allowGroupChats: Boolean? by optionalRequestParameter(customParameterName = "allow_group_chats")
22-
@set:JvmName("allowChannelChats") var allowChannelChats: Boolean? by optionalRequestParameter(customParameterName = "allow_channel_chats")
19+
var allowUserChats: Boolean? by optionalRequestParameter(customParameterName = "allow_user_chats")
20+
var allowBotChats: Boolean? by optionalRequestParameter(customParameterName = "allow_bot_chats")
21+
var allowGroupChats: Boolean? by optionalRequestParameter(customParameterName = "allow_group_chats")
22+
var allowChannelChats: Boolean? by optionalRequestParameter(customParameterName = "allow_channel_chats")
23+
24+
fun allowUserChats(allowUserChats: Boolean) = apply { this.allowUserChats = allowUserChats }
25+
26+
fun allowBotChats(allowBotChats: Boolean) = apply { this.allowBotChats = allowBotChats }
27+
28+
fun allowGroupChats(allowGroupChats: Boolean) = apply { this.allowGroupChats = allowGroupChats }
29+
30+
fun allowChannelChats(allowChannelChats: Boolean) = apply { this.allowChannelChats = allowChannelChats }
2331

2432
}

library/src/main/java/com/pengrad/telegrambot/request/SendGift.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SendGift(
1111
giftId: String,
1212
) : KBaseRequest<SendGift, BaseResponse>(BaseResponse::class) {
1313

14-
val userId: Long by requestParameter(userId)
14+
val userId: Long by requestParameter(userId, customParameterName = "user_id")
1515
val giftId: String by requestParameter(giftId, customParameterName = "gift_id")
1616

1717
@set:JvmName("text") var text: String? by optionalRequestParameter()
@@ -21,4 +21,10 @@ class SendGift(
2121
)
2222
@set:JvmName("textEntities") var textEntities: Array<MessageEntity>? by optionalRequestParameter(customParameterName = "text_entities")
2323

24+
fun text(text: String) = apply { this.text = text }
25+
26+
fun textParseMode(parseMode: ParseMode) = apply { this.textParseMode = textParseMode }
27+
28+
fun textEntities(textEntities: Array<MessageEntity>) = apply { this.textEntities = textEntities }
29+
2430
}

0 commit comments

Comments
 (0)