Skip to content

Commit d1fa29f

Browse files
authored
feat: update work object types (#1533)
* update fields * camel not snake
1 parent dc393d4 commit d1fa29f

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

slack-api-client/src/test/java/test_with_remote_apis/methods/chat_Test.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.slack.api.methods.response.files.FilesUploadResponse;
1616
import com.slack.api.methods.response.files.FilesUploadV2Response;
1717
import com.slack.api.model.*;
18+
import com.slack.api.model.EntityMetadata.EntityPayload.BooleanField;
1819
import com.slack.api.model.EntityMetadata.EntityPayload.FileFields;
1920
import com.slack.api.model.EntityMetadata.EntityPayload.IncidentFields;
2021
import com.slack.api.model.EntityMetadata.EntityPayload;
@@ -539,10 +540,13 @@ public void unfurl_with_work_object_from_object() throws Exception {
539540
EntityPayload.StringField.builder().value("World").tagColor("green").build()};
540541
EntityPayload.CustomField[] customFields = {
541542
EntityPayload.CustomField.builder().type("string").key("hello_world").label("Message")
542-
.value("Hello World").build(),
543+
.value("Hello World").build(),
543544
EntityPayload.CustomField.builder().type("array").key("array_field")
544-
.label("Array Field").itemType("string")
545-
.value(stringArray).build()};
545+
.label("Array Field").itemType("string")
546+
.value(stringArray).build(),
547+
EntityPayload.CustomField.builder().type("boolean").key("checkbox").label("Checkbox")
548+
.value(true).booleanField(BooleanField.builder().type("checkbox").text("Check the box").build()).build()
549+
};
546550
EntityPayload payload = EntityPayload.builder()
547551
.attributes(attributes)
548552
.fileFields(fields)
@@ -568,6 +572,8 @@ public void unfurl_with_work_object_from_object() throws Exception {
568572
.metadata(metadata)
569573
.build());
570574
assertThat(unfurlResponse.getError(), is(nullValue()));
575+
assertThat(unfurlResponse.getWarning(), is(nullValue()));
576+
assertThat(unfurlResponse.getResponseMetadata(), is(nullValue()));
571577

572578
// Verify if the message can be parsed by the JSON parser
573579
ConversationsHistoryResponse history = slack.methods(botToken).conversationsHistory(r -> r

slack-api-model/src/main/java/com/slack/api/model/EntityMetadata.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ public static class TypedField {
129129

130130
// When type is 'slack#/types/user'
131131
private User user;
132+
133+
// When type is 'slack#/types/entity_ref'
134+
private EntityRef entityRef;
135+
136+
// When type is 'boolean'
137+
@SerializedName("boolean")
138+
private BooleanField booleanField;
132139
}
133140

134141
@Data
@@ -146,6 +153,36 @@ public static class User {
146153
private Icon icon;
147154
}
148155

156+
@Data
157+
@Builder
158+
@NoArgsConstructor
159+
@AllArgsConstructor
160+
public static class BooleanField {
161+
private String type;
162+
163+
// Checkbox
164+
private String text;
165+
private String description;
166+
167+
// or text-based
168+
private String trueText;
169+
private String trueDescription;
170+
private String falseText;
171+
private String falseDescription;
172+
}
173+
174+
@Data
175+
@Builder
176+
@NoArgsConstructor
177+
@AllArgsConstructor
178+
public static class EntityRef {
179+
private String entityUrl;
180+
private ExternalRef externalRef;
181+
private String displayType;
182+
private String title;
183+
private Icon icon;
184+
}
185+
149186
@Data
150187
@Builder
151188
@NoArgsConstructor
@@ -170,8 +207,6 @@ public static class StringField {
170207
public static class Timestamp {
171208
private String label;
172209
private Integer value;
173-
private String link;
174-
private Icon icon;
175210
private String type;
176211
private Edit edit;
177212
}
@@ -220,6 +255,9 @@ public static class CustomField {
220255
private Edit edit;
221256
private String itemType;
222257
private User user;
258+
private EntityRef entityRef;
259+
@SerializedName("boolean")
260+
private BooleanField booleanField;
223261
}
224262

225263
@Data

0 commit comments

Comments
 (0)