File Coverage

blib/lib/SRS/EPP/Command/Update/Contact.pm
Criterion Covered Total %
statement 9 37 24.3
branch 0 26 0.0
condition 0 6 0.0
subroutine 3 6 50.0
pod n/a
total 12 75 16.0


line stmt bran cond sub pod time code
1             package SRS::EPP::Command::Update::Contact;
2             {
3             $SRS::EPP::Command::Update::Contact::VERSION = '0.22';
4             }
5              
6 1     1   2939 use Moose;
  1         2  
  1         13  
7              
8             extends 'SRS::EPP::Command::Update';
9             with 'SRS::EPP::Common::Contact';
10              
11 1     1   7539 use MooseX::Params::Validate;
  1         3  
  1         12  
12              
13 1     1   451 use feature 'switch';
  1         2  
  1         704  
14              
15             # for plugin system to connect
16             sub xmlns {
17 0     0     return XML::EPP::Contact::Node::xmlns();
18             }
19              
20             sub process {
21 0     0     my $self = shift;
22            
23 0           my ( $session ) = pos_validated_list(
24             \@_,
25             { isa => 'SRS::EPP::Session' },
26             );
27 0           $self->session($session);
28              
29 0           my $epp = $self->message;
30 0           my $message = $epp->message;
31 0           my $payload = $message->argument->payload;
32              
33             # Reject add or remove elements, since those are just statuses
34             # which we don't support
35 0 0 0       if ( $payload->add || $payload->remove) {
36 0           return $self->make_response(code => 2307);
37             }
38              
39             # Must supply a change element
40 0 0         unless ( $payload->change ) {
41 0           return $self->make_response(code => 2002);
42             }
43              
44 0           my $contact = $payload->change;
45              
46 0           my $address;
47             my $name;
48 0 0         if ($contact->postal_info) {
49 0 0         if ( my $resp = $self->validate_contact_postal($contact->postal_info) ) {
50 0           return $resp;
51             }
52              
53 0 0         if ( my $addr = $contact->postal_info->[0]->addr ) {
54 0           $address = $self->translate_address($addr);
55              
56             # Blank out any optional fields they didn't provide in
57             # the address. Otherwise the original values will be
58             # left in by the SRS (EPP considers the address one
59             # unit to be replaced)
60 0           for my $field (qw/address2 region postcode/) {
61 0 0         $address->$field('') unless $address->$field;
62             }
63             }
64              
65 0           $name = $contact->postal_info->[0]->name;
66             }
67 0 0         if ($contact->voice) {
68 0 0         if ( my $resp = $self->validate_contact_voice($contact->voice)) {
69 0           return $resp;
70             }
71             }
72              
73 0 0 0       return XML::SRS::Handle::Update->new(
    0          
    0          
    0          
    0          
74             handle_id => $payload->id,
75             action_id => $message->client_id || $self->server_id,
76             ($name ? (name => $name) : ()),
77             ($address ? (address => $address) : ()),
78             ($contact->voice ? (phone => $contact->voice->content) : ()),
79             ($contact->fax ? (fax => $contact->fax->content) : ()),
80             ($contact->email ? (email => $contact->email) : ()),
81             );
82             }
83              
84             sub notify{
85 0     0     my $self = shift;
86            
87 0           my ( $rs ) = pos_validated_list(
88             \@_,
89             { isa => 'ArrayRef[SRS::EPP::SRSResponse]' },
90             );
91            
92 0           return $self->make_response(code => 1000);
93             }
94              
95             1;