Documentation

Ginota's Java SDK

Ginota's Java SDK simplifies the process to create HTTP requests to Ginota's API.

 

Prerequisites

Java SE Development Kit (JDK) version 6 or above (download from Oracle download centre).

 

Download Ginota's Java SDK

In order to start using Ginota's Java SDK, you have to download the Java SDK compressed package:

The compressed package includes:

  • JAR with dependencies
    • ginota-sdk-1.x-with-dependencies.jar
  • JAR without dependencies (use this when you encountered conflicting jars in your project.)
    • ginota-sdk-1.x.jar
  • Dependencies of Ginota's Java SDK
    • located under lib folder
  • Javadoc
    • located under javadoc folder
  • Source Code with Examples
    • located under src folder

 

Installation of Ginota's Java SDK

First, you need to copy the JAR with/without dependencies into your application and ensure that it is configured correctly in your classpath. To begin using JAR without dependencies, you are required to copy all the JAR files under “lib” into your application.

 

Quick Start Example - Send a SMS

Once installation of Ginota's Java SDK is completed, you may verify it via the following quick start example. Try sending yourself a SMS now!


import com.ginota.sdk.client.GinotaRestClient;
import com.ginota.sdk.client.GinotaRestResponse;
import com.ginota.sdk.client.GinotaSmsRequest;
import com.ginota.sdk.message.MessageFactory;
import com.ginota.sdk.message.MobileMessage;

public class SendMessage {

    private final static String API_KEY = "specify your api key here";
    private final static String API_SECRET = "specify your api secret here";
    private final static String DEST_ADDR = "60122772595";
    private final static String SRC_ADDR = "MyCompany";

    public static void main(String[] args) {
        try {
            //Construct a Text SMS using Message Factory
            MobileMessage smsTextMessage = MessageFactory.getInstance().constructTextSms(SRC_ADDR, DEST_ADDR, "Welcome to Ginota.");
            //Create a Ginota SMS Request
            GinotaSmsRequest ginotaSmsRequest = new GinotaSmsRequest(API_KEY, API_SECRET, smsTextMessage);
            //Make a POST call to Ginota!
            GinotaRestResponse ginotaRestResponse = GinotaRestClient.getInstance().request(ginotaSmsRequest, true);
        } catch (Exception ex) {
            System.err.println("Failed to send Ginota SMS Request");
            ex.printStackTrace();
        }
    }
}


Note: The example can also be seen in this class: com.ginota.sdk.examples.SendMessage.

 

Handling the Return Response

Ginota's Java SDK helps you to wrap the JSON response into Java Map object. This is how you can obtain the Ginota's API Response attributes from GinotaRestResponse object class:


//Make a POST call to Ginota!
GinotaRestResponse ginotaRestResponse = GinotaRestClient.getInstance().request(ginotaSmsRequest, true);
//Wrap to Map object
Map<String, Object> results = ginotaRestResponse.toMap();
//Obtain response attributes
System.out.println("[Status] = " + results.get("status"));
System.out.println("[MessageId] = " + results.get("messageId"));
System.out.println("[Parts] = " + results.get("parts"));
if (results.containsKey("txnRef")) {
	System.out.println("[TxnRef] = " + results.get("txnRef"));
}

 

Learn More

For details about the methods and classes contained in the Ginota's Java SDK, you may refer to the javadoc folder. Additionally, you can also browse through the source code of the SDK.

 

Dependencies of Ginota's Java SDK

Following are the dependencies libraries used by Ginota's Java SDK:

LibraryVersionJAR files
Apache HTTP Client 4.3.5 httpclient-4.3.5.jar
httpcore-4.3.2.jar
commons-logging-1.1.3.jar
commons-codec-1.6.jar
Apache Commons Lang 3.3.2 commons-lang3-3.3.2.jar
FasterXML Jackson 2.3 jackson-core-2.3.1.jar
jackson-databind-2.3.3.jar
jackson-annotations-2.3.0.jar

Subscribe today and get a free trial

GET ME CONNECTED!

No credit cards required