forked from slackapi/java-slack-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncChatStreamProtocol.java
More file actions
69 lines (61 loc) · 2.37 KB
/
AsyncChatStreamProtocol.java
File metadata and controls
69 lines (61 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.slack.api.methods;
import com.slack.api.methods.request.chat.ChatAppendStreamRequest;
import com.slack.api.methods.request.chat.ChatStartStreamRequest;
import com.slack.api.methods.request.chat.ChatStopStreamRequest;
import com.slack.api.methods.response.chat.ChatAppendStreamResponse;
import com.slack.api.methods.response.chat.ChatStartStreamResponse;
import com.slack.api.methods.response.chat.ChatStopStreamResponse;
import com.slack.api.model.Message;
import com.slack.api.model.block.LayoutBlock;
import java.util.List;
import java.util.concurrent.CompletableFuture;
class AsyncChatStreamProtocol {
private final AsyncMethodsClient client;
private final String channel;
private final String threadTs;
private final String recipientTeamId;
private final String recipientUserId;
AsyncChatStreamProtocol(
AsyncMethodsClient client,
String channel,
String threadTs,
String recipientTeamId,
String recipientUserId
) {
this.client = client;
this.channel = channel;
this.threadTs = threadTs;
this.recipientTeamId = recipientTeamId;
this.recipientUserId = recipientUserId;
}
CompletableFuture<ChatStartStreamResponse> startStream(String markdownText) {
return client.chatStartStream(ChatStartStreamRequest.builder()
.channel(channel)
.threadTs(threadTs)
.recipientTeamId(recipientTeamId)
.recipientUserId(recipientUserId)
.markdownText(markdownText)
.build());
}
CompletableFuture<ChatAppendStreamResponse> appendStream(String streamTs, String markdownText) {
return client.chatAppendStream(ChatAppendStreamRequest.builder()
.channel(channel)
.ts(streamTs)
.markdownText(markdownText)
.build());
}
CompletableFuture<ChatStopStreamResponse> stopStream(
String streamTs,
String markdownText,
List<LayoutBlock> blocks,
Message.Metadata metadata
) {
return client.chatStopStream(ChatStopStreamRequest.builder()
.channel(channel)
.ts(streamTs)
.markdownText(markdownText)
.blocks(blocks)
.metadata(metadata)
.build());
}
}