-
Notifications
You must be signed in to change notification settings - Fork 233
feat(model): add TaskCardBlock and UrlSourceElement #1638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5023106
feat(model): add TaskCardBlock and UrlSourceElement
srtaalej 83e4ec2
Update slack-api-model/src/test/java/test_locally/api/model/block/Blo…
srtaalej d089233
fix: update assertion to match in_progress status in test
srtaalej f6aad3a
refactor: alphabetize block entries in factory and tests
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
slack-api-model/src/main/java/com/slack/api/model/block/TaskCardBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.slack.api.model.block; | ||
|
|
||
| import com.slack.api.model.block.composition.SlackIconObject; | ||
| import com.slack.api.model.block.element.UrlSourceElement; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * https://docs.slack.dev/reference/block-kit/blocks/task-card-block | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class TaskCardBlock implements LayoutBlock { | ||
| public static final String TYPE = "task_card"; | ||
| private final String type = TYPE; | ||
|
|
||
| private String taskId; | ||
| private String title; | ||
| private String status; | ||
| private RichTextBlock details; | ||
| private RichTextBlock output; | ||
| private List<UrlSourceElement> sources; | ||
| private String blockId; | ||
| private SlackIconObject icon; | ||
| private Boolean hideTitle; | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
slack-api-model/src/main/java/com/slack/api/model/block/element/UrlSourceElement.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.slack.api.model.block.element; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * https://docs.slack.dev/reference/block-kit/block-elements/url-source-element | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class UrlSourceElement { | ||
| public static final String TYPE = "url"; | ||
| private final String type = TYPE; | ||
|
|
||
| private String url; | ||
| private String text; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,40 +33,42 @@ public LayoutBlock deserialize(JsonElement json, Type typeOfT, JsonDeserializati | |
|
|
||
| private Class<? extends LayoutBlock> getLayoutClassInstance(String typeName) { | ||
| switch (typeName) { | ||
| case SectionBlock.TYPE: | ||
| return SectionBlock.class; | ||
| case DividerBlock.TYPE: | ||
| return DividerBlock.class; | ||
| case ImageBlock.TYPE: | ||
| return ImageBlock.class; | ||
| case ContextBlock.TYPE: | ||
| return ContextBlock.class; | ||
| case ContextActionsBlock.TYPE: | ||
| return ContextActionsBlock.class; | ||
| case CallBlock.TYPE: | ||
| return CallBlock.class; | ||
| case ActionsBlock.TYPE: | ||
| return ActionsBlock.class; | ||
| case AlertBlock.TYPE: | ||
| return AlertBlock.class; | ||
| case CallBlock.TYPE: | ||
| return CallBlock.class; | ||
| case CardBlock.TYPE: | ||
| return CardBlock.class; | ||
| case CarouselBlock.TYPE: | ||
| return CarouselBlock.class; | ||
| case ContextActionsBlock.TYPE: | ||
| return ContextActionsBlock.class; | ||
| case ContextBlock.TYPE: | ||
| return ContextBlock.class; | ||
| case DividerBlock.TYPE: | ||
| return DividerBlock.class; | ||
| case FileBlock.TYPE: | ||
| return FileBlock.class; | ||
| case InputBlock.TYPE: | ||
| return InputBlock.class; | ||
| case HeaderBlock.TYPE: | ||
| return HeaderBlock.class; | ||
| case ImageBlock.TYPE: | ||
| return ImageBlock.class; | ||
| case InputBlock.TYPE: | ||
| return InputBlock.class; | ||
| case MarkdownBlock.TYPE: | ||
| return MarkdownBlock.class; | ||
| case VideoBlock.TYPE: | ||
| return VideoBlock.class; | ||
| case RichTextBlock.TYPE: | ||
| return RichTextBlock.class; | ||
| case SectionBlock.TYPE: | ||
| return SectionBlock.class; | ||
| case ShareShortcutBlock.TYPE: | ||
| return ShareShortcutBlock.class; | ||
| case AlertBlock.TYPE: | ||
| return AlertBlock.class; | ||
| case CardBlock.TYPE: | ||
| return CardBlock.class; | ||
| case CarouselBlock.TYPE: | ||
| return CarouselBlock.class; | ||
| case TaskCardBlock.TYPE: | ||
| return TaskCardBlock.class; | ||
|
Comment on lines
+68
to
+69
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎲 note: Similar suggestion to alphabetical ordering but no blocker if this is a significant change! |
||
| case VideoBlock.TYPE: | ||
| return VideoBlock.class; | ||
| default: | ||
| if (failOnUnknownProperties) { | ||
| throw new JsonParseException("Unsupported layout block type: " + typeName); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💸 praise: Nice!