Conductrics Client
This class give access to Conductrics Management API to:
- define - create - delete
an agent.
At start, I've written this class to automate tests of Conductrics::Agent, the user has not to learn how to create agent in Conductrics console before to run tests of Conductrics::Agent.
With this class you can automate the agent definition, use your data to create them in programmatic way, and I'm sure that it's better and powerfull.
use Conductrics::Client; my $client = Conductrics::Client->new( apiKey=>'', # place your managent (admin) apikey here ownerCode=>'', # place your ownerCode here baseUrl=>'http://api.conductrics.com', ); # # An agent will make decisions on the conductrics server. # my $decision_points = [ $client->define_decision_point( 'home_page', $client->define_decision( 'colour', qw/red green blue/ ), $client->define_decision( 'font', qw/arial verdana/ ) ), $client->define_decision_point( 'auction', $client->define_decision( 'message_mood', qw/estatic happy gambling/ ), $client->define_decision( 'sort_by', qw/price time/ ) ), ]; my $goals = $client->define_goals(qw/ registration bet sold subscription /); my $main_site_definition = $client->define_agent('main_site', $goals, $decision_points); unless ($client->validate_agent($client->get_json_schema, $main_site_definition)) { die("agent defition is not valid for agent json schema"); } if ($client->create_agent('main_site', $main_site_definition)) { ... # success: agent is ready on conductrics server }
From another script/program you can then use the agent:
my $agent = Conductrics::Agent->new( name=>'main_site', apiKey=>'', # place your runtime apikey here ownerCode=>'', # place your ownerCode here baseUrl=>'http://api.conductrics.com', ); ... see Conductrics::Agent documentation
$content can be a json description of the Agent according the agent json schema.
create_agent('test-agent', $json);
$json contains json agent description
create_agent('test-agent', $hashref);
$hashref contains agent descrition as Perl structure that will be encoded to json.
you can provide list of names: $client->define_goals('micky mouse','pluto');
or can provide a list of hashref: $client->define_goals({name=>'micky mouse'}.{name=>'pluto'});
with codes too: $client->define_goals({code=>1, name=>'micky mouse'}.{code=>2, name=>'pluto'});
or calling define_goal()
$client->define_goals($client->define_goal('micky mouse', 1), $client->define_goal('pluto', 2));
or calling define_goal() with settings
$client->define_goals($client->define_goal('micky mouse', 1, {min=>1, max=>5, default=>0, limit=>3}), $client->define_goal('pluto', 2, {min=>1, max=>2, default=>1, limit=>5}));
Look for goal's setting in help conductrics manual, for more info and their meanings.
You can define a goals with more details.
It gets json schema for agent definition.
It validates json against json schema.
You have to set some env to execute t/02-define_agent.t You will find your data into Account/Keys and Users page.
Required env for execute full test's suite:
Conductrics_apikey Conductrics_ownerCode Conductrics_Mng_apikey admin/management apikey
Test's sources are good examples about how to use this API, so "Use The Source Luke".
Conductrics has many help pages available from the console, so signup and read it.
http://conductrics.com/
There are also Report API, Management API and Targetting Rule API.
Ferruccio Zamuner - nonsolosoft@diff.org
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
To install Conductrics::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Conductrics::Client
CPAN shell
perl -MCPAN -e shell install Conductrics::Client
For more information on module installation, please visit the detailed CPAN module installation guide.