Skip to content

Commit 0d098b5

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

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

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

Lines changed: 12 additions & 4 deletions
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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ 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

17-
@set:JvmName("text") var text: String? by optionalRequestParameter()
18-
@set:JvmName("textParseMode") var textParseMode: ParseMode? by optionalRequestParameter(
17+
var text: String? by optionalRequestParameter()
18+
var textParseMode: ParseMode? by optionalRequestParameter(
1919
customParameterName = "text_parse_mode",
2020
valueMapper = { it?.name }
2121
)
22-
@set:JvmName("textEntities") var textEntities: Array<MessageEntity>? by optionalRequestParameter(customParameterName = "text_entities")
22+
var textEntities: Array<MessageEntity>? by optionalRequestParameter(customParameterName = "text_entities")
23+
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 }
2329

2430
}

0 commit comments

Comments
 (0)