API-Drip-Request

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for API-Drip

0.05    8/29/17
        Added Github information to meta and updated bug reporting location.
        Please submit an issue via Github.

0.04    8/29/17
        Fixed tests

0.03    8/24/17
        Fixed bug when the endpoint contains slashes.
        Added more options to drip.pl

0.02    8/23/17
        Adding dependencies in Build.PL.   We might need those.

0.01    8/23/17
        First version, released on an unsuspecting world.

bin/drip_client.pl  view on Meta::CPAN

    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;
}


sub delete_subscribers {
    my %OPT = @_;
    my $id = $OPT{email} || $OPT{id};

    die "email or id required in delete subscriber" unless $id;

lib/API/Drip/Request.pm  view on Meta::CPAN

On success, returns a Perl data structure corresponding to the data returned
from the server.    Some operations (DELETE), do not return any data and may
return undef on success.  On error, this method will die() with the
HTTP::Response object.

=cut

my $request_validator = validation_for( params => [ {type => Str()}, {type => Str()}, {type => HashRef(), optional => 1} ] );
sub do_request {
    my $self = shift;
    my ($method, $endpoint, $content) = $request_validator->(@_);

    my $uri = URI->new($self->{DRIP_URI});
    $uri->path_segments( $uri->path_segments, $self->{DRIP_ID}, split( '/', $endpoint) );

    $self->{debugger}->( 'Requesting: ' . $uri->as_string );
    my $request = HTTP::Request->new( $method => $uri->as_string, );
    if ( ref($content) ) {
        $request->content_type('application/vnd.api+json');
        $request->content( encode_json( $content ) );
    }
    $request->authorization_basic( $self->{DRIP_TOKEN}, '' );

    $self->{agent} //= LWP::UserAgent->new( agent => $self->{DRIP_AGENT} );

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.690 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )