Skip to content

tylerlong/ringcentral-java

Repository files navigation

ringcentral-java

Build Status Coverage Status Download

Installation

Gradle

repositories {
  jcenter()
}

dependencies {
  compile 'com.ringcentral:ringcentral:0.2.4'
}

Maven

<repositories>
  <repository>
    <id>jcenter</id>
    <url>https://jcenter.bintray.com/</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.ringcentral</groupId>
  <artifactId>ringcentral</artifactId>
  <version>0.2.4</version>
  <type>pom</type>
</dependency>

Usage

RestClient restClient = new RestClient(appKey, appSecret, server);
restClient.authorize(username, extension, password);

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, you can choose whichever based on your preferences:

MessageInfo messageInfo = restClient.post("/restapi/v1.0/account/~/extension/~/sms", postParameters, MessageInfo.class);
MessageInfo messageInfo = restClient.post(restClient.restApi("v1.0").account("~").extension("~").sms().endpoint(), postParameters, MessageInfo.class);
MessageInfo messageInfo = restClient.post(restClient.restApi().account().extension().sms().endpoint(), postParameters, MessageInfo.class);
MessageInfo messageInfo = restClient.restApi("v1.0").account("~").extension("~").sms().post(postParameters, MessageInfo.class);
MessageInfo messageInfo = restClient.restApi().account().extension().sms().post(postParameters, MessageInfo.class);

Models or raw response

Both are OK:

ResponseBody responseBody = restClient.restApi().account().extension().sms().post(postParameters);
String stringBody = responseBody.string();
MessageInfo messageInfo = restClient.restApi().account().extension().sms().post(postParameters, MessageInfo.class);

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

Async

You can simply start a new thread.

Example

More examples

Please check the test cases.




For contributors

Setup

cp src/test/resources/.env.sample src/test/resources/.env
edit src/test/resources/.env

Test

./gradlew test

Auto generate models

All the files inside src/main/java/com/ringcentral/definitions/ and src/main/java/com/ringcentral/paths/ are auto-generated.

Please refer to rc-codegen project.

The generated code is formatted by IntelliJ IDEA.

Release a new version

Update version numbers in build.gradle.

./gradlew -PbintrayUser=bintrayUser -PbintrayApiKey=bintrayApiKey bintrayUpload

Todo

  • Rewrite in Kotlin - optional, low priority