API-Drip-Request
view release on metacpan or search on metacpan
bin/drip_client.pl view on Meta::CPAN
Accepts: -email, -id, -new_email, -user_id, -time_zone, -lifetime_value, -ip_address
=item B<delsub>
Delete a subscriber. Must specify -email, or -id.
=item B<getwork>
Get a list of all workflows.
=item B<startwork>
Start a user on a workflow
Requires: -workflow
Accepts: -email, -id, -user_id, -time_zone, -prospect
=item B<event>
Record that an event happened.
bin/drip_client.pl view on Meta::CPAN
use Readonly;
my %OPT = ( # Add defaults here.
);
GetOptions( \%OPT,
'help|h|?',
'man',
'verbose|verb|v+',
'conf=s',
'addsub', 'getsub', 'delsub', 'getwork', 'startwork', 'event',
'workflow=i', 'action=s',
'email=s', 'id=s', 'new_email=s', 'user_id=s', 'time_zone=s', 'lifetime_vaule=i', 'ip_address=s', 'prospect'
) or pod2usage(2);
pod2usage(1) if $OPT{help};
pod2usage(-exitval => 0, -verbose => 2) if $OPT{man};
p %OPT if $OPT{verbose};
use API::Drip::Request;
my $client = API::Drip::Request->new( $OPT{conf} ? ( DRIP_CLIENT_CONF => $OPT{conf} ) : () );
eval {
if ( $OPT{getsub} ) { get_subscribers() and exit }
if ( $OPT{addsub} ) { add_subscribers( %OPT ) and exit }
if ( $OPT{delsub} ) { delete_subscribers( %OPT ) and exit }
if ( $OPT{getwork} ) { get_workflows( %OPT ) and exit }
if ( $OPT{startwork} ) { start_workflow( %OPT ) and exit }
if ( $OPT{event} ) { record_event( %OPT ) and exit }
};
if ( $@ ) {
warn "Request failed:";
p $@;
}
exit;
sub record_event {
bin/drip_client.pl view on Meta::CPAN
sub get_workflows {
my %OPT = @_;
my $result = $client->do_request( GET => 'workflows' );
p $result;
}
sub start_workflow {
my %OPT = @_;
$OPT{workflow} or pod2usage( "Required parameter -workflow missing for -startwork" );
my $subscriber = _build_hash( %OPT, keys => [qw( email id user_id time_zone prospect )] );
my $endpoint = 'workflows/' . $OPT{workflow} . '/subscribers';
my $result = $client->do_request( POST => $endpoint, { subscribers => [ $subscriber ] } );
p $result;
}
( run in 0.238 second using v1.01-cache-2.11-cpan-0d8aa00de5b )