File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/ARNES/Contact.pm
Criterion Covered Total %
statement 6 41 14.6
branch 0 24 0.0
condition 0 12 0.0
subroutine 2 6 33.3
pod 0 4 0.0
total 8 87 9.2


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, ARNES (.SI) Contact EPP extension commands
2             ##
3             ## Copyright (c) 2008,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::EPP::Extensions::ARNES::Contact;
16              
17 1     1   854 use strict;
  1         2  
  1         49  
18 1     1   7 use warnings;
  1         2  
  1         365  
19              
20             =pod
21              
22             =head1 NAME
23              
24             Net::DRI::Protocol::EPP::Extensions::ARNES::Contact - ARNES (.SI) EPP Contact extensions 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) 2008 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             create => [ \&create, undef ],
67             info => [ undef, \&info_parse ],
68             );
69              
70 0           return { 'contact' => \%tmp };
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 0       return unless ($contact->maticna() || $contact->emso());
88              
89 0           my @n;
90 0 0         push @n,['dnssi:contact',{type=>$contact->maticna()? 'org' : 'person'}];
91 0 0         push @n,['dnssi:maticna',$contact->maticna()] if $contact->maticna();
92 0 0         push @n,['dnssi:EMSO',$contact->emso()] if $contact->emso();
93 0           my $eid=build_command_extension($mes,$epp,'dnssi:ext');
94 0           $mes->command_extension($eid,[['dnssi:create'],\@n]);
95 0           return;
96             }
97              
98             sub info_parse
99             {
100 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
101 0           my $mes=$po->message();
102 0 0         return unless $mes->is_success();
103              
104 0           my $infdata=$mes->get_extension('dnssi','ext');
105 0 0         return unless $infdata;
106              
107 0           $infdata=$infdata->getChildrenByTagNameNS($mes->ns('dnssi'),'info');
108 0 0 0       return unless ($infdata && $infdata->size()==1);
109 0           $infdata=$infdata->shift()->getChildrenByTagNameNS($mes->ns('dnssi'),'contact');
110 0 0 0       return unless ($infdata && $infdata->size()==1);
111              
112 0           my $co=$rinfo->{contact}->{$oname}->{self};
113 0           my $c=$infdata->shift()->getFirstChild();
114 0           while($c)
115             {
116 0 0         next unless ($c->nodeType() == 1); ## only for element nodes
117 0   0       my $name=$c->localname() || $c->nodeName();
118 0 0         next unless $name;
119              
120 0 0         if ($name eq 'maticna')
    0          
121             {
122 0           $co->maticna($c->textContent());
123             } elsif ($name eq 'EMSO')
124             {
125 0           $co->emso($c->textContent());
126             }
127 0           } continue { $c=$c->getNextSibling(); }
128 0           return;
129             }
130              
131             ####################################################################################################
132             1;