Skip to content

penguin4238/ringcentral-java

 
 

Repository files navigation

RingCentral SDK for Java

Build Status Coverage Status Download Chat Community Twitter

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.

Installation

Gradle

repositories {
  jcenter()
}

dependencies {
  compile 'com.ringcentral:ringcentral:[version]'
}

Don't forget to replace [version] with expected version.

Maven

<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.

Manually

Download jar here and save it into your java classpath.

Usage

Intialization & Authorization

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";

Url Builder

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);

Url Builder Examples

Raw Response vs. Models

Raw Response

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 invoke responseBody.close() because the former implicitly closes body.

Models

MessageInfo messageInfo = restClient.restApi().account().extension().sms()
    .post(postParameters, MessageInfo.class);
// System.out.println(messageInfo.creationTime)
// ...

Send sms

Example

Glip related

Example

Specify query parameters

Example

Subscription & notification

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();

Example

Send fax

Example

Upload & Download binary files

Example

More examples

Please check the test cases.

About

RingCentral Java SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%