File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/DNSBE/Contact.pm
Criterion Covered Total %
statement 6 43 13.9
branch 0 16 0.0
condition 0 6 0.0
subroutine 2 7 28.5
pod 0 5 0.0
total 8 77 10.3


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, DNSBE Contact EPP extension commands
2             ## (based on Registration_guidelines_v4_7_2-Part_4-epp.pdf)
3             ##
4             ## Copyright (c) 2006,2008,2013 Patrick Mevzek . All rights reserved.
5             ##
6             ## This file is part of Net::DRI
7             ##
8             ## Net::DRI is free software; you can redistribute it and/or modify
9             ## it under the terms of the GNU General Public License as published by
10             ## the Free Software Foundation; either version 2 of the License, or
11             ## (at your option) any later version.
12             ##
13             ## See the LICENSE file that comes with this distribution for more details.
14             ####################################################################################################
15              
16             package Net::DRI::Protocol::EPP::Extensions::DNSBE::Contact;
17              
18 1     1   794 use strict;
  1         2  
  1         29  
19 1     1   4 use warnings;
  1         2  
  1         451  
20              
21             =pod
22              
23             =head1 NAME
24              
25             Net::DRI::Protocol::EPP::Extensions::DNSBE::Contact - DNSBE EPP Contact extension commands 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) 2006,2008,2013 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           my %tmp=(
67             create => [ \&create, undef ],
68             update => [ \&update, undef ],
69             info => [ undef, \&info_parse ],
70             );
71              
72 0           return { 'contact' => \%tmp };
73             }
74              
75             ####################################################################################################
76              
77             sub build_command_extension
78             {
79 0     0 0   my ($mes,$epp,$tag)=@_;
80 0           return $mes->command_extension_register($tag,sprintf('xmlns:dnsbe="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('dnsbe')));
81             }
82              
83             sub create
84             {
85 0     0 0   my ($epp,$contact)=@_;
86 0           my $mes=$epp->message();
87              
88             ## validate() has been called, we are sure that type & lang exists
89 0           my @n;
90 0 0         push @n,['dnsbe:type',($contact->type() eq 'registrant')? 'licensee' : $contact->type()];
91 0 0         push @n,['dnsbe:vat',$contact->vat()] if $contact->vat();
92 0           push @n,['dnsbe:lang',$contact->lang()];
93              
94 0           my $eid=build_command_extension($mes,$epp,'dnsbe:ext');
95 0           $mes->command_extension($eid,['dnsbe:create',['dnsbe:contact',@n]]);
96 0           return;
97             }
98              
99             sub update
100             {
101 0     0 0   my ($epp,$domain,$todo)=@_;
102 0           my $mes=$epp->message();
103              
104 0           my $newc=$todo->set('info');
105 0 0 0       return unless ($newc && (defined($newc->vat()) || defined($newc->lang())));
      0        
106              
107 0           my @n;
108 0 0         push @n,['dnsbe:vat',$newc->vat()] if defined($newc->vat());
109 0 0         push @n,['dnsbe:lang',$newc->lang()] if defined($newc->lang());
110              
111 0           my $eid=build_command_extension($mes,$epp,'dnsbe:ext');
112 0           $mes->command_extension($eid,['dnsbe:update',['dnsbe:contact',['dnsbe:chg',@n]]]);
113 0           return;
114             }
115              
116             sub info_parse
117             {
118 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
119 0           my $mes=$po->message();
120 0 0         return unless $mes->is_success();
121              
122 0           my $infdata=$mes->get_extension('dnsbe','infData');
123 0 0         return unless $infdata;
124              
125 0           my $s=$rinfo->{contact}->{$oname}->{self};
126              
127 0           my $el=$infdata->getChildrenByTagNameNS($mes->ns('dnsbe'),'type');
128 0           $s->type($el->get_node(1)->getFirstChild()->getData());
129 0           $el=$infdata->getChildrenByTagNameNS($mes->ns('dnsbe'),'vat');
130 0 0         $s->vat($el->get_node(1)->getFirstChild()->getData()) if defined($el->get_node(1));
131 0           $el=$infdata->getChildrenByTagNameNS($mes->ns('dnsbe'),'lang');
132 0           $s->lang($el->get_node(1)->getFirstChild()->getData());
133 0           return;
134             }
135              
136             ####################################################################################################
137             1;