Skip to content

Commit aeb4fe5

Browse files
committed
Added the method editStory, allowing bots to edit stories they had previously posted on behalf of a managed business account.
1 parent 86f1b50 commit aeb4fe5

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.pengrad.telegrambot.request.business
2+
3+
import com.pengrad.telegrambot.model.MessageEntity
4+
import com.pengrad.telegrambot.model.story.StoryArea
5+
import com.pengrad.telegrambot.model.story.inputstory.InputStoryContent
6+
import com.pengrad.telegrambot.request.KBaseRequest
7+
import com.pengrad.telegrambot.response.EditStoryResponse
8+
import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
9+
import com.pengrad.telegrambot.utility.kotlin.requestParameter
10+
11+
@Suppress("unused")
12+
class EditStory private constructor(
13+
businessConnectionId: String,
14+
storyId: Int,
15+
content: InputStoryContent,
16+
caption: String?,
17+
parseMode: String?,
18+
captionEntities: Array<MessageEntity>?,
19+
areas: Array<StoryArea>?
20+
): KBaseRequest<EditStory, EditStoryResponse>(EditStoryResponse::class) {
21+
22+
constructor(businessConnectionId: String, storyId: Int, content: InputStoryContent) : this(
23+
businessConnectionId = businessConnectionId,
24+
storyId = storyId,
25+
content = content,
26+
caption = null,
27+
parseMode = null,
28+
captionEntities = null,
29+
areas = null
30+
)
31+
32+
val businessConnectionId: String by requestParameter(businessConnectionId, customParameterName = "business_connection_id")
33+
val storyId: Int by requestParameter(storyId, customParameterName = "story_id")
34+
val content: InputStoryContent by requestParameter(content, customParameterName = "content")
35+
36+
var caption: String? by optionalRequestParameter(caption, customParameterName = "caption")
37+
fun caption(caption: String) = applySelf { this.caption = caption }
38+
39+
var parseMode: String? by optionalRequestParameter(parseMode, customParameterName = "parse_mode")
40+
fun parseMode(parseMode: String) = applySelf { this.parseMode = parseMode }
41+
42+
var captionEntities: Array<MessageEntity>? by optionalRequestParameter(captionEntities, customParameterName = "caption_entities")
43+
fun captionEntities(captionEntities: Array<MessageEntity>) = applySelf { this.captionEntities = captionEntities }
44+
45+
var areas: Array<StoryArea>? by optionalRequestParameter(areas, customParameterName = "areas")
46+
fun areas(areas: Array<StoryArea>) = applySelf { this.areas = areas }
47+
48+
}

library/src/main/java/com/pengrad/telegrambot/request/business/PostStory.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import com.pengrad.telegrambot.model.MessageEntity
44
import com.pengrad.telegrambot.model.story.StoryArea
55
import com.pengrad.telegrambot.model.story.inputstory.InputStoryContent
66
import com.pengrad.telegrambot.request.KBaseRequest
7-
import com.pengrad.telegrambot.request.business.GetBusinessAccountGifts
87
import com.pengrad.telegrambot.response.PostStoryResponse
98
import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
109
import com.pengrad.telegrambot.utility.kotlin.requestParameter
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.pengrad.telegrambot.response
2+
3+
import com.pengrad.telegrambot.model.Story
4+
5+
data class EditStoryResponse(val result: Story) : BaseResponse()

0 commit comments

Comments
 (0)