File Coverage

blib/lib/Net/DRI/Protocol/AFNIC/WS/Domain.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 8 0.0
condition 0 3 0.0
subroutine 2 6 33.3
pod 0 4 0.0
total 8 47 17.0


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, AFNIC Web Services Domain commands
2             ##
3             ## Copyright (c) 2005,2013 Patrick Mevzek . 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::AFNIC::WS::Domain;
16              
17 1     1   1308 use strict;
  1         2  
  1         30  
18 1     1   4 use warnings;
  1         2  
  1         318  
19              
20             =pod
21              
22             =head1 NAME
23              
24             Net::DRI::Protocol::AFNIC::WS::Domain - AFNIC Web Services Domain commands for Net::DRI
25              
26             =head1 DESCRIPTION
27              
28             Please see the README file for details.
29              
30             =head1 SUPPORT
31              
32             For now, support questions should be sent to:
33              
34             Enetdri@dotandco.comE
35              
36             Please also see the SUPPORT file in the distribution.
37              
38             =head1 SEE ALSO
39              
40             Ehttp://www.dotandco.com/services/software/Net-DRI/E
41              
42             =head1 AUTHOR
43              
44             Patrick Mevzek, Enetdri@dotandco.comE
45              
46             =head1 COPYRIGHT
47              
48             Copyright (c) 2005,2013 Patrick Mevzek .
49             All rights reserved.
50              
51             This program is free software; you can redistribute it and/or modify
52             it under the terms of the GNU General Public License as published by
53             the Free Software Foundation; either version 2 of the License, or
54             (at your option) any later version.
55              
56             See the LICENSE file that comes with this distribution for more details.
57              
58             =cut
59              
60             ##########################################################
61              
62             sub register_commands
63             {
64 0     0 0   my ($class,$version)=@_;
65 0           my %tmp=(
66             check => [ \&check, \&check_parse ],
67             );
68              
69 0           return { 'domain' => \%tmp };
70             }
71              
72             sub build_msg
73             {
74 0     0 0   my ($msg,$command,$domain)=@_;
75 0 0 0       Net::DRI::Exception->die(1,'protocol/afnic/ws',2,"Domain name needed") unless defined($domain) && $domain;
76 0 0         Net::DRI::Exception->die(1,'protocol/afnic/ws',10,"Invalid domain name") unless ($domain=~m/^[a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.[a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?$/i); ## from RRP grammar
77              
78 0 0         $msg->method($command) if defined($command);
79 0           return;
80             }
81              
82             sub check
83             {
84 0     0 0   my ($po,$domain)=@_;
85 0           my $msg=$po->message();
86 0           build_msg($msg,'check_domain',$domain);
87 0           $msg->params([$domain]);
88 0           $msg->service('Domain');
89 0           return;
90             }
91              
92             sub check_parse
93             {
94 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
95 0           my $mes=$po->message();
96 0 0         return unless $mes->is_success();
97              
98 0           my $r=$mes->result(); ## { free => 0|1, reason => \d+, message => '' }
99 0           $rinfo->{domain}->{$oname}->{exist}=1-($r->{free});
100 0           return;
101             }
102              
103             #########################################################################################################
104             1;