AppChains Integration using Java | Sequencing.com

Real-Time Personalization (+RTP) API Guide

Integration

Sequencing.com has already everything to simplify integration of AppChains API into your Java based project.

There are 2 ways of achiving this:

  • Get code from our GitHub repository and paste it into your project
  • Integrate using our Maven artifacts

In case you decided to copy code directly from GitHub repository make sure you also get dependencies from our pom.xml

For Maven, add following snippet to your pom.xml

<dependency>
    <groupId>com.sequencing</groupId>
    <artifactId>appchains</artifactId>
    <version>1.0.9</version>
</dependency>

 

Java module API

Method Purpose Arguments Description
public AppChains(String token, String chainsHostname) Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
public Report getReport(String remoteMethodName, String applicationMethodName, String datasourceId) Reporting API
  • remoteMethodName - REST endpoint name, use "StartApp" 
  • applicationMethodName - name of data processing routine 
  • datasourceId - input data identifier 
 
public Map<String, Report> getReportBatch(String remoteMethodName, Map<String, String> appChainsParams) Batch reporting API

Map<String,String> with App Chain request parameters:

  • Key is chain identifier
  • Value is file identifier
 

 

Code snippet

Adding code to the project:

  • Add imports to your class (import com.sequencing.appchains.AppChains.*).

For complete usage example, refer to our code in GitHub repository.

 

Single App Chain retrieval example

// Plain Java
DefaultAppChainsImpl chains = new DefaultAppChainsImpl("<your token>", "api.sequencing.com");

// Android
// AndroidAppChainsImpl chains = new AndroidAppChainsImpl("<your token>", "api.sequencing.com");

Report result = chains.getReport("StartApp", "<chain id>", "<file id>");
 
if (result.isSucceeded() == false)
    System.out.println("Request has failed");
else
    System.out.println("Request has succeeded");
 
for (Result r : result.getResults())
{
    ResultType type = r.getValue().getType();
 
    if (type == ResultType.TEXT)
    {
        TextResultValue v = (TextResultValue) r.getValue();
        System.out.println(String.format(" -> text result type %s = %s", r.getName(), v.getData()));
    }
}

 

Batch App Chain retrieval example

// Plain Java
DefaultAppChainsImpl chains = new DefaultAppChainsImpl("<your token>", "api.sequencing.com");

// Android
// AndroidAppChainsImpl chains = new AndroidAppChainsImpl("<your token>", "api.sequencing.com");

// retrieving multiple chain results
Map<String, String> appChainsParams = new HashMap<String, String>();
appChainsParams.put("Chain9",  "227680");
appChainsParams.put("Chain88", "227680");

Map<String, Report> reportMap = chains.getReportBatch("StartAppBatch", appChainsParams);
printReport(reportMap.get("Chain9"));
printReport(reportMap.get("Chain88"));