AppChains Integration using C# | Sequencing.com

Real-Time Personalization (+RTP) API Guide

Integration

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

There are 2 ways of achiving this:

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

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

For Nuget, search and add "Sequencing.AppChainsSample" dependency. If you are new to Nuget, see detailed guide here.

 

C# module API

Method Purpose Arguments Description
public AppChains(string token, string chainsUrl, string beaconsUrl) Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
public Report GetReport(string applicationMethodName, string datasourceId) Reporting API
  • applicationMethodName - name of data processing routine 
  • datasourceId - input data identifier 
 
public Dictionary<string, Report> GetReportBatch(Dictionary<string, string> appChainsParams) Batch reporting API

Dictionary with App Chain request parameters.

  • Key is chain identifier
  • Value is file identifier
 

 

Code snippet

Adding code to the project:

  • Add Newtonsoft.Json and RestSharp nuget packages into your project

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

 

Single App Chain retrieval example

var chains = new AppChains("<your token>", "https://api.sequencing.com/v1", "https://beacon.sequencing.com/");
 
Report result = chains.GetReport("Chain9", "227680");
if (result.Succeeded == false)
    Console.WriteLine("Request has failed");
else
    Console.WriteLine("Request has succeeded");
foreach (Result r in result.getResults())
{
    ResultType type = r.getValue().getType();
 
    if (type == ResultType.TEXT)
    {
        var v = (TextResultValue) r.getValue();
        Console.WriteLine(" -> text result type {0} = {1}", r.getName(), v.Data);
    }
 
    if (type == ResultType.FILE)
    {
        var v = (FileResultValue) r.getValue();
        Console.WriteLine(" -> file result type {0} = {1}", r.getName(), v.Url);
        v.saveTo("<your token>", ".\\");
    }
}

 

Batch App Chain retrieval example

var chains = new AppChains("<your token>", "https://api.sequencing.com/v1", "https://beacon.sequencing.com/");

// retrieving multiple chain results
var appChainsParms = new Dictionary<string, string>();
appChainsParms["Chain9"] = "227680";
appChainsParms["Chain88"] = "227680";

var jobReports = chains.GetReportBatch(appChainsParms);
PrintReport("<your token goes here>", jobReports["Chain9"]);
PrintReport("<your token goes here>", jobReports["Chain88"]);