File Coverage

blib/lib/SRS/EPP/Command/Check/Contact.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1              
2              
3             package SRS::EPP::Command::Check::Contact;
4              
5 1     1   2092 use Moose;
  0            
  0            
6             extends 'SRS::EPP::Command::Check';
7             use MooseX::Method::Signatures;
8             use Crypt::Password;
9             use SRS::EPP::Session;
10             use XML::EPP::Contact;
11              
12             # for plugin system to connect
13             sub xmlns {
14             XML::EPP::Contact::Node::xmlns();
15             }
16              
17             method process( SRS::EPP::Session $session ) {
18             $self->session($session);
19             my $epp = $self->message;
20              
21             my $payload = $epp->message->argument->payload;
22              
23             return XML::SRS::Handle::Query->new( handle_id_filter => $payload->ids );
24             }
25              
26             has 'ids_to_check' =>
27             is => 'rw',
28             isa => 'ArrayRef[Str]',
29             ;
30              
31             has 'avail' =>
32             is => "rw",
33             isa => "HashRef[Str]",
34             ;
35              
36             method notify( SRS::EPP::SRSResponse @rs ) {
37             $self->avail({ map { $_->message->response->handle_id => 1 } grep { $_->message->response } @rs });
38              
39             my $epp = $self->message;
40             my $payload = $epp->message->argument->payload;
41              
42             my $ids = $payload->ids;
43             my $avail = $self->avail();
44              
45             my @ids = map { XML::EPP::Contact::Check::ID->new(
46             name => $_,
47             available => ($avail->{$_} ? 0 : 1),
48             ) } @$ids;
49              
50             my $status = XML::EPP::Contact::Check::Status->new(
51             id_status => \@ids,
52             );
53              
54             my $r = XML::EPP::Contact::Check::Response->new(
55             items => [ $status ],
56             );
57              
58             # from SRS::EPP::Response::Check
59             return $self->make_response(
60             'Check',
61             code => 1000,
62             payload => $r,
63             );
64             }
65              
66             1;