Dubber-API
view release on metacpan or search on metacpan
lib/Dubber/API.pm view on Meta::CPAN
push( @etag_parts, { part_number => $part_number, e_tag => $put_response->header('ETag') } );
}
else {
die "Unable to PUT recording upload - $!";
}
}
else {
die "Unable to request recording upload - $!";
}
}
$return_status = $self->put_complete_multipart_recording_upload(
recording_id => $recording_id,
parts => \@etag_parts
);
}
catch {
# it failed - delete the part uploaded chunk
$self->abort_multipart_recording_upload( recording_id => $recording_id );
};
return $return_status;
}
return $res;
}
# ------------------------------------------------------------------------
method _split_recording_data ($file_or_data) {
my $data;
if ( ref($file_or_data) and $file_or_data->isa('Path::Tiny') ) {
my $stat = $file_or_data->stat or die "File $file_or_data does not exist - $!\n";
$data = $file_or_data->slurp_raw;
}
else {
$data = $file_or_data;
}
# split into chunks of $max_part_size
my $template =
sprintf( 'A%d', $self->max_part_size ) x int( length($data) / $self->max_part_size )
. ( length($data) % $self->max_part_size )
? 'A*'
: '';
my @chunks = unpack( $template, $data );
return @chunks;
}
# ------------------------------------------------------------------------
method BUILD ($args) {
$self->user_agent( __PACKAGE__ . ' ' . ( $Dubber::API::VERSION || '' ) );
$self->base_url( 'https://api.dubber.net/' . $self->region . '/v' . $self->api_version );
$self->content_type('application/json');
$self->decoder( sub { $self->json_coder->decode( shift || '{}' ) } );
}
# ------------------------------------------------------------------------
method _build_agent () {
return LWP::UserAgent->new(
agent => $self->user_agent,
cookie_jar => $self->cookies,
timeout => $self->timeout,
con_cache => $self->connection_cache,
keep_alive => 1,
ssl_opts => { verify_hostname => $self->strict_ssl },
);
}
# ------------------------------------------------------------------------
method _clear_state () { $self->clear_decoded_response; $self->clear_response; }
# ------------------------------------------------------------------------
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Dubber::API - Interact with the Dubber Call Recording platform API
=head1 VERSION
version 0.011
This is undocumented to an amazing degree at present!
=head1 AUTHOR
Nigel Metheringham <nigelm@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Nigel Metheringham.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.516 second using v1.01-cache-2.11-cpan-39bf76dae61 )