Skip to content

Commit

Permalink
Fix slackapi#462 Calls API support
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored and emanguy committed Jun 22, 2020
1 parent 8dd5496 commit ea539c9
Show file tree
Hide file tree
Showing 38 changed files with 1,075 additions and 2 deletions.
23 changes: 23 additions & 0 deletions json-logs/samples/api/calls.add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ok": false,
"error": "",
"response_metadata": {
"messages": [
""
]
},
"call": {
"id": "R00000000",
"date_start": 12345,
"external_unique_id": "",
"join_url": "https://www.example.com/",
"title": "",
"users": [
{
"slack_id": "U00000000"
}
]
},
"needed": "",
"provided": ""
}
23 changes: 23 additions & 0 deletions json-logs/samples/api/calls.end.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ok": false,
"call": {
"id": "R00000000",
"date_start": 12345,
"external_unique_id": "",
"join_url": "https://www.example.com/",
"date_end": 12345,
"channels": [
"C00000000"
],
"external_display_id": "",
"title": "",
"users": [
{
"slack_id": "U00000000"
}
]
},
"error": "",
"needed": "",
"provided": ""
}
22 changes: 22 additions & 0 deletions json-logs/samples/api/calls.info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"ok": false,
"call": {
"id": "R00000000",
"date_start": 12345,
"external_unique_id": "",
"join_url": "https://www.example.com/",
"channels": [
"C00000000"
],
"external_display_id": "",
"title": "",
"users": [
{
"slack_id": "U00000000"
}
]
},
"error": "",
"needed": "",
"provided": ""
}
22 changes: 22 additions & 0 deletions json-logs/samples/api/calls.participants.add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"ok": false,
"call": {
"id": "R00000000",
"date_start": 12345,
"external_unique_id": "",
"join_url": "https://www.example.com/",
"channels": [
"C00000000"
],
"external_display_id": "",
"title": "",
"users": [
{
"slack_id": "U00000000"
}
]
},
"error": "",
"needed": "",
"provided": ""
}
22 changes: 22 additions & 0 deletions json-logs/samples/api/calls.update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"ok": false,
"call": {
"id": "R00000000",
"date_start": 12345,
"external_unique_id": "",
"join_url": "https://www.example.com/",
"channels": [
"C00000000"
],
"external_display_id": "",
"title": "",
"users": [
{
"slack_id": "U00000000"
}
]
},
"error": "",
"needed": "",
"provided": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
import com.slack.api.methods.request.auth.AuthRevokeRequest;
import com.slack.api.methods.request.auth.AuthTestRequest;
import com.slack.api.methods.request.bots.BotsInfoRequest;
import com.slack.api.methods.request.calls.CallsAddRequest;
import com.slack.api.methods.request.calls.CallsEndRequest;
import com.slack.api.methods.request.calls.CallsInfoRequest;
import com.slack.api.methods.request.calls.CallsUpdateRequest;
import com.slack.api.methods.request.calls.participants.CallsParticipantsAddRequest;
import com.slack.api.methods.request.chat.*;
import com.slack.api.methods.request.chat.scheduled_messages.ChatScheduledMessagesListRequest;
import com.slack.api.methods.request.conversations.*;
Expand Down Expand Up @@ -80,6 +85,11 @@
import com.slack.api.methods.response.auth.AuthRevokeResponse;
import com.slack.api.methods.response.auth.AuthTestResponse;
import com.slack.api.methods.response.bots.BotsInfoResponse;
import com.slack.api.methods.response.calls.CallsAddResponse;
import com.slack.api.methods.response.calls.CallsEndResponse;
import com.slack.api.methods.response.calls.CallsInfoResponse;
import com.slack.api.methods.response.calls.CallsUpdateResponse;
import com.slack.api.methods.response.calls.participants.CallsParticipantsAddResponse;
import com.slack.api.methods.response.channels.UsersLookupByEmailResponse;
import com.slack.api.methods.response.chat.*;
import com.slack.api.methods.response.chat.scheduled_messages.ChatScheduledMessagesListResponse;
Expand Down Expand Up @@ -371,6 +381,34 @@ public interface AsyncMethodsClient {

CompletableFuture<BotsInfoResponse> botsInfo(RequestConfigurator<BotsInfoRequest.BotsInfoRequestBuilder> req);

// ------------------------------
// calls
// ------------------------------

CompletableFuture<CallsAddResponse> callsAdd(CallsAddRequest req);

CompletableFuture<CallsAddResponse> callsAdd(RequestConfigurator<CallsAddRequest.CallsAddRequestBuilder> req);

CompletableFuture<CallsEndResponse> callsEnd(CallsEndRequest req);

CompletableFuture<CallsEndResponse> callsEnd(RequestConfigurator<CallsEndRequest.CallsEndRequestBuilder> req);

CompletableFuture<CallsInfoResponse> callsInfo(CallsInfoRequest req);

CompletableFuture<CallsInfoResponse> callsInfo(RequestConfigurator<CallsInfoRequest.CallsInfoRequestBuilder> req);

CompletableFuture<CallsUpdateResponse> callsUpdate(CallsUpdateRequest req);

CompletableFuture<CallsUpdateResponse> callsUpdate(RequestConfigurator<CallsUpdateRequest.CallsUpdateRequestBuilder> req);

// ------------------------------
// calls.participants
// ------------------------------

CompletableFuture<CallsParticipantsAddResponse> callsParticipantsAdd(CallsParticipantsAddRequest req);

CompletableFuture<CallsParticipantsAddResponse> callsParticipantsAdd(RequestConfigurator<CallsParticipantsAddRequest.CallsParticipantsAddRequestBuilder> req);

// ------------------------------
// chat
// ------------------------------
Expand Down
15 changes: 15 additions & 0 deletions slack-api-client/src/main/java/com/slack/api/methods/Methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,21 @@ private Methods() {

public static final String BOTS_INFO = "bots.info";

// ------------------------------
// calls
// ------------------------------

public static final String CALLS_ADD = "calls.add";
public static final String CALLS_END = "calls.end";
public static final String CALLS_INFO = "calls.info";
public static final String CALLS_UPDATE = "calls.update";

// ------------------------------
// calls.participants
// ------------------------------

public static final String CALLS_PARTICIPANTS_ADD = "calls.participants.add";

// ------------------------------
// channels
// ------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import com.slack.api.methods.request.auth.AuthRevokeRequest;
import com.slack.api.methods.request.auth.AuthTestRequest;
import com.slack.api.methods.request.bots.BotsInfoRequest;
import com.slack.api.methods.request.calls.CallsAddRequest;
import com.slack.api.methods.request.calls.CallsEndRequest;
import com.slack.api.methods.request.calls.CallsInfoRequest;
import com.slack.api.methods.request.calls.CallsUpdateRequest;
import com.slack.api.methods.request.calls.participants.CallsParticipantsAddRequest;
import com.slack.api.methods.request.channels.*;
import com.slack.api.methods.request.chat.*;
import com.slack.api.methods.request.chat.scheduled_messages.ChatScheduledMessagesListRequest;
Expand Down Expand Up @@ -99,6 +104,11 @@
import com.slack.api.methods.response.auth.AuthRevokeResponse;
import com.slack.api.methods.response.auth.AuthTestResponse;
import com.slack.api.methods.response.bots.BotsInfoResponse;
import com.slack.api.methods.response.calls.CallsAddResponse;
import com.slack.api.methods.response.calls.CallsEndResponse;
import com.slack.api.methods.response.calls.CallsInfoResponse;
import com.slack.api.methods.response.calls.CallsUpdateResponse;
import com.slack.api.methods.response.calls.participants.CallsParticipantsAddResponse;
import com.slack.api.methods.response.channels.*;
import com.slack.api.methods.response.chat.*;
import com.slack.api.methods.response.chat.scheduled_messages.ChatScheduledMessagesListResponse;
Expand Down Expand Up @@ -515,6 +525,34 @@ <T extends SlackApiResponse> T postFormWithAuthorizationHeaderAndParseResponse(

BotsInfoResponse botsInfo(RequestConfigurator<BotsInfoRequest.BotsInfoRequestBuilder> req) throws IOException, SlackApiException;

// ------------------------------
// calls
// ------------------------------

CallsAddResponse callsAdd(CallsAddRequest req) throws IOException, SlackApiException;

CallsAddResponse callsAdd(RequestConfigurator<CallsAddRequest.CallsAddRequestBuilder> req) throws IOException, SlackApiException;

CallsEndResponse callsEnd(CallsEndRequest req) throws IOException, SlackApiException;

CallsEndResponse callsEnd(RequestConfigurator<CallsEndRequest.CallsEndRequestBuilder> req) throws IOException, SlackApiException;

CallsInfoResponse callsInfo(CallsInfoRequest req) throws IOException, SlackApiException;

CallsInfoResponse callsInfo(RequestConfigurator<CallsInfoRequest.CallsInfoRequestBuilder> req) throws IOException, SlackApiException;

CallsUpdateResponse callsUpdate(CallsUpdateRequest req) throws IOException, SlackApiException;

CallsUpdateResponse callsUpdate(RequestConfigurator<CallsUpdateRequest.CallsUpdateRequestBuilder> req) throws IOException, SlackApiException;

// ------------------------------
// calls.participants
// ------------------------------

CallsParticipantsAddResponse callsParticipantsAdd(CallsParticipantsAddRequest req) throws IOException, SlackApiException;

CallsParticipantsAddResponse callsParticipantsAdd(RequestConfigurator<CallsParticipantsAddRequest.CallsParticipantsAddRequestBuilder> req) throws IOException, SlackApiException;

// ------------------------------
// channels
// ------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ public static void setRateLimitTier(String methodName, MethodsRateLimitTier tier

setRateLimitTier(BOTS_INFO, Tier3);

setRateLimitTier(CALLS_ADD, Tier2);
setRateLimitTier(CALLS_END, Tier2);
setRateLimitTier(CALLS_INFO, Tier2);
setRateLimitTier(CALLS_UPDATE, Tier2);
setRateLimitTier(CALLS_PARTICIPANTS_ADD, Tier2);

setRateLimitTier(CHAT_DELETE, Tier3);
setRateLimitTier(CHAT_DELETE_SCHEDULED_MESSAGE, Tier3);
setRateLimitTier(CHAT_GET_PERMALINK, SpecialTier_chat_getPermalink);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.slack.api.methods;

import com.google.gson.Gson;
import com.slack.api.methods.request.admin.apps.*;
import com.slack.api.methods.request.admin.conversations.AdminConversationsSetTeamsRequest;
import com.slack.api.methods.request.admin.emoji.*;
Expand All @@ -24,6 +25,11 @@
import com.slack.api.methods.request.auth.AuthRevokeRequest;
import com.slack.api.methods.request.auth.AuthTestRequest;
import com.slack.api.methods.request.bots.BotsInfoRequest;
import com.slack.api.methods.request.calls.CallsAddRequest;
import com.slack.api.methods.request.calls.CallsEndRequest;
import com.slack.api.methods.request.calls.CallsInfoRequest;
import com.slack.api.methods.request.calls.CallsUpdateRequest;
import com.slack.api.methods.request.calls.participants.CallsParticipantsAddRequest;
import com.slack.api.methods.request.channels.*;
import com.slack.api.methods.request.chat.*;
import com.slack.api.methods.request.chat.scheduled_messages.ChatScheduledMessagesListRequest;
Expand Down Expand Up @@ -89,6 +95,8 @@
@Slf4j
public class RequestFormBuilder {

private static final Gson GSON = GsonFactory.createSnakeCase();

private RequestFormBuilder() {
}

Expand Down Expand Up @@ -460,6 +468,54 @@ public static FormBody.Builder toForm(BotsInfoRequest req) {
return form;
}

public static FormBody.Builder toForm(CallsAddRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("external_unique_id", req.getExternalUniqueId(), form);
setIfNotNull("join_url", req.getJoinUrl(), form);
setIfNotNull("created_by", req.getCreatedBy(), form);
setIfNotNull("date_start", req.getDateStart(), form);
setIfNotNull("desktop_app_join_url", req.getDesktopAppJoinUrl(), form);
setIfNotNull("external_display_id", req.getExternalDisplayId(), form);
setIfNotNull("title", req.getTitle(), form);
if (req.getUsers() != null && req.getUsers().size() > 0) {
String usersJson = GSON.toJson(req.getUsers());
setIfNotNull("users", usersJson, form);
}
return form;
}

public static FormBody.Builder toForm(CallsEndRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("id", req.getId(), form);
setIfNotNull("duration", req.getDuration(), form);
return form;
}

public static FormBody.Builder toForm(CallsInfoRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("id", req.getId(), form);
return form;
}

public static FormBody.Builder toForm(CallsUpdateRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("id", req.getId(), form);
setIfNotNull("desktop_app_join_url", req.getDesktopAppJoinUrl(), form);
setIfNotNull("join_url", req.getJoinUrl(), form);
setIfNotNull("title", req.getTitle(), form);
return form;
}

public static FormBody.Builder toForm(CallsParticipantsAddRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("id", req.getId(), form);
if (req.getUsers() != null && req.getUsers().size() > 0) {
String usersJson = GSON.toJson(req.getUsers());
setIfNotNull("users", usersJson, form);
}
return form;
}

public static FormBody.Builder toForm(ChannelsArchiveRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("channel", req.getChannel(), form);
Expand Down
Loading

0 comments on commit ea539c9

Please sign in to comment.