Client.pm

filter: Statementstmt 76.2% 61 / 80 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 16 / 18 Podpod 100% 1 / 1 totaltotal 70.2% 78 / 111 CC 10 SCAR 20.6
CC
10
Cov
66%
submit
30.0
_finalize_request
12.0
_build_calls
2.0
CRAP 7.8
↑ Summary Request/ProcessCard.pm »
1 package Business::PaperlessTrans::Client;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.002000'; # VERSION
7  
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Class::Load 0.20 'load_class';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Data::Printer alias => 'Dumper';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use MooseX::Types::Path::Class qw( File Dir );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use File::ShareDir::ProjectDistDir qw( dist_file dist_dir );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use XML::Compile::WSDL11;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use XML::Compile::SOAP11;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use XML::Compile::Transport::SOAPHTTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 with 'MooseY::RemoteHelper::Role::Client';
21  
22 0 ▶sub submit {
Subroutine submit: not called CC=5 SCAR=34.0
Pod documented
23 0 my ( $self, $request ) = @_;
24  
25 0 my %request = %{ $self->_finalize_request( $request ) };
26  
27 0 ▶ Dumper %request if $self->debug >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug >= 1 0 0 0
28  
29 0 my ( $answer, $trace ) = $self->_get_call( $request->type )->( %request );
30  
31 0 ▶ carp "REQUEST >\n" . $trace->request->as_string if $self->debug > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug > 1 0 0 0
32 0 ▶ carp "RESPONSE <\n" . $trace->response->as_string if $self->debug > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug > 1 0 0 0
33  
34 0 ▶ Dumper $answer if $self->debug >= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug >= 1 0 0 0
35  
36 0 my $res = $answer->{parameters}{$request->type . 'Result'};
37  
38 0 my $res_c = 'Business::PaperlessTrans::Response::' . $request->type;
39  
40 0 return load_class( $res_c )->new( $res );
41 }
42  
43 0 ▶sub _finalize_request {
Subroutine _finalize_request: not called CC=3 SCAR=24.8
44 0 my ( $self, $request ) = @_;
45  
46 0 my %request;
47 0 ▶ if ( $request->type eq 'TestConnection' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($request->type eq 'TestConnection') { } 0 0 0
48 0 %request = ( %{ $request->serialize },
49 token => {
50 TerminalID => $self->user,
51 TerminalKey => $self->pass,
52 },
53 );
54 }
55 else {
56 %request = ( req => {
57 0 ▶ %{ $request->serialize },
Branch: 1 branch
BranchTrueFalseTotal
$self->test ? : 0 0 0
58 Token => {
59 TerminalID => $self->user,
60 TerminalKey => $self->pass,
61 },
62 TestMode => $self->test ? 'True' : 'False',
63 });
64 }
65  
66 0 return \%request;
67 }
68  
69 1 ▶sub _build_calls {
Subroutine _build_calls: called CC=2 SCAR=6.9
70 1 my $self = shift;
71  
72 1 my @calls = qw( TestConnection AuthorizeCard ProcessCard ProcessACH );
73  
74 1 my %calls;
75 1 foreach my $call ( @calls ) {
76 4 $calls{$call} = $self->_wsdl->compileClient( $call );
77 }
78 1 return \%calls;
79 }
80  
81 1 ▶sub _build_wsdl {
Subroutine _build_wsdl: called CC=2 SCAR=6.9
82 1 my $self = shift;
83  
84 1 my $wsdl
85 = XML::Compile::WSDL11->new(
86 $self->_wsdl_file->stringify,
87 );
88  
89 1 foreach my $xsd ( $self->_list_xsd_files ) {
90 7 $wsdl->importDefinitions( $xsd->stringify );
91 }
92  
93 1 return $wsdl;
94 }
95  
96 1 ▶sub _build_wsdl_file {
Subroutine _build_wsdl_file: called CC=1 SCAR=0.0
97 1 return load_class('Path::Class::File')->new(
98 dist_file(
99 'Business-PaperlessTrans',
100 'svc.paperlesstrans.wsdl'
101 )
102 );
103 }
104  
105 1 ▶sub _build_xsd_files {
Subroutine _build_xsd_files: called CC=2 SCAR=6.9
106 1 my @xsd;
107 1 foreach ( 0..6 ) {
108 7 my $file
109 = load_class('Path::Class::File')->new(
110 dist_file(
111 'Business-PaperlessTrans',
112 "svc.paperlesstrans.$_.xsd"
113 )
114 );
115  
116 7 push @xsd, $file;
117 }
118 1 return \@xsd;
119 }
120  
121 1 has _calls => (
122 isa => 'HashRef',
123 traits => ['Hash'],
124 is => 'rw',
125 lazy => 1,
126 builder => '_build_calls',
127 handles => {
128 _get_call => 'get',
129 },
130 );
131  
132 1 has _wsdl => (
133 isa => 'XML::Compile::WSDL11',
134 is => 'ro',
135 lazy => 1,
136 builder => '_build_wsdl'
137 );
138  
139 1 has _wsdl_file => (
140 isa => File,
141 lazy => 1,
142 is => 'ro',
143 builder => '_build_wsdl_file',
144 );
145  
146 1 has _xsd_files => (
147 isa => 'ArrayRef[Path::Class::File]',
148 traits => ['Array'],
149 lazy => 1,
150 is => 'ro',
151 builder => '_build_xsd_files',
152 handles => {
153 _list_xsd_files => 'elements',
154 },
155 );
156  
157 1 __PACKAGE__->meta->make_immutable;
158 1 1;
159 # ABSTRACT: PaperlessTrans Client object
160  
161 __END__
↑ Summary Request/ProcessCard.pm »