|
59 | 59 | import com.slack.api.methods.request.auth.AuthRevokeRequest; |
60 | 60 | import com.slack.api.methods.request.auth.AuthTestRequest; |
61 | 61 | import com.slack.api.methods.request.auth.teams.AuthTeamsListRequest; |
| 62 | +import com.slack.api.methods.request.blocks.BlocksValidateRequest; |
62 | 63 | import com.slack.api.methods.request.bookmarks.BookmarksAddRequest; |
63 | 64 | import com.slack.api.methods.request.bookmarks.BookmarksEditRequest; |
64 | 65 | import com.slack.api.methods.request.bookmarks.BookmarksListRequest; |
@@ -1242,6 +1243,35 @@ public static FormBody.Builder toForm(AuthTeamsListRequest req) { |
1242 | 1243 | return form; |
1243 | 1244 | } |
1244 | 1245 |
|
| 1246 | + public static FormBody.Builder toForm(BlocksValidateRequest req) { |
| 1247 | + FormBody.Builder form = new FormBody.Builder(); |
| 1248 | + if (req.getBlocksAsString() != null) { |
| 1249 | + form.add("blocks", req.getBlocksAsString()); |
| 1250 | + } else if (req.getBlocks() != null) { |
| 1251 | + form.add("blocks", getJsonWithGsonAnonymInnerClassHandling(req.getBlocks())); |
| 1252 | + } |
| 1253 | + if (req.getBlocksAsString() != null && req.getBlocks() != null) { |
| 1254 | + log.warn("Although you set both blocksAsString and blocks, only blocksAsString was used."); |
| 1255 | + } |
| 1256 | + if (req.getMessageAsString() != null) { |
| 1257 | + form.add("message", req.getMessageAsString()); |
| 1258 | + } else if (req.getMessage() != null) { |
| 1259 | + form.add("message", GSON.toJson(req.getMessage())); |
| 1260 | + } |
| 1261 | + if (req.getMessageAsString() != null && req.getMessage() != null) { |
| 1262 | + log.warn("Although you set both messageAsString and message, only messageAsString was used."); |
| 1263 | + } |
| 1264 | + if (req.getViewAsString() != null) { |
| 1265 | + form.add("view", req.getViewAsString()); |
| 1266 | + } else if (req.getView() != null) { |
| 1267 | + form.add("view", GSON.toJson(req.getView())); |
| 1268 | + } |
| 1269 | + if (req.getViewAsString() != null && req.getView() != null) { |
| 1270 | + log.warn("Although you set both viewAsString and view, only viewAsString was used."); |
| 1271 | + } |
| 1272 | + return form; |
| 1273 | + } |
| 1274 | + |
1245 | 1275 | public static FormBody.Builder toForm(BookmarksAddRequest req) { |
1246 | 1276 | FormBody.Builder form = new FormBody.Builder(); |
1247 | 1277 | setIfNotNull("channel_id", req.getChannelId(), form); |
|
0 commit comments