diff --git a/methods/README.md b/methods/README.md index 1bd5d8e..9344ddd 100644 --- a/methods/README.md +++ b/methods/README.md @@ -18,5 +18,8 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques ### chat +- **[chat.appendStream](https://docs.slack.dev/reference/methods/chat.appendStream)**: Appends text to an existing streaming conversation. [Implementation](./src/main/java/chat/ChatAppendStream.java). - **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/main/java/chat/ChatPostMessage.java). +- **[chat.startStream](https://docs.slack.dev/reference/methods/chat.startStream)**: Starts a new streaming conversation. [Implementation](./src/main/java/chat/ChatStartStream.java). +- **[chat.stopStream](https://docs.slack.dev/reference/methods/chat.stopStream)**: Stops a streaming conversation. [Implementation](./src/main/java/chat/ChatStopStream.java). diff --git a/methods/src/main/java/chat/ChatAppendStream.java b/methods/src/main/java/chat/ChatAppendStream.java new file mode 100644 index 0000000..c086d6c --- /dev/null +++ b/methods/src/main/java/chat/ChatAppendStream.java @@ -0,0 +1,30 @@ +package chat; + +import com.slack.api.Slack; +import com.slack.api.methods.MethodsClient; +import com.slack.api.methods.SlackApiException; +import com.slack.api.methods.request.chat.ChatAppendStreamRequest; +import com.slack.api.methods.response.chat.ChatAppendStreamResponse; +import java.io.IOException; + +public class ChatAppendStream { + + public static void main(String[] args) throws IOException, SlackApiException { + // Read a token from an environment variable + String token = System.getenv("SLACK_TOKEN"); + + // Initialize + MethodsClient methods = Slack.getInstance().methods(token); + + // Call the chat.appendStream method + ChatAppendStreamRequest request = ChatAppendStreamRequest.builder() + .channel("C123ABC456") + .ts("1234567890.123456") + .markdownText(" — reading the logs now") + .build(); + ChatAppendStreamResponse response = methods.chatAppendStream(request); + + // Inspect the response + System.out.println(response); + } +} diff --git a/methods/src/main/java/chat/ChatStartStream.java b/methods/src/main/java/chat/ChatStartStream.java new file mode 100644 index 0000000..374e1fd --- /dev/null +++ b/methods/src/main/java/chat/ChatStartStream.java @@ -0,0 +1,30 @@ +package chat; + +import com.slack.api.Slack; +import com.slack.api.methods.MethodsClient; +import com.slack.api.methods.SlackApiException; +import com.slack.api.methods.request.chat.ChatStartStreamRequest; +import com.slack.api.methods.response.chat.ChatStartStreamResponse; +import java.io.IOException; + +public class ChatStartStream { + + public static void main(String[] args) throws IOException, SlackApiException { + // Read a token from an environment variable + String token = System.getenv("SLACK_TOKEN"); + + // Initialize + MethodsClient methods = Slack.getInstance().methods(token); + + // Call the chat.startStream method + ChatStartStreamRequest request = ChatStartStreamRequest.builder() + .channel("C123ABC456") + .threadTs("1234567890.123456") + .markdownText("Let me look into that") + .build(); + ChatStartStreamResponse response = methods.chatStartStream(request); + + // Inspect the response + System.out.println(response); + } +} diff --git a/methods/src/main/java/chat/ChatStopStream.java b/methods/src/main/java/chat/ChatStopStream.java new file mode 100644 index 0000000..dab0739 --- /dev/null +++ b/methods/src/main/java/chat/ChatStopStream.java @@ -0,0 +1,29 @@ +package chat; + +import com.slack.api.Slack; +import com.slack.api.methods.MethodsClient; +import com.slack.api.methods.SlackApiException; +import com.slack.api.methods.request.chat.ChatStopStreamRequest; +import com.slack.api.methods.response.chat.ChatStopStreamResponse; +import java.io.IOException; + +public class ChatStopStream { + + public static void main(String[] args) throws IOException, SlackApiException { + // Read a token from an environment variable + String token = System.getenv("SLACK_TOKEN"); + + // Initialize + MethodsClient methods = Slack.getInstance().methods(token); + + // Call the chat.stopStream method + ChatStopStreamRequest request = ChatStopStreamRequest.builder() + .channel("C123ABC456") + .ts("1234567890.123456") + .build(); + ChatStopStreamResponse response = methods.chatStopStream(request); + + // Inspect the response + System.out.println(response); + } +}