File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/US/Contact.pm
Criterion Covered Total %
statement 12 44 27.2
branch 0 18 0.0
condition 0 6 0.0
subroutine 4 8 50.0
pod 0 4 0.0
total 16 80 20.0


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, EPP .US Contact NEXUS Extensions
2             ##
3             ## Copyright (c) 2005,2006,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::US::Contact;
16              
17 1     1   1606 use strict;
  1         2  
  1         28  
18 1     1   4 use warnings;
  1         2  
  1         21  
19              
20 1     1   4 use Net::DRI::Util;
  1         1  
  1         21  
21 1     1   4 use Net::DRI::Exception;
  1         1  
  1         648  
22              
23             =pod
24              
25             =head1 NAME
26              
27             Net::DRI::Protocol::EPP::Extensions::US::Contact - .US EPP Contact NEXUS Extensions for Net::DRI
28              
29             =head1 DESCRIPTION
30              
31             Please see the README file for details.
32              
33             =head1 SUPPORT
34              
35             For now, support questions should be sent to:
36              
37             Enetdri@dotandco.comE
38              
39             Please also see the SUPPORT file in the distribution.
40              
41             =head1 SEE ALSO
42              
43             Ehttp://www.dotandco.com/services/software/Net-DRI/E
44              
45             =head1 AUTHOR
46              
47             Patrick Mevzek, Enetdri@dotandco.comE
48              
49             =head1 COPYRIGHT
50              
51             Copyright (c) 2005,2006,2008,2013 Patrick Mevzek .
52             All rights reserved.
53              
54             This program is free software; you can redistribute it and/or modify
55             it under the terms of the GNU General Public License as published by
56             the Free Software Foundation; either version 2 of the License, or
57             (at your option) any later version.
58              
59             See the LICENSE file that comes with this distribution for more details.
60              
61             =cut
62              
63             ###################################################################################################
64              
65             sub register_commands
66             {
67 0     0 0   my ($class,$version)=@_;
68 0           my %tmp=(
69             info => [ undef, \&info_parse ],
70             create => [ \&create, undef ],
71             update => [ \&update, undef ],
72             );
73              
74 0           return { 'contact' => \%tmp };
75             }
76              
77             ####################################################################################################
78              
79             ########### Query commands
80              
81             sub info_parse
82             {
83 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
84 0           my $mes=$po->message();
85 0 0         return unless $mes->is_success();
86              
87 0           my $contact=$rinfo->{contact}->{$oname}->{self};
88 0           my $ext=$mes->node_extension();
89              
90 0 0 0       return unless (defined($ext) && $ext && $ext->getFirstChild());
      0        
91 0           my %tmp=map { split(/=/,$_) } split(/\s+/,$ext->getFirstChild()->getData());
  0            
92              
93 0 0         $contact->application_purpose($tmp{AppPurpose}) if exists($tmp{AppPurpose});
94 0 0         $contact->nexus_category($tmp{NexusCategory}) if exists($tmp{NexusCategory});
95 0           return;
96             }
97              
98             ############ Transform commands
99              
100             sub create
101             {
102 0     0 0   my ($epp,$contact)=@_;
103 0           my $mes=$epp->message();
104              
105 0 0         return unless Net::DRI::Util::isa_contact($contact,'Net::DRI::Data::Contact::US');
106              
107 0           my $str=sprintf('AppPurpose=%s NexusCategory=%s',$contact->application_purpose(),$contact->nexus_category());
108 0           my $eid=$mes->command_extension_register('neulevel:extension','xmlns:neulevel="urn:ietf:params:xml:ns:neulevel-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:neulevel-1.0 neulevel-1.0.xsd"');
109 0           $mes->command_extension($eid,['neulevel:unspec',$str]);
110 0           return;
111             }
112              
113             sub update
114             {
115 0     0 0   my ($epp,$contact,$todo)=@_;
116 0           my $mes=$epp->message();
117              
118 0           my $newc=$todo->set('info');
119 0 0         return unless Net::DRI::Util::isa_contact($newc,'Net::DRI::Data::Contact::US');
120              
121 0           my @tmp;
122 0 0         push @tmp,'AppPurpose='.$newc->application_purpose() if (defined($newc->application_purpose()));
123 0 0         push @tmp,'NexusCategory='.$newc->nexus_category() if (defined($newc->nexus_category()));
124              
125 0 0         return unless @tmp;
126            
127 0           my $eid=$mes->command_extension_register('neulevel:extension','xmlns:neulevel="urn:ietf:params:xml:ns:neulevel-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:neulevel-1.0 neulevel-1.0.xsd"');
128 0           $mes->command_extension($eid,['neulevel:unspec',join(' ',@tmp)]);
129 0           return;
130             }
131              
132             ####################################################################################################
133             1;