|
| 1 | +package agents.conversations; |
| 2 | + |
| 3 | +import com.slack.api.Slack; |
| 4 | +import com.slack.api.methods.MethodsClient; |
| 5 | +import com.slack.api.methods.SlackApiException; |
| 6 | +import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest; |
| 7 | +import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest.CodeChannel; |
| 8 | +import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest.ContextBarItem; |
| 9 | +import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetPropertiesResponse; |
| 10 | +import java.io.IOException; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +public class AgentsConversationsSetProperties { |
| 14 | + |
| 15 | + public static void main(String[] args) throws IOException, SlackApiException { |
| 16 | + // Read a token from an environment variable |
| 17 | + String token = System.getenv("SLACK_TOKEN"); |
| 18 | + |
| 19 | + // Initialize |
| 20 | + MethodsClient methods = Slack.getInstance().methods(token); |
| 21 | + |
| 22 | + // Call the agents.conversations.setProperties method |
| 23 | + AgentsConversationsSetPropertiesRequest request = AgentsConversationsSetPropertiesRequest.builder() |
| 24 | + .channelId("C9876543210") |
| 25 | + .codeChannel(CodeChannel.builder() |
| 26 | + .contextBarItems(List.of( |
| 27 | + ContextBarItem.builder() |
| 28 | + .key("repo") |
| 29 | + .label("borant/billing") |
| 30 | + .icon("folder") |
| 31 | + .url("https://github.com/borant/billing") |
| 32 | + .build(), |
| 33 | + ContextBarItem.builder() |
| 34 | + .key("branch") |
| 35 | + .label("agent/migrate-cron") |
| 36 | + .icon("branch") |
| 37 | + .url("https://github.com/borant/billing/tree/agent/migrate-cron") |
| 38 | + .build(), |
| 39 | + ContextBarItem.builder() |
| 40 | + .key("pr") |
| 41 | + .label("PR #42 is open") |
| 42 | + .icon("hierarchy") |
| 43 | + .url("https://github.com/borant/billing/pull/42") |
| 44 | + .build(), |
| 45 | + ContextBarItem.builder() |
| 46 | + .key("ci") |
| 47 | + .label("Tests pending") |
| 48 | + .icon("terminal") |
| 49 | + .build())) |
| 50 | + .build()) |
| 51 | + .build(); |
| 52 | + AgentsConversationsSetPropertiesResponse response = methods.agentsConversationsSetProperties(request); |
| 53 | + |
| 54 | + // Inspect the response |
| 55 | + System.out.println(response); |
| 56 | + } |
| 57 | +} |
0 commit comments