This Api is meant for 3rd party integrations
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 CynSMSAPI 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 CynSMSAPILib 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 CynSMSAPI in Group Id
and CynSMSAPILib 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 CynSMSAPILib from the package explorer.
- Select "Run -> Run as -> JUnit Test" or use "Alt + Shift + X" followed by "T" to run the Tests.
API client can be initialized as following.
CynSMSAPIClient client = new CynSMSAPIClient();
The singleton instance of the APIController
class can be accessed from the API Client.
APIController client = client.getClient();
TODO: Add a method description
void createSendSMSAsync(
final String apiKey,
final String to,
final String sms,
final String from,
final APICallBack<String> callBack)
Parameter | Tags | Description |
---|---|---|
apiKey | Required DefaultValue |
set your API_KEY from http://sms.cynojine.com/sms-api/info (user panel) |
to | Required DefaultValue |
the number we are sending to - Any phone number |
sms | Required |
SMS Body |
from | Required |
Change the from number below. It can be a valid phone number or a String |
String apiKey = "xxxxxxxxxxxxx";
String to = "260986";
String sms = "sms";
String from = "from";
// Invoking the API call with sample inputs
client.createSendSMSAsync(apiKey, to, sms, from, new APICallBack<String>() {
public void onSuccess(HttpContext context, String response) {
// TODO success callback handler
}
public void onFailure(HttpContext context, Throwable error) {
// TODO failure callback handler
}
});
Checking SMS Balance
void getBALANCECHECKAsync(
final GetBALANCECHECKInput input,
final Map<String, Object> queryParameters,
final APICallBack<Object> callBack)
Parameter | Tags | Description |
---|---|---|
apiKey | Required |
Get your account balance |
response | Required DefaultValue |
Json Responce |
queryParameters | Optional |
Additional optional query parameters are supported by this method |
GetBALANCECHECKInput collect = new GetBALANCECHECKInput();
String apiKey = "api_key";
collect.setApiKey(apiKey);
String response = "json";
collect.setResponse(response);
// key-value map for optional query parameters
Map<String, Object> queryParams = new LinkedHashMap<String, Object>();
// Invoking the API call with sample inputs
client.getBALANCECHECKAsync(collect, , queryParams, new APICallBack<void>() {
public void onSuccess(HttpContext context, void response) {
// TODO success callback handler
}
public void onFailure(HttpContext context, Throwable error) {
// TODO failure callback handler
}
}
);