Package com.slack.api
Class Slack
- java.lang.Object
-
- com.slack.api.Slack
-
- All Implemented Interfaces:
AutoCloseable
public class Slack extends Object implements AutoCloseable
This class is a kind of facade of a variety of Slack API clients offered by this SDK. Any objects of this class and all the APIs this class provides are thread-safe. We recommend sharing an instance across your application.This class internally uses the OkHttpClient and the client has its own daemon thread for realizing its optimal resource management. When your app needs to close all the threads when shutting down etc, call #close() method to terminate those threads.
If your application depends on the Gson library for JSON manipulation as with this SDK and the app uses the latest version for some reasons, just in case, you may need to check the binary-compatibility among their releases. We don't think any issues happened before but in general, some libraries may break bin-compatibility among major/minor releases.
- See Also:
- OkHttpClient, Gson
-
-
Constructor Summary
Constructors Constructor Description Slack()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AuditClientaudit()Creates a Audit Logs API client.AuditClientaudit(String token)voidclose()SlackConfiggetConfig()SlackHttpClientgetHttpClient()static SlackgetInstance()static SlackgetInstance(SlackConfig config)static SlackgetInstance(SlackConfig config, SlackHttpClient httpClient)static SlackgetInstance(SlackHttpClient httpClient)MethodsClientmethods()Creates a Methods API client.MethodsClientmethods(String token)AsyncMethodsClientmethodsAsync()AsyncMethodsClientmethodsAsync(String token)MethodsStatsmethodsStats(String teamId)MethodsStatsmethodsStats(String executorName, String teamId)RTMClientrtm(String apiToken)Creates an RTM API client.RTMClientrtmConnect(String apiToken)Creates an RTM API client using `/rtm.connect`.RTMClientrtmConnect(String apiToken, boolean fullUserInfoRequired)Creates an RTM API client using `/rtm.connect`.RTMClientrtmStart(String apiToken)Creates an RTM API client using `/rtm.start`.RTMClientrtmStart(String apiToken, boolean fullUserInfoRequired)Creates an RTM API client using `/rtm.start`.SCIMClientscim()Creates a SCIM API client.SCIMClientscim(String token)WebhookResponsesend(String url, Payload payload)Send a data to Incoming Webhook endpoint.WebhookResponsesend(String url, String payload)Send a raw JSON body to Incoming Webhook endpoint.StatusClientstatus()LegacyStatusClientstatusLegacy()Creates a Status API client.
-
-
-
Method Detail
-
getInstance
public static Slack getInstance()
-
getInstance
public static Slack getInstance(SlackConfig config)
-
getInstance
public static Slack getInstance(SlackConfig config, SlackHttpClient httpClient)
-
getInstance
public static Slack getInstance(SlackHttpClient httpClient)
-
getConfig
public SlackConfig getConfig()
-
getHttpClient
public SlackHttpClient getHttpClient()
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
send
public WebhookResponse send(String url, Payload payload) throws IOException
Send a data to Incoming Webhook endpoint.- Throws:
IOException
-
send
public WebhookResponse send(String url, String payload) throws IOException
Send a raw JSON body to Incoming Webhook endpoint.- Throws:
IOException
-
rtm
public RTMClient rtm(String apiToken) throws IOException
Creates an RTM API client.- Throws:
IOException- See Also:
- Slack RTM API, RTM's Rate Limits
-
rtmConnect
public RTMClient rtmConnect(String apiToken) throws IOException
Creates an RTM API client using `/rtm.connect`.- Throws:
IOException- See Also:
- Slack RTM API, RTM's Rate Limits
-
rtmConnect
public RTMClient rtmConnect(String apiToken, boolean fullUserInfoRequired) throws IOException
Creates an RTM API client using `/rtm.connect`.- Throws:
IOException- See Also:
- Slack RTM API, RTM's Rate Limits
-
rtmStart
public RTMClient rtmStart(String apiToken) throws IOException
Creates an RTM API client using `/rtm.start`.- Throws:
IOException- See Also:
- Slack RTM API, RTM's Rate Limits
-
rtmStart
public RTMClient rtmStart(String apiToken, boolean fullUserInfoRequired) throws IOException
Creates an RTM API client using `/rtm.start`.- Throws:
IOException- See Also:
- Slack RTM API, RTM's Rate Limits
-
statusLegacy
public LegacyStatusClient statusLegacy()
Creates a Status API client.
-
status
public StatusClient status()
-
scim
public SCIMClient scim()
Creates a SCIM API client.
-
scim
public SCIMClient scim(String token)
-
audit
public AuditClient audit()
Creates a Audit Logs API client.
-
audit
public AuditClient audit(String token)
-
methods
public MethodsClient methods()
Creates a Methods API client.
-
methods
public MethodsClient methods(String token)
-
methodsAsync
public AsyncMethodsClient methodsAsync()
-
methodsAsync
public AsyncMethodsClient methodsAsync(String token)
-
methodsStats
public MethodsStats methodsStats(String teamId)
-
methodsStats
public MethodsStats methodsStats(String executorName, String teamId)
-
-