You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can add the Block Kit Kotlin DSL via 2 artifacts:
114
114
115
-
* The `slack-api-model` Kotlin extension, which adds the Kotlin DSL itself as well as the standalone `withBlocks { }` builder and `View.ViewBuilder`'s `.blocks { }` extension function
116
-
* The `slack-api-client` Kotlin extension, which adds the `.blocks { }` extension function to `MethodsClient`'s request object builders for seamless use of the DSL with the Java builders
117
-
* The `.blocks { }` extension function is available on the following Java builders:
118
-
* ChatPostEphemeralRequestBuilder
119
-
* ChatPostMessageRequestBuilder
120
-
* ChatScheduleMessageRequestBuilder
121
-
* ChatUpdateRequestBuilder
115
+
|artifactId|Description|
116
+
|---|---|
117
+
|[**com.slack.api:slack-api-model-kotlin-extension**](https://search.maven.org/search?q=g:com.slack.api%20AND%20a:slack-api-model-kotlin-extension)[📖](https://oss.sonatype.org/service/local/repositories/releases/archive/com/slack/api/slack-api-model-kotlin-extension/{{ site.sdkLatestVersion }}/slack-api-model-kotlin-extension-{{ site.sdkLatestVersion }}-javadoc.jar/!/index.html#package)|The **slack-api-model** Kotlin extension, which adds the Kotlin DSL itself as well as the standalone `withBlocks { }` builder and `View.ViewBuilder`'s `.blocks { }` extension function.|
118
+
|[**com.slack.api:slack-api-client-kotlin-extension**](https://search.maven.org/search?q=g:com.slack.api%20AND%20a:slack-api-client-kotlin-extension)[📖](https://oss.sonatype.org/service/local/repositories/releases/archive/com/slack/api/slack-api-client-kotlin-extension/{{ site.sdkLatestVersion }}/slack-api-client-kotlin-extension-{{ site.sdkLatestVersion }}-javadoc.jar/!/index.html#package)|The **slack-api-client** Kotlin extension, which adds the `.blocks { }` extension function to `MethodsClient`'s request object builders for seamless use of the DSL with the Java builders such as **ChatPostEphemeralRequestBuilder**, **ChatPostMessageRequestBuilder**, **ChatScheduleMessageRequestBuilder**, and **ChatUpdateRequestBuilder**.|
122
119
123
120
**Adding via Gradle:**
124
121
@@ -140,9 +137,11 @@ dependencies {
140
137
141
138
### Notable examples and features
142
139
143
-
**Standalone withBlocks builder which comes with the model extension**:
140
+
In this section, I'll share some code snippets demonstrating how to use this DSL.
144
141
145
-
You can create lists of blocks outside of the `slack-api-client` Kotlin extension functions with the `withBlocks { }` builder.
142
+
#### Standalone `withBlocks { }` builder which comes with the model extension
143
+
144
+
You can create lists of blocks outside of the **slack-api-client** Kotlin extension functions with the `withBlocks { }` builder.
**Type safe enums for inputs which require specific string inputs**:
156
+
#### Type safe enums for inputs which require specific string inputs
157
+
158
+
Type-safe enums are available for properties of some block elements which require specific input strings.
158
159
159
-
Type-safe enums are available for properties of some block elements which require specific input strings. With this, you get the benefit of verifying your inputs are correct at compile time and you gain access to Kotlin enum features such as being able to iterate over or retrieve all possible values for these inputs. Versions of these inputs which accept strings are also available, if you prefer.
160
+
With this, you get the benefit of verifying your inputs are correct at compile time, and you gain access to Kotlin enum features such as being able to iterate over or retrieve all possible values for these inputs. Versions of these inputs which accept strings are also available, if you prefer.
**Write DSL extension functions for message templating**:
192
+
#### Write DSL extension functions for message templating
192
193
193
194
Because it is a Kotlin DSL, you benefit from Kotlin language features while you are constructing your messages, one of which being able to create extension functions which reproduce common Block Kit structures. This makes your code less repetitive and easier to read. You also benefit from being able to use conditionals and loops as you construct your blocks.
194
195
@@ -218,7 +219,10 @@ val blocks = withBlocks {
218
219
markdownText("Please select your favorite color.")
219
220
}
220
221
actions {
221
-
presentOptions("Green", "Red", "Blue", "Yellow", "Orange", "Black", prompt ="Pick a color...")
0 commit comments