File Coverage

blib/lib/Akamai/Open/Request.pm
Criterion Covered Total %
statement 8 10 80.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 12 14 85.7


line stmt bran cond sub pod time code
1             package Akamai::Open::Request;
2             BEGIN {
3 1     1   25122 $Akamai::Open::Request::AUTHORITY = 'cpan:PROBST';
4             }
5             # ABSTRACT: The request handler for the Akamai Open API Perl clients
6             $Akamai::Open::Request::VERSION = '0.03';
7 1     1   9 use strict;
  1         3  
  1         39  
8 1     1   6 use warnings;
  1         2  
  1         32  
9              
10 1     1   522 use Moose;
  0            
  0            
11             use Data::UUID;
12             use POSIX qw(strftime);
13             use HTTP::Request;
14             use LWP::UserAgent;
15             use Akamai::Open::Debug;
16              
17             use constant USER_AGENT => "Akamai::Open::Client/Perl-$^V";
18              
19             has 'debug' => (is => 'rw', default => sub{ return(Akamai::Open::Debug->instance());});
20             has 'nonce' => (is => 'rw', isa => 'Str', default => \&gen_uuid, trigger => \&Akamai::Open::Debug::debugger);
21             has 'timestamp' => (is => 'rw', isa => 'Str', default => \&gen_timestamp, trigger => \&Akamai::Open::Debug::debugger);
22             has 'request' => (is => 'rw', default => sub{return(HTTP::Request->new());});
23             has 'response' => (is => 'rw', trigger => \&Akamai::Open::Debug::debugger);
24             has 'user_agent'=> (is => 'rw', default => sub {
25             my $agent = LWP::UserAgent->new();
26             $agent->timeout(600);
27             $agent->agent(USER_AGENT);
28             return($agent);
29             });
30              
31             sub gen_timestamp {
32             return(strftime('%Y%m%dT%H:%M:%S%z', gmtime()));
33             }
34             sub gen_uuid {
35             return(Data::UUID->new->create_str());
36             }
37              
38             1;
39              
40             __END__
41              
42             =pod
43              
44             =encoding utf-8
45              
46             =head1 NAME
47              
48             Akamai::Open::Request - The request handler for the Akamai Open API Perl clients
49              
50             =head1 VERSION
51              
52             version 0.03
53              
54             =head1 ABOUT
55              
56             I<Akamai::Open::Request> is the internal used request
57             handler, based on I<HTTP::Request> and I<LWP::UserAgent>.
58              
59             =head1 AUTHOR
60              
61             Martin Probst <internet+cpan@megamaddin.org>
62              
63             =head1 COPYRIGHT AND LICENSE
64              
65             This software is copyright (c) 2014 by Martin Probst.
66              
67             This is free software; you can redistribute it and/or modify it under
68             the same terms as the Perl 5 programming language system itself.
69              
70             =cut