File Coverage

blib/lib/WebService/PayPal/NVP/Response.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 8 0.0
condition 0 3 0.0
subroutine 2 6 33.3
pod 1 4 25.0
total 9 47 19.1


line stmt bran cond sub pod time code
1             package WebService::PayPal::NVP::Response;
2              
3 5     5   24 use Moo;
  5         6  
  5         41  
4             has 'success' => ( is => 'rw', default => sub { 0 } );
5             has 'errors' => ( is => 'rw', default => sub { [] } );
6             has 'branch' => ( is => 'rw', isa => sub {
7             die "Response branch expects 'live' or 'sandbox' only\n"
8             if $_[0] ne 'live' and $_[0] ne 'sandbox';
9             } );
10              
11             sub express_checkout_uri {
12 0     0 0   my ($self) = @_;
13 0 0         if ($self->can('token')) {
14 0 0         my $www = $self->branch eq 'live' ?
15             'www' : 'www.sandbox';
16 0           return "https://${www}.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" .
17             $self->token . "&useraction=commit";
18             }
19              
20 0           return;
21             }
22              
23             sub has_arg {
24 0     0 0   my ($self, $arg) = @_;
25 0           return $self->can($arg);
26             }
27              
28             sub has_errors {
29 0     0 1   my $self = shift;
30 0           return scalar @{$self->errors} > 0;
  0            
31             }
32              
33             sub args {
34 0     0 0   my ($self) = @_;
35 0           my @moothods = qw/
36             around before can after
37             import with new has
38             options errors extends
39             /;
40 0           my @options;
41 5         701 listmethods: {
42 5     5   2650 no strict 'refs';
  5         7  
  0            
43 0           foreach my $key (keys %{"WebService::PayPal::NVP::Response::"}) {
  0            
44 0 0 0       if ($key =~ /^[a-z]/ and not grep { $_ eq $key } @moothods) {
  0            
45 0           push @options, $key;
46             }
47             }
48             }
49              
50 0 0         return wantarray ? @options : \@options;
51             }
52              
53             1;
54             __END__