API-Drip-Request
view release on metacpan or search on metacpan
bin/drip_client.pl view on Meta::CPAN
=head2 Operations
=over
=item B<getsub>
Get a list of all subscribers.
=item B<addsub>
Add a subscriber. At a minimum, must also specify -email, or -id.
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.
Requires: -email or -id, -action
Accepts: -prospect
=back
=head2 Additional Parameters
The parameters B<-email>, B<-id>, B<-new_email>, B<-user_id>, B<-time_zone>,
B<-lifetime_vaule>, B<-ip_address>, B<-prospect>, B<-action> are documented at
L<https://www.getdrip.com/docs/rest-api> and may be used with the above
operations.
=over
=item B<workflow>
Integer ID of a workflow.
=back
=head1 DESCRIPTION
B<drip_client.pl> is a command-line interface to the API::Drip library. It's
a handy way to verify your connection to Drip is working as expected, and
possibly to do some light-weight manipulation of your data.
=cut
use v5.14;
use strict;
use lib '/usr/pair/perl/lib';
use Pair::Result ':all';
use Data::Printer;
use Getopt::Long;
use Pod::Usage;
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 {
my %OPT = @_;
$OPT{email} or $OPT{id} or pod2usage( "Either -email or -id is required for -event" );
$OPT{action} or pod2usage( "-action is required for -event" );
my $content = _build_hash( %OPT, keys => [qw(email id action prospect)] );
my $result = $client->do_request( POST => 'events', { events => [ $content ] } );
p $result;
}
( run in 0.826 second using v1.01-cache-2.11-cpan-39bf76dae61 )