Skip to content
The Releans Android SDK allow you to get up an running with Releans API quickly in your project. # What you can do with Releans Services? 1- Send emails 2- On-time SMS 3- Automation for reminders and appointments
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ReleansAPILib
gradle/wrapper
LICENSE
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

Getting started

The Releans SDK enables developers to use Releans Services in their code. You can get started in minutes.

How to Build

The generated code uses a few Gradle dependencies e.g., Jackson, Volley, and Apache HttpClient. The reference to these dependencies is already added in the build.gradle file will be installed automatically. Therefore, you will need internet access for a successful build.

  • In order to open the client library in Android Studio click on Open an Existing Android Project.

Importing SDK into Android Studio - Step 1

  • Browse to locate the folder containing the source code. Select the location of the ReleansAPI gradle project and click Ok.

Importing SDK into Android Studio - Step 2

  • Upon successful import, the project can be built by clicking on Build > Make Project or pressing Ctrl + F9.

Importing SDK into Android Studio - Step 3

How to Use

The following section explains how to use the ReleansAPI library in a new project.

1. Starting a new project

For starting a new project, click on Create New Android Studio Project.

Add a new project in Android Studio - Step 1

Here, configure the new project by adding the name, domain and location of the sample application followed by clicking Next.

Create a new Android Studio Project - Step 2

Following this, select the Phone and Tablet option as shown in the illustration below and click Next.

Create a new Android Studio Project - Step 3

In the following step, choose Empty Activity as the activity type and click Next.

Create a new Android Studio Project - Step 4

In this step, provide an Activity Name and Layout Name and click Finish. This would take you to the newly created project.

Create a new Android Studio Project - Step 4

2. Add reference of the library project

In order to add a dependency to this sample application, click on the android button shown in the project explorer on the left side as shown in the picture. Click on Project in the drop down that emerges.

Adding dependency to the client library - Step 1

Right click the sample application in the project explorer and click on New > Module as shown in the picture.

Adding dependency to the client library - Step 2

Choose Import Gradle Project and click Next.

Adding dependency to the client library - Step 3

Click on Finish which would take you back to the sample application with the refernced SDK.

Adding dependency to the client library - Step 4

In the following step first navigate to the SampleApplication > settings.gradle file and add the line include ':ReleansAPILib'

Then navigate to the SampleApplication > app > build.gradle file and add the following line implementation project(path: ':ReleansAPILib') to the dependencies section as shown in the illustration below. Also add the following packagingOptions.

packagingOptions exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/DEPENDENCIES' }

Adding dependency to the client library - Step 5

Finally, press Sync Now in the warning visible as shown in the picture below.

Adding dependency to the client library - Step 6

3. Write sample code

Once the SampleApplication is created, a file named SampleApplication > app > src > main > java > MainActivity will be visible in the Project Explorer with an onCreate method. This is the entry point for the execution of the created project. Here, you can add code to initialize the client library and instantiate a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.

How to Test

The generated code and the server can be tested using automatically generated test cases. JUnit is used as the testing framework and test runner.

In Android Studio, for running the tests do the following:

  1. Right click on SampleApplication > ReleansAPILib > androidTest > java) from the project explorer.
  2. Select "Run All Tests" or use "Ctrl + Shift + F10" to run the Tests.

Initialization

Authentication

In order to setup authentication and initialization of the API client, you need the following information.

Parameter Description
oAuthAccessToken OAuth 2.0 Access Token

API client can be initialized as following. The appContext being passed is the Android application Context.

// Configuration parameters and credentials
String oAuthAccessToken = "oAuthAccessToken"; // OAuth 2.0 Access Token

com.releans.platform.Configuration.initialize(appContext);
ReleansAPIClient client = new ReleansAPIClient(oAuthAccessToken);

Class Reference

List of Controllers

Class: MessageController

Get singleton instance

The singleton instance of the MessageController class can be accessed from the API Client.

MessageController message = client.getMessage();

Method: getAllMessagesAsync

List all messages sent by the account.

void getAllMessagesAsync(
        final String accept,
        final APICallBack<DynamicResponse> callBack)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

String accept = "*/*";
// Invoking the API call with sample inputs
message.getAllMessagesAsync(accept, new APICallBack<DynamicResponse>() {
    public void onSuccess(HttpContext context, DynamicResponse response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Method: getViewMessageAsync

Return the details of the message.

void getViewMessageAsync(
        final String id,
        final String accept,
        final APICallBack<DynamicResponse> callBack)

Parameters

Parameter Tags Description
id Required TODO: Add a parameter description
accept Required TODO: Add a parameter description

Example Usage

String id = "id";
String accept = "*/*";
// Invoking the API call with sample inputs
message.getViewMessageAsync(id, accept, new APICallBack<DynamicResponse>() {
    public void onSuccess(HttpContext context, DynamicResponse response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Method: createSendSMSMessageAsync

Send a single message.

void createSendSMSMessageAsync(
        final String accept,
        final String senderId,
        final String mobileNumber,
        final String message,
        final APICallBack<DynamicResponse> callBack)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description
senderId Required Sender id to send the message from.
mobileNumber Required The mobile number supposed to receive the message.
message Required Message text.

Example Usage

String accept = "Accept";
String senderId = "senderId";
String mobileNumber = "mobileNumber";
String message = "message";
// Invoking the API call with sample inputs
message.createSendSMSMessageAsync(accept, senderId, mobileNumber, message, new APICallBack<DynamicResponse>() {
    public void onSuccess(HttpContext context, DynamicResponse response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Back to List of Controllers

Class: SenderController

Get singleton instance

The singleton instance of the SenderController class can be accessed from the API Client.

SenderController sender = client.getSender();

Method: getSenderNameDetailsAsync

Return the details of the sender name.

void getSenderNameDetailsAsync(
        final String id,
        final String accept,
        final APICallBack<DynamicResponse> callBack)

Parameters

Parameter Tags Description
id Required TODO: Add a parameter description
accept Required TODO: Add a parameter description

Example Usage

String id = "sender-id";
String accept = "*/*";
// Invoking the API call with sample inputs
sender.getSenderNameDetailsAsync(id, accept, new APICallBack<DynamicResponse>() {
    public void onSuccess(HttpContext context, DynamicResponse response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Method: createSenderNameAsync

Create a new sender id to send messages using it

void createSenderNameAsync(
        final String accept,
        final String contentType,
        final String body,
        final APICallBack<Response200> callBack)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description
contentType Required TODO: Add a parameter description
body Required TODO: Add a parameter description

Example Usage

String accept = "text/plain";
String contentType = "text/plain";
String body = "Your sender name";
// Invoking the API call with sample inputs
sender.createSenderNameAsync(accept, contentType, body, new APICallBack<Response200>() {
    public void onSuccess(HttpContext context, Response200 response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Method: getAllSendersAsync

List all senders names associated with the account

void getAllSendersAsync(
        final String accept,
        final APICallBack<List<Response2001>> callBack)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

String accept = "*/*";
// Invoking the API call with sample inputs
sender.getAllSendersAsync(accept, new APICallBack<List<Response2001>>() {
    public void onSuccess(HttpContext context, List<Response2001> response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Back to List of Controllers

Class: BalanceController

Get singleton instance

The singleton instance of the BalanceController class can be accessed from the API Client.

BalanceController balance = client.getBalance();

Method: getBalanceAsync

Get your available balance

void getBalanceAsync(
        final String accept,
        final APICallBack<Response2002> callBack)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

String accept = "text/plain";
// Invoking the API call with sample inputs
balance.getBalanceAsync(accept, new APICallBack<Response2002>() {
    public void onSuccess(HttpContext context, Response2002 response) {
        // TODO success callback handler
    }
    public void onFailure(HttpContext context, Throwable error) {
        // TODO failure callback handler
    }
});

Back to List of Controllers

You can’t perform that action at this time.