Skip to content

selcompaytechltd/selcom-apigw-client-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selcom API Gateway Client - JAVA

Homepage

https://developers.selcommobile.com/

Description

This is a library containing functions that aid in the accessing of selcom api.

Installation

Get Snippet for relevant package manager from https://central.sonatype.com/artifact/io.github.selcompaytechltd/apigwClient/1.0.0/overview

or search for io.github.selcompaytechltd/apigwClient using package manager

Use

//use package
import io.github.selcompaytechltd.ApigwClient;

//// initalize a new apiAccess instace with values of the base url, api key and api secret

ApigwClient client = new ApigwClient(baseUrl, apiKey, apiSecret);

// computeHeader a dictionary containing data to bes submitted
// computeHeader returns an array with values for the following header fields: 
// Authorization, Timestamp, Digest, Signed-Fields
client.computeHeader( jsonData):

// postFuct takes relative path to base url. a JSONObject containing data to be submitted 
// It performs a POST request of the submitted data to the destniation url generatingg the header internally
// IT returns a JSONObject containing the response data to the request
client.postFunc(path, jsonData)

// getFuct takestakes relative path to base url. a JSONObject containing data to be submitted  
// It performs a GET request adding the query to the  url and generatingg the header internally
// IT returns a SJSONObject containing the response data to the request
client.getFunc(path, jsonData)

// deletetFuct takes relative path to base url.a JSONObject containing data to be submitted 
// It performs a DELETE request adding the query to the  url and generatingg the header internally
// IT returns a JSONObject containing the response data to the request
client.deleteFunc(path, jsonData)

Examples

//import package
import io.github.selcompaytechltd.ApigwClient;
import java.util.Map;
import com.google.gson.*;s

String apiKey = '202cb962ac59075b964b07152d234b70';
String apiSecret = '81dc9bdb52d04dc20036dbd8313ed055';
String baseUrl = "http://example.com";



// initalize a new Client instace with values of the base url, api key and api secret
Client client = new ApigwClient(baseUrl,apiKey,apiSecret);

// path relatiive to base url
String orderPath = "/v1/checkout/create-order-minimal";

//order data
JsonObject orderDict = new JsonObject();
orderDict.addProperty("vendor","VENDORTILL");
orderDict.addProperty("order_id","1218d00Y");
orderDict.addProperty("buyer_email", "john@example.com");
orderDict.addProperty("buyer_name", "John Joh");
orderDict.addProperty("buyer_phone", "255682555555");
orderDict.addProperty("amount",  8000);
orderDict.addProperty("currency","TZS");
orderDict.addProperty("buyer_remarks","None");
orderDict.addProperty("merchant_remarks","None");
orderDict.addProperty("no_of_items", 1 );

//post data
JsonObject response = client.postFunc(orderPath ,orderDict);
// print response
System.out.println(response);

About

selcom-apigw-client-java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages