ResponseIDCIO.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 68 CC 7 SCAR 35.1
CC
7
Cov
0%
schemeCompliant
56.0
new
2.0
get_status
2.0
CRAP 33.5
1 package IDCHECKIO::ResponseIDCIO;
2  
3 use strict;
4  
5 our $VERSION = '0.01';
6  
7 sub new {
8 my $class = shift;
9 my $self = {
10 _status => shift,
11 _uid => shift,
12 _body => shift,
13 };
14  
15 my $defaultScheme = { 'analysisRefUid' => '',
16 'uid' => '',
17 'mrz' => {
18 'line2' => '',
19 'line1' => ''},
20 'holderDetail' => {
21 'birthPlace' => '',
22 'firstName' => (''),
23 'lastName' => (''),
24 'address' => '',
25 'birthDate' => {
26 'year' => '',
27 'day' => '',
28 'month' => ''},
29 'gender' => '',
30 'nationality'=> ''},
31 'documentDetail' => {
32 'emitCountry'=> '',
33 'extraInfos' => ({
34 'dataKey'=> '',
35 'dataValue'=> '',
36 'title' => ''}),
37 'documentNumber'=> '',
38 'emitDate' => {
39 'year' => '',
40 'month' => '',
41 'day' => ''},
42 'expirationDate'=> {
43 'year' => '',
44 'month' => '',
45 'day' => ''}},
46 'checkReportSummary'=> {
47 'check' => ({
48 'titleMsg'=> '',
49 'identifier'=> '',
50 'result' => '',
51 'resultMsg'=> ''})},
52 'documentClassification'=> {
53 'idType' => ''},
54 'report' => '',
55 'accepted' => '',
56 'started' => '',
57 'ended' => '',
58 'redirectUrl' => ''};
59  
60 $self->{_body} = schemeCompliant( $self->{_body}, $defaultScheme );
61  
62 bless $self, $class;
63 return $self;
64 }
65  
66 sub schemeCompliant {
67 my ( $dic, $scheme ) = @_;
68 my $result = {};
69
70 foreach my $key (sort(keys $dic)) {
71 my $ref = ref($dic->{$key});
72 if (ref($dic->{$key}) eq "SCALAR" or ref($dic->{$key}) eq "ARRAY") {
73 if ( exists($scheme->{$key}) ) {
74 $result->{$key} = $dic->{$key};
75 }
76 }
77 elsif (ref($dic->{$key}) eq "HASH") {
78 if ( exists($scheme->{$key}) ) {
79 $result->{$key} = schemeCompliant($dic->{$key}, $scheme->{$key});
80 }
81 }
82 unless ( ref($dic->{$key}) ) {
83 if ( exists($scheme->{$key}) ) {
84 $result->{$key} = $dic->{$key};
85 }
86 }
87 }
88 return $result;
89 }
90  
91 sub get_status {
92 my $self = shift;
93 return $self->{_status};
94 }
95  
96 sub get_uid {
97 my $self = shift;
98 return $self->{_uid};
99 }
100  
101 sub get_body {
102 my $self = shift;
103 return $self->{_body};
104 }
105  
106 1;