Real-Time Personalization (+RTP) API Guide

Integration

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

In order to integrate it, get code from our GitHub repository and paste it into your project. Code is Perl 5.10 compatible and is OO based.

 

Perl module API

Method Purpose Arguments Description
sub new Constructor Use both arguments for creating chains instance in case reporting API is required
sub getReport Reporting API
  • 1st arg - REST endpoint name, use "StartApp" 
  • 2nd arg - name of data processing routine 
  • 3rd arg - input data identifier 
 
sub getBatchReport Batch reporting API
  • 1st arg - REST endpoint name, use "StartAppBatch" 
  • 2nd arg - hashref, key should be chain identifier, value - file identifier 
 

 

Code snippet

Adding code to the project:

  • Add AppChains.pm into your source folder and import AppChains in your Perl file (use AppChains;).

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

my $chains = AppChains->new("<your token>", "api.sequencing.com");
my $chainsResult = $chains->getReport("StartApp", "<chain id>", "<file id>");
 
if ($chainsResult->isSucceeded()) {
    print "Request has succeeded\n";
} else {
    print "Request has failed\n";
}
 
foreach (@{$chainsResult->getResults()})
{
    my $type = $_->getValue()->getType();
 
    if ($type == ResultType->TEXT)
    {
        my $v = $_->getValue();
        print sprintf("-> text result type %s = %s\n", $_->getName(), $v->getData());
    }
    elsif ($type == ResultType->FILE)
    {
        my $v = $_->getValue();
        print sprintf(" -> file result type %s = %s\n", $_->getName(), $v->getUrl());
        $v->saveTo("/tmp");
    }
}

Batch App Chain retrieval example

my $chains = AppChains->new("<your token goes here>", "api.sequencing.com");

# batch result retrieval
my %chainsSpec = ("Chain9" => "227680", "Chain88" => "227680");
my $out = $chains->getBatchReport("StartAppBatch", \%chainsSpec);

foreach (keys %$out)
{
    my $cr = $out->{$_};
    print "-> Chain ID: " . $_ . "\n";
    handleAppChainResult($cr);
    print "\n\n";
}