File Coverage

blib/lib/SRS/EPP/Response/Greeting.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # vim: filetype=perl:noexpandtab:ts=3:sw=3
2             #
3             # Copyright (C) 2009 NZ Registry Services
4             #
5             # This program is free software: you can redistribute it and/or modify
6             # it under the terms of the Artistic License 2.0 or later. You should
7             # have received a copy of the Artistic License the file COPYING.txt.
8             # If not, see <http://www.perlfoundation.org/artistic_license_2_0>
9              
10 1     1   1114 use strict;
  1         1  
  1         28  
11 1     1   4 use warnings;
  1         1  
  1         26  
12              
13             package SRS::EPP::Response::Greeting;
14 1     1   170 use Moose;
  0            
  0            
15             extends 'SRS::EPP::Response';
16              
17             use MooseX::TimestampTZ qw(gmtimestamptz);
18              
19             has "+message" =>
20             lazy => 1,
21             default => \&make_greeting,
22             ;
23              
24             has "+code" =>
25             required => 0,
26             ;
27              
28             sub make_greeting {
29             my $self = shift;
30             my $proxy = eval { SRS::EPP::Proxy->new };
31              
32             # create the "Data Collection Policy"
33             my $dcp = eval { $proxy->dcp };
34             my $access = $dcp ? $dcp->access : undef;
35             $access ||= "personalAndOther";
36             my $statements = $dcp ? $dcp->statements : undef;
37             $statements ||= [];
38             if ( !@$statements) {
39             # must have something...
40             push @$statements, {
41             purpose => [ qw(admin prov) ],
42             recipient => [ qw(ours) ],
43              
44             retention => "business",
45             };
46             }
47             my $expiry = $dcp ? $dcp->expiry : undef;
48              
49             # let coerce rules do the magic here...
50             my $DCP = XML::EPP::DCP->new(
51             access => $access,
52             statement => $statements,
53             ( defined $expiry ? (expiry => $expiry) : () ),
54             );
55              
56             return XML::EPP->new(
57             message => XML::EPP::Greeting->new(
58             server_name => eval { $proxy->server_name }
59             || "localhost",
60             server_time => gmtimestamptz,
61             services => "auto",
62             dcp => $DCP,
63             ),
64             );
65             }
66              
67             no Moose;
68             __PACKAGE__->meta->make_immutable;
69              
70             1;
71              
72             __END__
73              
74             =head1 NAME
75              
76             SRS::EPP::Message::Greeting - EPP XML Greeting message
77              
78             =head1 SYNOPSIS
79              
80             return SRS::EPP::Message::Greeting->new;
81              
82             =head1 DESCRIPTION
83              
84             This module handles generating the EPP XML greeting
85              
86             =head1 SEE ALSO
87              
88             L<SRS::EPP::Message>
89              
90             =cut
91              
92             # Local Variables:
93             # mode:cperl
94             # indent-tabs-mode: t
95             # cperl-continued-statement-offset: 8
96             # cperl-brace-offset: 0
97             # cperl-close-paren-offset: 0
98             # cperl-continued-brace-offset: 0
99             # cperl-continued-statement-offset: 8
100             # cperl-extra-newline-before-brace: nil
101             # cperl-indent-level: 8
102             # cperl-indent-parens-as-block: t
103             # cperl-indent-wrt-brace: nil
104             # cperl-label-offset: -8
105             # cperl-merge-trailing-else: t
106             # End: