File Coverage

blib/lib/SRS/EPP/Command/Check/Contact.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1              
2             package SRS::EPP::Command::Check::Contact;
3             {
4             $SRS::EPP::Command::Check::Contact::VERSION = '0.22';
5             }
6              
7 1     1   3335 use Moose;
  1         3  
  1         13  
8             extends 'SRS::EPP::Command::Check';
9              
10 1     1   8552 use SRS::EPP::Session;
  0            
  0            
11             use XML::EPP::Contact;
12             use MooseX::Params::Validate;
13              
14             # for plugin system to connect
15             sub xmlns {
16             XML::EPP::Contact::Node::xmlns();
17             }
18              
19             sub multiple_responses { 1 }
20              
21             sub process {
22             my $self = shift;
23            
24             my ( $session ) = pos_validated_list(
25             \@_,
26             { isa => 'SRS::EPP::Session' },
27             );
28            
29             $self->session($session);
30             my $epp = $self->message;
31              
32             my $payload = $epp->message->argument->payload;
33              
34             return XML::SRS::Handle::Query->new( handle_id_filter => $payload->ids );
35             }
36              
37             sub notify {
38             my $self = shift;
39            
40             my ( $rs ) = pos_validated_list(
41             \@_,
42             { isa => 'ArrayRef[SRS::EPP::SRSResponse]' },
43             );
44            
45             my $handles = $rs->[0]->message->responses;
46              
47             my %used;
48             %used = map { $_->handle_id => 1 } @$handles if $handles;
49              
50             my $epp = $self->message;
51             my $payload = $epp->message->argument->payload;
52              
53             my $ids = $payload->ids;
54              
55             my @statuses = map {
56             my $id = XML::EPP::Contact::Check::ID->new(
57             name => $_,
58             available => ($used{$_} ? 0 : 1),
59             );
60            
61             XML::EPP::Contact::Check::Status->new(
62             id_status => $id,
63             );
64            
65             } @$ids;
66              
67            
68              
69             my $r = XML::EPP::Contact::Check::Response->new(
70             items => \@statuses,
71             );
72              
73             # from SRS::EPP::Response::Check
74             return $self->make_response(
75             code => 1000,
76             payload => $r,
77             );
78             }
79              
80             1;