-
Notifications
You must be signed in to change notification settings - Fork 232
feat(methods): add blocks.validate method #1622
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
Draft
zimeg
wants to merge
16
commits into
main
Choose a base branch
from
blocks-validate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a7c05c7
feat(methods): add blocks.validate method
zimeg 02a29a7
fix(methods): classify blocks.validate as a special rate-limit tier
zimeg efb20b6
test(methods): add remote coverage for blocks.validate
zimeg eb983ef
style(methods): sort blocks.validate into its alphabetical position
zimeg 2764f52
fix(methods): treat blocks.validate as unauthenticated
zimeg 1894103
Merge remote-tracking branch 'origin/main' into blocks-validate
zimeg 226fa23
fix(methods): align blocks.validate errors[] with documented contract
zimeg 8c560f6
test(methods): ground blocks.validate errors[] in the live API contract
zimeg bd42793
fix(methods): use blank-skeleton mock fixture for blocks.validate
zimeg 8fbb2c3
fix(methods): correct blocks.validate rate limit and strengthen tests
zimeg 11739e1
docs(methods): note blocks.validate special tier follows from no token
zimeg 5f8be9b
feat(methods): accept typed blocks on blocks.validate
zimeg 816a861
feat(methods): accept typed message and view on blocks.validate
zimeg 94bcce3
fix(methods): type blocks.validate constraint expected/got as JsonEle…
zimeg d5be43e
style(methods): trim blocks.validate Constraint field comments
zimeg 69ea477
style(methods): match request-class doc convention for blocks.validate
zimeg 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "ok": false, | ||
| "error": "", | ||
| "response_metadata": { | ||
| "messages": [ | ||
| "" | ||
| ] | ||
| }, | ||
| "needed": "", | ||
| "provided": "", | ||
| "errors": [ | ||
| { | ||
| "code": "", | ||
| "message": "", | ||
| "pointer": "", | ||
| "constraint": { | ||
| "type": "", | ||
| "expected": [ | ||
| "" | ||
| ], | ||
| "got": "" | ||
| } | ||
| } | ||
| ], | ||
| "warning": "" | ||
| } |
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
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
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
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
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
60 changes: 60 additions & 0 deletions
60
...-api-client/src/main/java/com/slack/api/methods/request/blocks/BlocksValidateRequest.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,60 @@ | ||
| package com.slack.api.methods.request.blocks; | ||
|
|
||
| import com.slack.api.methods.SlackApiRequest; | ||
| import com.slack.api.model.Attachment; | ||
| import com.slack.api.model.block.LayoutBlock; | ||
| import com.slack.api.model.view.View; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * https://docs.slack.dev/reference/methods/blocks.validate | ||
| */ | ||
| @Data | ||
| @Builder | ||
| public class BlocksValidateRequest implements SlackApiRequest { | ||
|
|
||
| /** | ||
| * An array of blocks to validate. | ||
| */ | ||
| private List<LayoutBlock> blocks; | ||
|
|
||
| /** | ||
| * An array of blocks to validate, as a JSON-encoded string. | ||
| */ | ||
| private String blocksAsString; | ||
|
|
||
| /** | ||
| * A message payload to validate. | ||
| */ | ||
| private MessagePayload message; | ||
|
|
||
| /** | ||
| * A message payload to validate, as a JSON-encoded string. | ||
| */ | ||
| private String messageAsString; | ||
|
|
||
| /** | ||
| * A view payload to validate. | ||
| */ | ||
| private View view; | ||
|
|
||
| /** | ||
| * A view payload to validate, as a JSON-encoded string. | ||
| */ | ||
| private String viewAsString; | ||
|
|
||
| @Override | ||
| public String getToken() { | ||
| return null; | ||
| } | ||
|
|
||
| @Data | ||
| @Builder | ||
| public static class MessagePayload { | ||
| private List<LayoutBlock> blocks; | ||
| private List<Attachment> attachments; | ||
| } | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
...pi-client/src/main/java/com/slack/api/methods/response/blocks/BlocksValidateResponse.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,41 @@ | ||
| package com.slack.api.methods.response.blocks; | ||
|
|
||
| import com.google.gson.JsonElement; | ||
| import com.slack.api.methods.SlackApiTextResponse; | ||
| import com.slack.api.model.ResponseMetadata; | ||
| import lombok.Data; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| @Data | ||
| public class BlocksValidateResponse implements SlackApiTextResponse { | ||
|
|
||
| private boolean ok; | ||
| private String warning; | ||
| private String error; | ||
| private String needed; | ||
| private String provided; | ||
| private transient Map<String, List<String>> httpResponseHeaders; | ||
|
|
||
| private ResponseMetadata responseMetadata; | ||
| private List<Error> errors; | ||
|
|
||
| // https://docs.slack.dev/reference/methods/blocks.validate#validation-errors | ||
| @Data | ||
| public static class Error { | ||
| private String pointer; | ||
| private String code; | ||
| private String message; | ||
| private Constraint constraint; | ||
|
|
||
| // expected/got are JsonElement because their shape varies by constraint type | ||
| // (a string array for "enum", a number for length/count constraints, or absent). | ||
| @Data | ||
| public static class Constraint { | ||
| private String type; | ||
| private JsonElement expected; | ||
| private JsonElement got; | ||
|
Comment on lines
+37
to
+38
Member
Author
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: These can be handled with a typecheck in calling code but for now we avoid parsing responses into particular types here. |
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
👁️🗨️ note: This is added to the request class for
blocks.validateto bring matching arguments for: