Skip to content

Commit 924f79f

Browse files
Merge pull request #392 from HubSpot/feature/update_fields_for_work_object
Feature/update fields for work object
2 parents 0b45a0c + 46cbc9a commit 924f79f

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
package com.hubspot.slack.client.methods.params.chat.workobject.entity;
22

3+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
4+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
5+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
36
import com.hubspot.immutables.style.HubSpotStyle;
7+
import com.hubspot.slack.client.methods.params.chat.workobject.serializers.FieldDataTypeSerializer;
8+
import java.util.Optional;
49
import org.immutables.value.Value;
510

611
@Value.Immutable
712
@HubSpotStyle
13+
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
814
public interface EntityPayloadAttributesCustomFieldIF {
915
String getKey();
1016
String getLabel();
1117
String getValue();
12-
String getType();
18+
19+
@JsonSerialize(using = FieldDataTypeSerializer.class)
20+
FieldDataType getType();
21+
22+
//Can only be set when the type is string. This icon will be displayed next to field's text value. Not compatible with tag_color.
23+
Optional<Icon> getIcon();
24+
25+
//Can only be set when the type is string, date, or timestamp. The field's content will be hyperlinked with the URL specified here
26+
Optional<String> getLink();
27+
28+
//Can only be set when the type is string. Allows the string to be highlighted in of one of the following colors: red, yellow, green, gray, blue. E.g. tag_color: "red"
29+
Optional<String> getTagColor();
30+
31+
//Used when the field's type is slack#/types/image.
32+
Optional<String> getImageUrl();
33+
34+
//Used when the field's type is slack#/types/image.
35+
Optional<String> getSlackFile();
36+
37+
//Used when the field's type is slack#/types/image.
38+
Optional<String> getAltText();
1339
}

slack-base/src/main/java/com/hubspot/slack/client/methods/params/chat/workobject/entity/EntityPayloadAttributesIF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public interface EntityPayloadAttributesIF {
2222
Optional<DisplayType> getDisplayType();
2323

2424
Optional<String> getProductName();
25-
Optional<ProductIcon> getProductIcon();
25+
Optional<Icon> getProductIcon();
2626
Optional<String> getLocale();
2727
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.hubspot.slack.client.methods.params.chat.workobject.entity;
2+
3+
public enum FieldDataType {
4+
STRING("string"),
5+
INTEGER("integer"),
6+
USER_ID("slack#/types/user_id"),
7+
CHANNEL_ID("slack#/types/channel_id"),
8+
TIMESTAMP("slack#/types/timestamp"),
9+
//A date in the format YYYY-MM-DD
10+
DATE("slack#/types/date"),
11+
//An image; provide either the URL of a publicly hosted image (image_url) or a slack_file with a preview image
12+
IMAGE("slack#/types/image");
13+
14+
private final String value;
15+
16+
FieldDataType(String value) {
17+
this.value = value;
18+
}
19+
20+
public String getValue() {
21+
return value;
22+
}
23+
}

slack-base/src/main/java/com/hubspot/slack/client/methods/params/chat/workobject/entity/ProductIconIF.java renamed to slack-base/src/main/java/com/hubspot/slack/client/methods/params/chat/workobject/entity/IconIF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@Value.Immutable
99
@HubSpotStyle
1010
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
11-
public interface ProductIconIF {
11+
public interface IconIF {
1212
String getUrl();
1313
String getAltText();
1414
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.hubspot.slack.client.methods.params.chat.workobject.serializers;
2+
3+
import com.fasterxml.jackson.core.JsonGenerator;
4+
import com.fasterxml.jackson.databind.JsonSerializer;
5+
import com.fasterxml.jackson.databind.SerializerProvider;
6+
import com.hubspot.slack.client.methods.params.chat.workobject.entity.FieldDataType;
7+
import java.io.IOException;
8+
9+
public class FieldDataTypeSerializer extends JsonSerializer<FieldDataType> {
10+
11+
@Override
12+
public void serialize(
13+
FieldDataType fieldDataType,
14+
JsonGenerator jsonGenerator,
15+
SerializerProvider serializerProvider
16+
) throws IOException {
17+
jsonGenerator.writeString(fieldDataType.getValue());
18+
}
19+
}

0 commit comments

Comments
 (0)