RingCentral Developers is a cloud communications platform which can be accessed via more than 70 APIs. The platform's main capabilities include technologies that enable: Voice, SMS/MMS, Fax, Glip Team Messaging, Data and Configurations.
API Reference and APIs Explorer.
repositories {
jcenter()
}
dependencies {
compile 'com.ringcentral:ringcentral:[version]'
}
Don't forget to replace [version]
with expected version.
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<dependency>
<groupId>com.ringcentral</groupId>
<artifactId>ringcentral</artifactId>
<version>[version]</version>
<type>pom</type>
</dependency>
Don't forget to replace [version]
with expected version.
Download jar here and save it into your java classpath.
RestClient restClient = new RestClient(clientId, clientSecret, server);
restClient.authorize(username, extension, password);
For the server
parameter, there are two static final string variables in RestClient
:
public static final String SANDBOX_SERVER = "https://platform.devtest.ringcentral.com";
public static final String PRODUCTION_SERVER = "https://platform.ringcentral.com";
The following code snippets are equivalent, you can choose whichever based on your preferences:
String endpoint = "/restapi/v1.0/account/~/extension/~/sms";
String endpoint = restClient.restApi("v1.0").account("~").extension("~").sms().endpoint();
String endpoint = restClient.restApi().account().extension().sms().endpoint();
The following code snippets are also equivalent:
restClient.post(
"/restapi/v1.0/account/~/extension/~/sms",
postParameters);
restClient.post(
restClient.restApi("v1.0").account("~").extension("~").sms().endpoint(),
postParameters);
restClient.post(
restClient.restApi().account().extension().sms().endpoint(),
postParameters);
restClient.restApi("v1.0").account("~").extension("~").sms()
.post(postParameters);
restClient.restApi().account().extension().sms()
.post(postParameters);
ResponseBody responseBody = restClient.restApi().account().extension().sms()
.post(postParameters);
// String stringBody = responseBody.string();
// byte[] bytes = resonseBody.bytes();
// ...
- ❗️ ❗️ Please don't forget to invoke
responseBody.close()
. Ref: square/okhttp#2311- If you invoked
responseBody.string()
you don't need to invokeresponseBody.close()
because the former implicitly closes body.
- If you invoked
MessageInfo messageInfo = restClient.restApi().account().extension().sms()
.post(postParameters, MessageInfo.class);
// System.out.println(messageInfo.creationTime)
// ...
Subscription subscription = restClient.subscription(
new String[]{
"/restapi/v1.0/glip/posts",
"/restapi/v1.0/account/~/extension/~/message-store",
// more event filters here
},
(message) -> {
// do something with message
});
subscription.subscribe();
Please check the test cases.