12th Aug 2019

Perl

The official Talon.One Perl SDK can be found at https://github.com/talon-one/TalonOne.pm. The SDK supports the Integration API and Management API, and can be used on any Perl from 5.8.8 onwards.

my $subdomain = 'demo';
my $appkey = 'fefecafedeadbeef';
my $appid = 1;

GetOptions ("appid=i" => \$appid,
            "subdomain=s" => \$subdomain,
            "appkey=s"    => \$appkey);

my $talon = new TalonOne($subdomain, $appid, $appkey);

my %effect_handlers;

$effect_handlers{rejectCoupon} = sub {
        my ($response, @args) = @_;
        my $coupon = $args[0];
        print "Invalid coupon: $coupon\n";
};

$effect_handlers{acceptCoupon} = sub {
        my ($response, @args) = @_;
        print "Valid coupon: @args\n";
};

$effect_handlers{setDiscount} = sub {
        my ($response, @args) = @_;
        print "Set discount: @args\n";
};

my ($ok, $response) = $talon->PUT("customer_profiles/testprofile1234", 
                                  {'attributes' => {'Email' => 'happycustomer@example.org'},
                                   'advocateId' => 'friendid2345'}, 
                                   \%effect_handlers);

my ($ok, $response) = $talon->PUT("customer_sessions/testsession1234", 
                                  {'attributes' => {},
                                   'coupon' => 'DEMO-AWAU-TAYA',
                                   # Set state to 'closed' when the order is completed
                                   'state' => 'open'}, 
                                   \%effect_handlers);
Still need help? Get in touch!
Last updated on 12th Aug 2019

Was this article helpful?

Thank you! You have already voted

If you’d like a member of our support team to respond to you, please send a note to support@talon.one

On this page