Business/CyberSource/Request.pm

filter: Statementstmt 86.7% 46 / 53 Branchbran 33.3% 2 / 6 Conditioncond 55.5% 5 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 90.9% 10 / 11 Podpod 100% 1 / 1 totaltotal 77.6% 66 / 85 CC 7 SCAR 18.2
CC
7
Cov
78%
add_item
20.0
__ANON__
4.0
BEGIN
1.0
CRAP 6.2
« Business/CyberSource/Rule/RequestIDisZero.pm ↑ Summary Business/CyberSource/RequestPart/Card.pm »
1 package Business::CyberSource::Request;
2 17 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 our $VERSION = '0.010007'; # VERSION
8  
9 17 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 17 extends 'Business::CyberSource::Message';
11 17 with qw(
12 MooseX::RemoteHelper::CompositeSerialization
13 );
14  
15 17 ▶use MooseX::Types::CyberSource qw( PurchaseTotals Service Items );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 17 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 17 our @CARP_NOT = ( 'Class::MOP::Method::Wrapped', __PACKAGE__ );
20  
21 before serialize => sub { ## no critic qw( Subroutines::RequireFinalReturn )
22 10 ▶ my $self = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
23  
24 10 ▶ if ( ! $self->has_total && ( ! $self->has_items || $self->items_is_empty ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->has_total and !$self->has_items || $self->items_is_empty) 1 9 10
Condition83%5/6
not $self->has_total and !$self->has_items || $self->items_is_empty
!ll&&!rl&&r
811
not $self->has_items or $self->items_is_empty
l!l&&r!l&&!r
101
MC/DC66%2/3
not $self->has_total and !$self->has_items || $self->items_is_empty
not $self->has_total not $self->has_items $self->items_is_empty
Truth table75%3/4
not(A) and not(B) or C
A= not $self->has_totalB= not $self->has_itemsC= $self->items_is_empty
ABCresult
0XX0
1000
11X1
1011
25 1 die ## no critic ( ErrorHandling::RequireCarping )
26 use_module('Business::CyberSource::Exception::ItemsOrTotal')->new;
27 }
28 17 };
29  
30 sub add_item {
31 0 ▶ my ( $self, $args ) = @_;
Subroutine add_item: not called CC=4 SCAR=30.0
Pod documented
32  
33 0 my $item;
34 0 ▶ unless ( blessed $args
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($args) and $args->isa('Business::CyberSource::RequestPart::Item')) { } 0 0 0
Condition0%0/3
builtin::blessed($args) and $args->isa("Business::CyberSource::RequestPart::Item")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($args) and $args->isa("Business::CyberSource::RequestPart::Item")
builtin::blessed($args) $args->isa("Business::CyberSource::RequestPart::Item")
Truth table0%0/3
A and B
A= builtin::blessed($args)B= $args->isa("Business::CyberSource::RequestPart::Item")
ABresult
0X0
100
111
35 && $args->isa( 'Business::CyberSource::RequestPart::Item' )
36 ) {
37 0 $item
38 = use_module('Business::CyberSource::RequestPart::Item')
39 ->new( $args )
40 ;
41 }
42 else {
43 0 $item = $args;
44 }
45 0 ▶ $self->items( [ ] ) if ! $self->has_items;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_items 0 0 0
46  
47 0 return $self->_push_item( $item );
48 }
49  
50 sub _build_service {
51 1 ▶ return use_module('Business::CyberSource::RequestPart::Service')->new;
Subroutine _build_service: called CC=1 SCAR=0.0
52 }
53  
54 17 has comments => (
55 remote_name => 'comments',
56 isa => 'Str',
57 traits => ['SetOnce'],
58 is => 'rw',
59 );
60  
61 17 has service => (
62 isa => Service,
63 is => 'ro',
64 lazy_build => 1,
65 required => 1,
66 coerce => 1,
67 reader => undef,
68 );
69  
70 17 has purchase_totals => (
71 isa => PurchaseTotals,
72 remote_name => 'purchaseTotals',
73 is => 'ro',
74 required => 1,
75 coerce => 1,
76 handles => [qw( total has_total )],
77 );
78  
79 has items => (
80 isa => Items,
81 remote_name => 'item',
82 predicate => 'has_items',
83 is => 'rw',
84 traits => ['Array'],
85 coerce => 1,
86 handles => {
87 items_is_empty => 'is_empty',
88 next_item => [ natatime => 1 ],
89 list_items => 'elements',
90 _push_item => 'push',
91 },
92 serializer => sub {
93 1 ▶ my ( $attr, $instance ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
94  
95 1 my $items = $attr->get_value( $instance );
96  
97 1 my $i = 0;
98 my @serialized
99 = map { ## no critic ( BuiltinFunctions::ProhibitComplexMappings )
100 2 my $item = $_->serialize;
101 2 $item->{id} = $i;
102 2 $i++;
103 2 $item
104 1 } @{ $items };
105  
106 1 return \@serialized;
107 },
108 17 );
109  
110 17 has '+http_trace' => (
111 is => 'rw',
112 init_arg => undef
113 );
114  
115 17 __PACKAGE__->meta->make_immutable;
116 17 1;
117  
118 # ABSTRACT: Abstract Request Class
119  
120 __END__
121  
122 =pod
123  
124 =encoding UTF-8
125  
126 =head1 NAME
127  
128 Business::CyberSource::Request - Abstract Request Class
129  
130 =head1 VERSION
131  
132 version 0.010007
133  
134 =head1 DESCRIPTION
135  
136 extends L<Business::CyberSource::Message>
137  
138 Here are the provided Request subclasses.
139  
140 =over
141  
142 =item * L<Authorization|Business::CyberSource::Request::Authorization>
143  
144 =item * L<AuthReversal|Business::CyberSource::Request::AuthReversal>
145  
146 =item * L<Capture|Business::CyberSource::Request::Capture>
147  
148 =item * L<Follow-On Credit|Business::CyberSource::Request::FollowOnCredit>
149  
150 =item * L<Stand Alone Credit|Business::CyberSource::Request::StandAloneCredit>
151  
152 =item * L<DCC|Business::CyberSource::Request::DCC>
153  
154 =item * L<Sale|Business::CyberSource::Request::Sale>
155  
156 =back
157  
158 I<note:> You can use the L<Business:CyberSource::Request::Credit> class but,
159 it requires traits to be applied depending on the type of request you need,
160 and thus does not currently work with the factory.
161  
162 =head1 EXTENDS
163  
164 L<Business::CyberSource::Message>
165  
166 =head1 WITH
167  
168 =over
169  
170 =item L<MooseX::RemoteHelper::CompositeSerialization>
171  
172 =back
173  
174 =head1 METHODS
175  
176 =head2 serialize
177  
178 returns a hashref suitable for passing to L<XML::Compile::SOAP>
179  
180 =head2 add_item
181  
182 Add an L<Item|Business::CyberSource::RequestPart::Item> to L<items|/"items">.
183 Accepts an item object or a hashref to construct an item object.
184  
185 an array of L<Items|MooseX::Types::CyberSource/"Items">
186  
187 =head1 ATTRIBUTES
188  
189 =head2 reference_code
190  
191 Merchant-generated order reference or tracking number. CyberSource recommends
192 that you send a unique value for each transaction so that you can perform
193 meaningful searches for the transaction.
194  
195 =head2 service
196  
197 L<Business::CyberSource::RequestPart::Service>
198  
199 =head2 purchase_totals
200  
201 L<Business::CyberSource::RequestPart::PurchaseTotals>
202  
203 =head2 items
204  
205 An array of L<Business::CyberSource::RequestPart::Item>
206  
207 =head2 comments
208  
209 Comment Field
210  
211 =for Pod::Coverage BUILD
212  
213 =head1 BUGS
214  
215 Please report any bugs or feature requests on the bugtracker website
216 https://github.com/xenoterracide/business-cybersource/issues
217  
218 When submitting a bug or request, please include a test-file or a
219 patch to an existing test-file that illustrates the bug or desired
220 feature.
221  
222 =head1 AUTHOR
223  
224 Caleb Cushing <xenoterracide@gmail.com>
225  
226 =head1 COPYRIGHT AND LICENSE
227  
228 This software is Copyright (c) 2016 by Caleb Cushing <xenoterracide@gmail.com>.
229  
230 This is free software, licensed under:
231  
232 The Artistic License 2.0 (GPL Compatible)
233  
234 =cut
« Business/CyberSource/Rule/RequestIDisZero.pm ↑ Summary Business/CyberSource/RequestPart/Card.pm »