The Releans SDK enables developers to use Releans Services in their code. You can get started in minutes.
The generated code uses a few Maven dependencies e.g., Jackson, UniRest, and Apache HttpClient. The reference to these dependencies is already added in the pom.xml file will be installed automatically. Therefore, you will need internet access for a successful build.
- In order to open the client library in Eclipse click on
File -> Import
.
- In the import dialog, select
Existing Java Project
and clickNext
.
- Browse to locate the folder containing the source code. Select the detected location of the project and click
Finish
.
- Upon successful import, the project will be automatically built by Eclipse after automatically resolving the dependencies.
The following section explains how to use the ReleansAPI library in a new console project.
For starting a new project, click the menu command File > New > Project
.
Next, choose Maven > Maven Project
and click Next
.
Here, make sure to use the current workspace by choosing Use default Workspace location
, as shown in the picture below and click Next
.
Following this, select the quick start project type to create a simple project with an existing class and a main
method. To do this, choose maven-archetype-quickstart
item from the list and click Next
.
In the last step, provide a Group Id
and Artifact Id
as shown in the picture below and click Finish
.
The created Maven project manages its dependencies using its pom.xml
file. In order to add a dependency on the ReleansAPILib client library, double click on the pom.xml
file in the Package Explorer
. Opening the pom.xml
file will render a graphical view on the cavas. Here, switch to the Dependencies
tab and click the Add
button as shown in the picture below.
Clicking the Add
button will open a dialog where you need to specify ReleansAPI in Group Id
and ReleansAPILib in the Artifact Id
fields. Once added click OK
. Save the pom.xml
file.
Once the SimpleConsoleApp
is created, a file named App.java
will be visible in the Package Explorer with a main
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.
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 Eclipse, for running the tests do the following:
- Select the project ReleansAPILib from the package explorer.
- Select "Run -> Run as -> JUnit Test" or use "Alt + Shift + X" followed by "T" to run the Tests.
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.
// Configuration parameters and credentials
String oAuthAccessToken = "oAuthAccessToken"; // OAuth 2.0 Access Token
ReleansAPIClient client = new ReleansAPIClient(oAuthAccessToken);
The singleton instance of the MessageController
class can be accessed from the API Client.
MessageController message = client.getMessage();
List all messages sent by the account.
void getAllMessagesAsync(
final String accept,
final APICallBack<DynamicResponse> callBack)
Parameter | Tags | Description |
---|---|---|
accept | Required |
TODO: Add a parameter description |
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
}
});
Return the details of the message.
void getViewMessageAsync(
final String id,
final String accept,
final APICallBack<DynamicResponse> callBack)
Parameter | Tags | Description |
---|---|---|
id | Required |
TODO: Add a parameter description |
accept | Required |
TODO: Add a parameter description |
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
}
});
Send a single message.
void createSendSMSMessageAsync(
final String accept,
final String senderId,
final String mobileNumber,
final String message,
final APICallBack<DynamicResponse> callBack)
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. |
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
}
});
The singleton instance of the SenderController
class can be accessed from the API Client.
SenderController sender = client.getSender();
Return the details of the sender name.
void getSenderNameDetailsAsync(
final String id,
final String accept,
final APICallBack<DynamicResponse> callBack)
Parameter | Tags | Description |
---|---|---|
id | Required |
TODO: Add a parameter description |
accept | Required |
TODO: Add a parameter description |
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
}
});
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)
Parameter | Tags | Description |
---|---|---|
accept | Required |
TODO: Add a parameter description |
contentType | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
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
}
});
List all senders names associated with the account
void getAllSendersAsync(
final String accept,
final APICallBack<List<Response2001>> callBack)
Parameter | Tags | Description |
---|---|---|
accept | Required |
TODO: Add a parameter description |
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
}
});
The singleton instance of the BalanceController
class can be accessed from the API Client.
BalanceController balance = client.getBalance();
Get your available balance
void getBalanceAsync(
final String accept,
final APICallBack<Response2002> callBack)
Parameter | Tags | Description |
---|---|---|
accept | Required |
TODO: Add a parameter description |
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
}
});