File Coverage

blib/lib/Business/CyberSource/Factory/Response.pm
Criterion Covered Total %
statement 31 32 96.8
branch 2 4 50.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 1 1 100.0
total 45 50 90.0


line stmt bran cond sub pod time code
1             package Business::CyberSource::Factory::Response;
2 1     1   564 use 5.010;
  1         2  
3 1     1   3 use strict;
  1         1  
  1         18  
4 1     1   3 use warnings;
  1         1  
  1         25  
5 1     1   390 use namespace::autoclean;
  1         5244  
  1         5  
6              
7             our $VERSION = '0.010007'; # VERSION
8              
9 1     1   538 use Moose;
  1         198460  
  1         5  
10 1     1   4461 use Module::Runtime qw( use_module );
  1         1  
  1         4  
11 1     1   619 use Type::Params qw( compile Invocant );
  1         53269  
  1         8  
12 1     1   192 use Types::Standard qw( HashRef Optional );
  1         1  
  1         4  
13 1     1   760 use Type::Utils 0.040 qw( role_type );
  1         3163  
  1         6  
14              
15             sub create { ## no critic ( RequireArgUnpacking )
16 1     1 1 1048 state $traceable = role_type 'Business::CyberSource::Role::Traceable';
17 1         1231 state $check = compile( Invocant, HashRef, Optional[$traceable]);
18 1         2499 my ( $self, $result , $request ) = $check->( @_ );
19              
20             $result->{http_trace}
21 1 50 33     49 = $request->http_trace
22             if $request && $request->has_http_trace;
23              
24             die ## no critic ( ErrorHandling::RequireCarping )
25             use_module('Business::CyberSource::Exception::Response')
26 1 50       6 ->new( $result ) if $result->{decision} eq 'ERROR';
27              
28 0           return use_module('Business::CyberSource::Response')->new( $result );
29             }
30              
31             1;
32              
33             # ABSTRACT: A Response Factory
34              
35             __END__
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Business::CyberSource::Factory::Response - A Response Factory
44              
45             =head1 VERSION
46              
47             version 0.010007
48              
49             =head1 METHODS
50              
51             =head2 create
52              
53             my $response = $factory->create( $answer->{result}, $request );
54              
55             Pass the C<answer->{result}> from L<XML::Compile::SOAP> and the original Request Data
56             Transfer Object. Passing a L<Business::CyberSource::Request> is now optional.
57              
58             =head1 BUGS
59              
60             Please report any bugs or feature requests on the bugtracker website
61             https://github.com/xenoterracide/business-cybersource/issues
62              
63             When submitting a bug or request, please include a test-file or a
64             patch to an existing test-file that illustrates the bug or desired
65             feature.
66              
67             =head1 AUTHOR
68              
69             Caleb Cushing <xenoterracide@gmail.com>
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             This software is Copyright (c) 2016 by Caleb Cushing <xenoterracide@gmail.com>.
74              
75             This is free software, licensed under:
76              
77             The Artistic License 2.0 (GPL Compatible)
78              
79             =cut