DRI/Protocol/BookMyName/WS/Message.pm

filter: Statementstmt 32.6% 15 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 40.0% 4 / 10 Podpod 16.6% 1 / 6 totaltotal 25.3% 20 / 79 CC 8 SCAR 24.3
CC
8
Cov
25%
result_status
30.0
as_string
6.0
parse
6.0
CRAP 11.4
« DRI/Protocol/Whois/Message.pm ↑ Summary DRI/Protocol/EPP/Connection.pm »
1 ## Domain Registry Interface, BookMyName Web Services Message
2 ##
3 ## Copyright (c) 2008-2010,2013-2014 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::BookMyName::WS::Message;
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  
20 1 ▶use Net::DRI::Protocol::ResultStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 __PACKAGE__->mk_accessors(qw(version method params operation result retcode retval));
24  
25 =pod
26  
27 =head1 NAME
28  
29 Net::DRI::Protocol::BookMyName::WS::Message - BookMyName Web Services Message for Net::DRI
30  
31 =head1 DESCRIPTION
32  
33 Please see the README file for details.
34  
35 =head1 SUPPORT
36  
37 For now, support questions should be sent to:
38  
39 E<lt>netdri@dotandco.comE<gt>
40  
41 Please also see the SUPPORT file in the distribution.
42  
43 =head1 SEE ALSO
44  
45 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
46  
47 =head1 AUTHOR
48  
49 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
50  
51 =head1 COPYRIGHT
52  
53 Copyright (c) 2008-2010,2013-2014 Patrick Mevzek <netdri@dotandco.com>.
54 All rights reserved.
55  
56 This program is free software; you can redistribute it and/or modify
57 it under the terms of the GNU General Public License as published by
58 the Free Software Foundation; either version 2 of the License, or
59 (at your option) any later version.
60  
61 See the LICENSE file that comes with this distribution for more details.
62  
63 =cut
64  
65 ####################################################################################################
66  
67 sub new
68 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
69 0 my ($class,$trid,$otype,$oaction)=@_;
70 0 my $self={errcode => undef, errmsg => undef};
71 0 bless($self,$class);
72  
73 0 $self->params([]); ## default
74 0 return $self;
75 }
76  
77 sub as_string
78 0 ▶{
Subroutine as_string: not called CC=2 SCAR=17.9
Pod undocumented
79 0 my ($self)=@_;
80 0 my @p=@{$self->params()};
81 0 my @pr;
82 0 foreach my $i (0..$#p)
83 {
84 0 push @pr,sprintf 'PARAM%d=%s',$i+1,$p[$i];
85 }
86 0 return sprintf "METHOD=%s\n%s\n",$self->method(),join("\n",@pr);
87 }
88  
89 sub add_session
90 0 ▶{
Subroutine add_session: not called CC=1 SCAR=6.9
Pod undocumented
91 0 my ($self,$sd)=@_;
92 0 my $rp=$self->params();
93 0 unshift(@$rp,$sd->{id},$sd->{pass});
94 0 return;
95 }
96  
97 sub parse
98 0 ▶{
Subroutine parse: not called CC=2 SCAR=17.9
Pod undocumented
99 0 my ($self,$dr,$rinfo,$otype,$oaction,$sent)=@_; ## $sent is the original message, we could copy its method/params value into this new message
100 0 $self->operation($otype.'_'.$oaction);
101 0 my ($res)=@{$dr->data()}; ## $dr is a Data::Raw object, type=1
102 0 ▶ $self->result($res->{retfields}) if exists($res->{retfields});
Branch: 1 branch
BranchTrueFalseTotal
if exists $res->{"retfields"} 0 0 0
103 0 $self->retcode($res->{retcode}); ## integer
104 0 $self->retval($res->{retval}); ## integer
105 0 return;
106 }
107  
108 ## See http://api.doc.free.org/revendeur-de-nom-de-domaine
109 1 our %CODES=( domain_info => { '-1,-1' => 2200,
110 '-1,-2' => 2201,
111 '-1,-3' => 2003,
112 '0,0' => 2303,
113 },
114 domain_check => { '-1,-1' => 2200,
115 '-1,-2' => 2303,
116 '-1,-3' => 2103,
117 '-1,-4' => 2303,
118 '-1,-5' => 2003,
119 },
120 account_list_domains => {
121 '-1,-1' => 2200,
122 },
123 );
124  
125 0 ▶sub is_success { return (shift->retcode()==1)? 1 : 0; }
Subroutine is_success: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
(shift())->retcode == 1 ? : 0 0 0
126  
127 sub result_status
128 0 ▶{
Subroutine result_status: not called CC=5 SCAR=34.0
Pod undocumented
129 0 my $self=shift;
130 0 my ($op,$rc,$rv)=($self->operation(),$self->retcode(),$self->retval());
131 0 my $ok=$self->is_success();
132 0 my $k=$rc.','.$rv;
133 0 ▶ my $eppcode=(exists $CODES{$op} && ref $CODES{$op} eq 'HASH' && exists $CODES{$op}->{$k})? $CODES{$op}->{$k} : 'COMMAND_FAILED';
Branch: 1 branch
BranchTrueFalseTotal
exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} && ref $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} eq 'HASH' && exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op}{$k} ? : 0 0 0
Condition0%0/6
exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} and ref $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} eq "HASH" and exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op}{$k}
!ll&&!rl&&r
000
exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} and ref $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} and ref $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} eq "HASH" and exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op}{$k}
exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} ref $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} eq "HASH" exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op}{$k}
Truth table0%0/4
A and B and C
A= exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op}B= ref $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op} eq "HASH"C= exists $Net::DRI::Protocol::BookMyName::WS::Message::CODES{$op}{$k}
ABCresult
0XX0
10X0
1100
1111
134 0 ▶ return Net::DRI::Protocol::ResultStatus->new('bookmyname_ws',100*$rc+$rv,$ok ? 'COMMAND_SUCCESSFUL' : $eppcode,$ok,'retcode='.$rc.' retval='.$rv,'en');
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 0 0 0
135 }
136  
137 ####################################################################################################
138 1 1;
« DRI/Protocol/Whois/Message.pm ↑ Summary DRI/Protocol/EPP/Connection.pm »