Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ public enum SlackMethods implements SlackMethod {
RateLimitingTiers.TIER_2,
JsonStatus.ACCEPTS_JSON
),

files_completeUploadExternal(
MethodWriteMode.WRITE,
RateLimitingTiers.TIER_4,
JsonStatus.ACCEPTS_JSON
),
files_delete(MethodWriteMode.WRITE, RateLimitingTiers.TIER_3, JsonStatus.ACCEPTS_JSON),
files_getUploadURLExternal(
MethodWriteMode.WRITE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.hubspot.slack.client.methods.params.files;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.hubspot.immutables.style.HubSpotStyle;
import java.util.List;
import java.util.Optional;
import org.immutables.value.Value.Immutable;

@Immutable
@HubSpotStyle
@JsonNaming(SnakeCaseStrategy.class)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public interface CompleteUploadExternalParamsIF {
List<FileInfo> getFiles();
Optional<String> getChannelId();
Optional<String> getThreadTs();
Optional<String> getInitialComment();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.hubspot.slack.client.methods.params.files;

import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.hubspot.immutables.style.HubSpotStyle;
import org.immutables.value.Value.Immutable;

@Immutable
@HubSpotStyle
@JsonNaming(SnakeCaseStrategy.class)
public interface FileInfoIF {
String getId();
String getTitle();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.hubspot.slack.client.models.response.files;

import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.hubspot.immutables.style.HubSpotStyle;
import com.hubspot.slack.client.models.files.SlackFile;
import com.hubspot.slack.client.models.response.SlackResponse;
import java.util.List;
import org.immutables.value.Value.Immutable;

@Immutable
@HubSpotStyle
@JsonNaming(SnakeCaseStrategy.class)
public interface CompleteUploadExternalResponseIF extends SlackResponse {
List<SlackFile> getFiles();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.hubspot.slack.client.methods.params.dialog.DialogOpenParams;
import com.hubspot.slack.client.methods.params.dnd.DndInfoParams;
import com.hubspot.slack.client.methods.params.dnd.DndSetSnoozeParams;
import com.hubspot.slack.client.methods.params.files.CompleteUploadExternalParams;
import com.hubspot.slack.client.methods.params.files.FilesSharedPublicUrlParams;
import com.hubspot.slack.client.methods.params.files.FilesUploadParams;
import com.hubspot.slack.client.methods.params.files.GetUploadUrlExternalParams;
Expand Down Expand Up @@ -118,6 +119,8 @@
import com.hubspot.slack.client.models.response.dnd.DndInfoResponse;
import com.hubspot.slack.client.models.response.dnd.DndSnoozeResponse;
import com.hubspot.slack.client.models.response.emoji.EmojiListResponse;
import com.hubspot.slack.client.models.response.files.CompleteUploadExternalResponse;
import com.hubspot.slack.client.models.response.files.CompleteUploadExternalResponseIF;
import com.hubspot.slack.client.models.response.files.FilesSharedPublicUrlResponse;
import com.hubspot.slack.client.models.response.files.FilesUploadResponse;
import com.hubspot.slack.client.models.response.files.GetUploadUrlExternalResponse;
Expand Down Expand Up @@ -392,10 +395,12 @@ CompletableFuture<Result<AddReactionResponse, SlackError>> addReaction(
CompletableFuture<Result<FilesUploadResponse, SlackError>> uploadFile(
FilesUploadParams params
);

CompletableFuture<Result<GetUploadUrlExternalResponse, SlackError>> getUploadURLExternal(
GetUploadUrlExternalParams params
);
CompletableFuture<Result<CompleteUploadExternalResponse, SlackError>> completeUploadExternal(
CompleteUploadExternalParams params
);
CompletableFuture<Result<FilesSharedPublicUrlResponse, SlackError>> shareFilePublically(
FilesSharedPublicUrlParams params
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import com.hubspot.slack.client.methods.params.dialog.DialogOpenParams;
import com.hubspot.slack.client.methods.params.dnd.DndInfoParams;
import com.hubspot.slack.client.methods.params.dnd.DndSetSnoozeParams;
import com.hubspot.slack.client.methods.params.files.CompleteUploadExternalParams;
import com.hubspot.slack.client.methods.params.files.FilesSharedPublicUrlParams;
import com.hubspot.slack.client.methods.params.files.FilesUploadParams;
import com.hubspot.slack.client.methods.params.files.GetUploadUrlExternalParams;
Expand Down Expand Up @@ -155,6 +156,7 @@
import com.hubspot.slack.client.models.response.dnd.DndInfoResponse;
import com.hubspot.slack.client.models.response.dnd.DndSnoozeResponse;
import com.hubspot.slack.client.models.response.emoji.EmojiListResponse;
import com.hubspot.slack.client.models.response.files.CompleteUploadExternalResponse;
import com.hubspot.slack.client.models.response.files.FilesSharedPublicUrlResponse;
import com.hubspot.slack.client.models.response.files.FilesUploadResponse;
import com.hubspot.slack.client.models.response.files.GetUploadUrlExternalResponse;
Expand Down Expand Up @@ -596,7 +598,7 @@ protected LazyLoadingPage<Result<List<LiteMessage>, SlackError>, Long> getPage(
ChannelsHistoryParams.Builder requestBuilder = ChannelsHistoryParams
.builder()
.from(params);
if (!params.getCount().isPresent()) {
if (params.getCount().isEmpty()) {
requestBuilder.setCount(config.getChannelsHistoryMessageBatchSize().get());
}

Expand Down Expand Up @@ -633,7 +635,7 @@ protected LazyLoadingPage<Result<List<LiteMessage>, SlackError>, Long> getPage(
);

CompletableFuture<Boolean> hasMoreFuture = resultFuture.thenApply(result ->
result.match(err -> false, ok -> ok.hasMore())
result.match(err -> false, ChannelsHistoryResponse::hasMore)
);
CompletableFuture<Long> nextOffset = nextOffset(pagingDirection, pageFuture);

Expand All @@ -646,8 +648,8 @@ private CompletableFuture<Long> nextOffset(
PagingDirection pagingDirection,
CompletableFuture<Result<List<LiteMessage>, SlackError>> pageFuture
) {
return pageFuture.thenApply(page -> {
return page.match(
return pageFuture.thenApply(page ->
page.match(
err -> null,
messages -> {
Set<String> timestamps = messages
Expand All @@ -670,8 +672,8 @@ private CompletableFuture<Long> nextOffset(

return null;
}
);
});
)
);
}

@Override
Expand Down Expand Up @@ -1037,7 +1039,7 @@ protected LazyLoadingPage<Result<List<LiteMessage>, SlackError>, Long> getPage(
ConversationsHistoryParams.Builder requestBuilder = ConversationsHistoryParams
.builder()
.from(params);
if (!params.getLimit().isPresent()) {
if (params.getLimit().isEmpty()) {
requestBuilder.setLimit(config.getConversationsHistoryMessageBatchSize().get());
}

Expand Down Expand Up @@ -1074,7 +1076,7 @@ protected LazyLoadingPage<Result<List<LiteMessage>, SlackError>, Long> getPage(
);

CompletableFuture<Boolean> hasMoreFuture = resultFuture.thenApply(result ->
result.match(err -> false, ok -> ok.hasMore())
result.match(err -> false, ConversationsHistoryResponse::hasMore)
);
CompletableFuture<Long> nextOffset = nextOffset(pagingDirection, pageFuture);

Expand Down Expand Up @@ -1157,7 +1159,7 @@ protected LazyLoadingPage<Result<List<String>, SlackError>, String> getPage(
ConversationMemberParams.Builder requestBuilder = ConversationMemberParams
.builder()
.from(params);
if (!params.getLimit().isPresent()) {
if (params.getLimit().isEmpty()) {
requestBuilder.setLimit(config.getConversationMembersBatchSize().get());
}
Optional.ofNullable(offset).ifPresent(requestBuilder::setCursor);
Expand Down Expand Up @@ -1412,6 +1414,17 @@ public CompletableFuture<Result<GetUploadUrlExternalResponse, SlackError>> getUp
);
}

@Override
public CompletableFuture<Result<CompleteUploadExternalResponse, SlackError>> completeUploadExternal(
CompleteUploadExternalParams params
) {
return postSlackCommand(
SlackMethods.files_completeUploadExternal,
params,
CompleteUploadExternalResponse.class
);
}

@Override
public CompletableFuture<Result<FilesSharedPublicUrlResponse, SlackError>> shareFilePublically(
FilesSharedPublicUrlParams params
Expand Down