Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions methods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques

## What's on call

### blocks

- **[blocks.validate](https://docs.slack.dev/reference/methods/blocks.validate)**: Validates blocks, messages, and views Block Kit JSON payloads. [Implementation](./src/main/java/blocks/BlocksValidate.java).

### chat

- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/main/java/chat/ChatPostMessage.java).
Expand Down
29 changes: 29 additions & 0 deletions methods/src/main/java/blocks/BlocksValidate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package blocks;

import static com.slack.api.model.block.Blocks.section;
import static com.slack.api.model.block.composition.BlockCompositions.plainText;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.blocks.BlocksValidateRequest;
import com.slack.api.methods.response.blocks.BlocksValidateResponse;
import java.io.IOException;
import java.util.Arrays;

public class BlocksValidate {

public static void main(String[] args) throws IOException, SlackApiException {
// Initialize
MethodsClient methods = Slack.getInstance().methods();

// Call the blocks.validate method
BlocksValidateRequest request = BlocksValidateRequest.builder()
.blocks(Arrays.asList(section(s -> s.text(plainText("Hello world")))))
.build();
BlocksValidateResponse response = methods.blocksValidate(request);

// Inspect the response
System.out.println(response);
}
}
16 changes: 16 additions & 0 deletions methods/src/main/java/blocks/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"display_information": {
"name": "Slack API Methods",
"description": "Example implementations to call \"blocks\" methods"
},
"oauth_config": {
"scopes": {
"bot": []
}
},
"settings": {
"org_deploy_enabled": true,
"socket_mode_enabled": false,
"token_rotation_enabled": false
}
}