SOAP/Object.pm

filter: Statementstmt 16.1% 10 / 62 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 37.5% 3 / 8 Podpod 80.0% 4 / 5 totaltotal 14.5% 17 / 117 CC 21 SCAR 33.7
CC
21
Cov
10%
save
42.0
metaFields
42.0
load
30.0
CRAP 29.2
« SOAP/ItemDTOEx.pm ↑ Summary SOAP/API.pm »
1 package jBilling::Client::SOAP::Object;
2 1 our $VERSION = 0.02;
3 1 ▶ use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶ use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 0 ▶ sub load {
Subroutine load: not called CC=5 SCAR=34.0
Pod documented
8 0 my $self = shift;
9 0 my $response = shift;
10 0 ▶ while ( ( my $key, my $value ) = each(%$response) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$response) 0 0 0
11 0 ▶ if ( defined $value and $value ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and $value ne "") 0 0 0
Condition0%0/3
defined $value and $value ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and $value ne ""
defined $value $value ne ""
Truth table0%0/3
A and B
A= defined $valueB= $value ne ""
ABresult
0X0
100
111
12 0 ▶ if ( $self->can($key) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($key)) 0 0 0
13
14 #Set the value on the object
15 0 $self->$key($value);
16 }
17 }
18 }
19 }
20
21 0 ▶ sub getClassMethods {
Subroutine getClassMethods: not called CC=4 SCAR=30.0
Pod undocumented
22 0 my $self = shift;
23 0 my $meta = Moose::Meta::Class->initialize( ref($self) );
24 0 my $classname = ref($self);
25 0 my @methods;
26 0 for my $meth ( $meta->get_all_methods ) {
27 0 ▶ push( @methods, $meth->name )
Branch: 1 branch
BranchTrueFalseTotal
if $meth->fully_qualified_name =~ /$classname/ and not $meth->name =~ /BUILD|soapify|meta$|jbilling/ 0 0 0
Condition0%0/3
$meth->fully_qualified_name =~ /$classname/ and not $meth->name =~ /BUILD|soapify|meta$|jbilling/
!ll&&!rl&&r
000
MC/DC0%0/2
$meth->fully_qualified_name =~ /$classname/ and not $meth->name =~ /BUILD|soapify|meta$|jbilling/
$meth->fully_qualified_name =~ /$classname/ not $meth->name =~ /BUILD|soapify|meta$|jbilling/
Truth table0%0/3
A and not(B)
A= $meth->fully_qualified_name =~ /$classname/B= not $meth->name =~ /BUILD|soapify|meta$|jbilling/
ABresult
0X0
100
111
28 if ( $meth->fully_qualified_name =~ m/$classname/
29 and $meth->name !~ m/BUILD|soapify|meta$|jbilling/ );
30 }
31 0 return @methods;
32 }
33
34 0 ▶ sub save {
Subroutine save: not called CC=6 SCAR=37.4
Pod documented
35 0 my $self = shift;
36
37 0 ▶ if ( !defined $self->jbilling ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->jbilling) { } 0 0 0
38 0 throw jBilling::Client::SOAP::Exception 'No jBilling Connection';
39 }
40 else {
41 0 ▶ if ( ref($self) =~ m/OrderWS$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($self) =~ /OrderWS$/) 0 0 0
42
43 #this is an Order object
44 0 ▶ if ( defined $self->id ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->id) { } 0 0 0
elsif (not defined $self->id) { } 0 0 0
45
46 # We have an order id so order has been loaded
47 0 $self->jbilling->createUpdateOrder(
48 SOAP::Data->value( $self->soapify ) );
49
50 # Update the defined order
51 }
52 elsif ( !defined $self->id ) {
53
54 # No Order ID so create a new one
55 0 my $response = $self->jbilling->createOrder(
56 SOAP::Data->value( $self->soapify ) );
57 0 return $response;
58 }
59 }
60 0 ▶ if ( ref($self) =~ m/OrderLineWS$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($self) =~ /OrderLineWS$/) 0 0 0
61 # This is called to update an Individual OrderLine
62 # API does not return anything so
63 0 $self->jbilling->updateOrderLine(
64 $self->soapify
65 );
66 }
67
68 }
69 }
70
71 0 ▶ sub retrieve {
Subroutine retrieve: not called CC=4 SCAR=30.0
Pod documented
72 0 my $self = shift;
73 0 ▶ if ( !defined $self->jbilling ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->jbilling) { } 0 0 0
74 0 throw jBilling::Client::SOAP::Exception 'No jBilling Connection';
75 }
76 else {
77 0 ▶ if ( ref($self) =~ m/OrderWS$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($self) =~ /OrderWS$/) 0 0 0
78
79 #this is an Order object
80 0 ▶ if ( !defined $self->id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->id) { } 0 0 0
81 0 throw jBilling::Client::SOAP::Exception
82 'No ID so cannot retrieve';
83 }
84 else {
85 0 $self->jbilling->getOrder( $self->id );
86 0 return $self;
87 }
88
89 }
90 }
91 }
92
93 0 ▶ sub metaFields {
Subroutine metaFields: not called CC=6 SCAR=37.4
Pod documented
94 0 my $self = shift;
95 0 my @lines;
96 0 my $item = shift;
97 0 ▶ if ( ref($item) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $item eq 'HASH') { } 0 0 0
elsif (ref $item eq 'ARRAY') { } 0 0 0
98 0 my %hash = %{$item};
99 0 my $line = jBilling::Client::SOAP::MetaFieldValueWS->new();
100 0 $line->load($item);
101 0 push @lines, $line;
102 0 $self->{metaFields} = \@lines;
103 }
104 elsif ( ref($item) eq 'ARRAY' ) {
105 0 foreach my $v ( @{$item} ) {
106 0 ▶ if ( ref($v) eq 'jBilling::Client::SOAP::MetaFieldValueWS' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $v eq 'jBilling::Client::SOAP::MetaFieldValueWS') { } 0 0 0
elsif (ref $v eq 'HASH') { } 0 0 0
107
108 # This is an object created by our Client
109 0 push @lines, $v;
110 }
111 elsif ( ref($v) eq 'HASH' ) {
112
113 #This is coming back from jBilling
114 0 my %hash = %{$v};
115 0 my $line = jBilling::Client::SOAP::MetaFieldValueWS->new();
116 0 $line->load( \%hash );
117 0 push @lines, $line;
118 }
119
120 }
121 0 $self->{metaFields} = \@lines;
122 }
123 else {
124 0 return $self->{metaFields};
125 }
126
127 }
128
129
130
131
132 1 1;
133
134 =pod
135
136 =encoding UTF-8
137
138 =head1 NAME
139
140 jBilling::Client::SOAP::Object
141
142 =head1 VERSION
143
144 version 0.01
145
146 =head1 AUTHOR
147
148 Aaron Guise <guisea@cpan.org>
149
150 =head1 Functions
151
152 =head2 load
153
154 The load method is tasked with taking values returned by jBilling and
155 loading them into fields within the perl object.
156
157 =head2 retrieve
158
159 The retrieve method ensures an active connection is available to jBilling
160 and calls methods that return data via the API.
161
162 =head2 save
163
164 The save method is called to save our Objects to jBilling. Will soapify
165 the object and transport it.
166
167 =head2 metaFields
168
169 The metaFields method either returns metafields
170
171 =head1 COPYRIGHT AND LICENSE
172
173 This software is copyright (c) 2015 by Aaron Guise.
174
175 This is free software; you can redistribute it and/or modify it under
176 the same terms as the Perl 5 programming language system itself.
177
178 =cut
« SOAP/ItemDTOEx.pm ↑ Summary SOAP/API.pm »