DRI/Protocol/EPP/Extensions/ServiceMessage.pm

filter: Statementstmt 25.4% 13 / 51 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 4 totaltotal 20.4% 17 / 83 CC 13 SCAR 47.8
CC
13
Cov
18%
parse
182.0
register_commands
2.0
setup
2.0
CRAP 118.8
« DRI/Protocol/EPP/Extensions/BR/Contact.pm ↑ Summary DRI/Protocol/EPP/Core/Host.pm »
1 ## Domain Registry Interface, Service Message Extension Mapping for EPP
2 ##
3 ## Copyright (c) 2015,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::ServiceMessage;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 ####################################################################################################
24  
25 sub register_commands
26 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my ($class,$version)=@_;
28  
29 0 state $rops = { 'session' => { review_complete => [ undef, \&parse ] } };
30  
31 0 return $rops;
32 }
33  
34 sub setup
35 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my ($class,$po,$version)=@_;
37 0 $po->ns({ 'servicemessage' => 'http://tld-box.at/xmlns/resdata-1.1' });
38 0 return;
39 }
40  
41 0 ▶sub implements { return 'https://tools.ietf.org/html/draft-mayrhofer-eppext-servicemessage-00'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 ####################################################################################################
44  
45 sub parse
46 0 ▶{
Subroutine parse: not called CC=13 SCAR=52.0
Pod undocumented
47 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
48 0 my $mes=$po->message();
49 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
50  
51 0 my $data=$mes->get_response('servicemessage','message');
52 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
53  
54 0 my %r=(type => $data->getAttribute('type'));
55 0 my $ns=$mes->ns('servicemessage');
56 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
57 {
58 0 my ($name,$node)=@$el;
59 0 ▶ if ($name eq 'desc')
Branch: 3 branches
BranchTrueFalseTotal
if ($name eq 'desc') { } 0 0 0
elsif ($name eq 'reftrID') { } 0 0 0
elsif ($name eq 'data') { } 0 0 0
60 {
61 0 $r{description}=$node->textContent();
62 } elsif ($name eq 'reftrID')
63 {
64 0 $r{clTRID}=Net::DRI::Util::xml_traverse($node,$ns,qw/clTRID/);
65 0 $r{svTRID}=Net::DRI::Util::xml_traverse($node,$ns,qw/svTRID/);
66 } elsif ($name eq 'data')
67 {
68 0 my %entries;
69 0 foreach my $subel (Net::DRI::Util::xml_list_children($node))
70 {
71 0 my ($subname,$subnode)=@$subel;
72 0 ▶ if ($subname eq 'entry') ## specification says there are key/value tuples
Branch: 3 branches
BranchTrueFalseTotal
if ($subname eq 'entry') { } 0 0 0
elsif ($subname eq 'request') { } 0 0 0
elsif ($subname eq 'response') { } 0 0 0
73 {
74 0 my $key = $subnode->getAttribute('name');
75 0 my $value = $subnode->textContent();
76 0 ▶ if (exists $entries{$key})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $entries{$key}) { } 0 0 0
77 {
78 0 ▶ $entries{$key}=[ $entries{$key} ] unless ref $entries{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $entries{$key} 0 0 0
79 0 push @{$entries{$key}},$value;
80 } else
81 {
82 0 $entries{$key}=$value;
83 }
84 } elsif ($subname eq 'request')
85 {
86 0 $r{request}=$subnode->toString(0); ## TODO: do something better?
87 } elsif ($subname eq 'response')
88 {
89 0 $r{response}=$subnode->toString(0); ## TODO: do something better?
90 } else # An OPTIONAL "any other" element from "any other" namespace
91 {
92 0 $r{unspecified}=$subnode->toString(0);
93 }
94 }
95 0 $r{entries}=\%entries;
96 }
97 }
98  
99 0 my $msgid=$mes->msg_id();
100 0 $rinfo->{message}->{$msgid}->{servicemessage}=\%r;
101 0 return;
102 }
103  
104 ####################################################################################################
105 1 1;
106  
107 __END__
« DRI/Protocol/EPP/Extensions/BR/Contact.pm ↑ Summary DRI/Protocol/EPP/Core/Host.pm »