File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/ARNES/Contact.pm
Criterion Covered Total %
statement 9 36 25.0
branch 0 12 0.0
condition 0 6 0.0
subroutine 3 7 42.8
pod 0 4 0.0
total 12 65 18.4


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, ARNES (.SI) Contact EPP extension commands
2             ##
3             ## Copyright (c) 2008,2013,2016 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::EPP::Extensions::ARNES::Contact;
16              
17 1     1   711 use strict;
  1         1  
  1         24  
18 1     1   3 use warnings;
  1         1  
  1         19  
19 1     1   3 use feature 'state';
  1         1  
  1         338  
20              
21             =pod
22              
23             =head1 NAME
24              
25             Net::DRI::Protocol::EPP::Extensions::ARNES::Contact - ARNES (.SI) EPP Contact extensions for Net::DRI
26              
27             =head1 DESCRIPTION
28              
29             Please see the README file for details.
30              
31             =head1 SUPPORT
32              
33             For now, support questions should be sent to:
34              
35             Enetdri@dotandco.comE
36              
37             Please also see the SUPPORT file in the distribution.
38              
39             =head1 SEE ALSO
40              
41             Ehttp://www.dotandco.com/services/software/Net-DRI/E
42              
43             =head1 AUTHOR
44              
45             Patrick Mevzek, Enetdri@dotandco.comE
46              
47             =head1 COPYRIGHT
48              
49             Copyright (c) 2008,2013,2016 Patrick Mevzek .
50             All rights reserved.
51              
52             This program is free software; you can redistribute it and/or modify
53             it under the terms of the GNU General Public License as published by
54             the Free Software Foundation; either version 2 of the License, or
55             (at your option) any later version.
56              
57             See the LICENSE file that comes with this distribution for more details.
58              
59             =cut
60              
61             ####################################################################################################
62              
63             sub register_commands
64             {
65 0     0 0   my ($class,$version)=@_;
66 0           state $rcmds = { 'contact' => { 'create' => [ \&create, undef ],
67             'info' => [ undef, \&info_parse ],
68             },
69             };
70 0           return $rcmds;
71             }
72              
73             ####################################################################################################
74              
75             sub build_command_extension
76             {
77 0     0 0   my ($mes,$epp,$tag)=@_;
78 0           return $mes->command_extension_register($tag,sprintf('xmlns:dnssi="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('dnssi')));
79             }
80              
81             sub create
82             {
83 0     0 0   my ($epp,$contact)=@_;
84 0           my $mes=$epp->message();
85              
86             # validate() has been called
87 0 0         return unless $contact->ctype();
88              
89 0           my @n;
90 0           push @n,'dnssi:contact',{type=>$contact->ctype()};
91 0           my $eid=build_command_extension($mes,$epp,'dnssi:ext');
92 0           $mes->command_extension($eid,[['dnssi:create',\@n]]);
93 0           return;
94             }
95              
96             sub info_parse
97             {
98 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
99 0           my $mes=$po->message();
100 0 0         return unless $mes->is_success();
101              
102 0           my $infdata=$mes->get_extension('dnssi','ext');
103 0 0         return unless $infdata;
104              
105 0           $infdata=$infdata->getChildrenByTagNameNS($mes->ns('dnssi'),'info');
106 0 0 0       return unless ($infdata && $infdata->size()==1);
107 0           $infdata=$infdata->shift()->getChildrenByTagNameNS($mes->ns('dnssi'),'contact');
108 0 0 0       return unless ($infdata && $infdata->size()==1);
109              
110 0           my $co=$rinfo->{contact}->{$oname}->{self};
111 0           my $c=$infdata->pop();
112 0 0         if ( $c =~ /dnssi:contact type=\"(org|person)\"/ ) {
113 0           $co->ctype($1);
114             }
115              
116 0           return;
117             }
118              
119             ####################################################################################################
120             1;