| 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 | 3 |  |  | 3 |  | 6046 | use strict; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 113 |  | 
| 10 | 3 |  |  | 3 |  | 15 | use warnings; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 163 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | package SRS::EPP::Response; | 
| 13 |  |  |  |  |  |  | { | 
| 14 |  |  |  |  |  |  | $SRS::EPP::Response::VERSION = '0.22'; | 
| 15 |  |  |  |  |  |  | } | 
| 16 | 3 |  |  | 3 |  | 14 | use Moose; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 20 |  | 
| 17 | 3 |  |  | 3 |  | 19319 | use Moose::Util::TypeConstraints qw(subtype coerce as where enum); | 
|  | 3 |  |  |  |  | 10 |  | 
|  | 3 |  |  |  |  | 36 |  | 
| 18 |  |  |  |  |  |  | extends 'SRS::EPP::Message'; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 3 |  |  | 3 |  | 3706 | use SRS::EPP::SRSResponse; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | use XML::EPP::Extension; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | has 'code' => | 
| 24 |  |  |  |  |  |  | is => 'ro', | 
| 25 |  |  |  |  |  |  | isa => "XML::EPP::resultCodeType", | 
| 26 |  |  |  |  |  |  | required => 1, | 
| 27 |  |  |  |  |  |  | ; | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | has 'extra' => | 
| 30 |  |  |  |  |  |  | is => "ro", | 
| 31 |  |  |  |  |  |  | isa => "Str", | 
| 32 |  |  |  |  |  |  | ; | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | has 'msgQ' => | 
| 35 |  |  |  |  |  |  | is => "ro", | 
| 36 |  |  |  |  |  |  | isa => "XML::EPP::msgQType"; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | has 'payload' => | 
| 39 |  |  |  |  |  |  | is => "ro", | 
| 40 |  |  |  |  |  |  | ; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | has 'extension' => | 
| 43 |  |  |  |  |  |  | is => "ro", | 
| 44 |  |  |  |  |  |  | ; | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | use XML::EPP; | 
| 47 |  |  |  |  |  |  | has "+message" => | 
| 48 |  |  |  |  |  |  | isa => "XML::EPP", | 
| 49 |  |  |  |  |  |  | lazy => 1, | 
| 50 |  |  |  |  |  |  | default => sub { | 
| 51 |  |  |  |  |  |  | my $self = shift; | 
| 52 |  |  |  |  |  |  | $self->build_response; | 
| 53 |  |  |  |  |  |  | }, | 
| 54 |  |  |  |  |  |  | ; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub build_response { | 
| 57 |  |  |  |  |  |  | my $self = shift; | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | my $server_id = $self->server_id; | 
| 60 |  |  |  |  |  |  | my $client_id = $self->client_id; | 
| 61 |  |  |  |  |  |  | my $tx_id; | 
| 62 |  |  |  |  |  |  | if ($server_id) { | 
| 63 |  |  |  |  |  |  | $tx_id = XML::EPP::TrID->new( | 
| 64 |  |  |  |  |  |  | server_id => $server_id, | 
| 65 |  |  |  |  |  |  | ($client_id ? (client_id => $client_id) : () ), | 
| 66 |  |  |  |  |  |  | ); | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  | my $msg = $self->extra; | 
| 69 |  |  |  |  |  |  | my $result = XML::EPP::Result->new( | 
| 70 |  |  |  |  |  |  | ($msg ? (msg => $msg) : ()), | 
| 71 |  |  |  |  |  |  | code => $self->code, | 
| 72 |  |  |  |  |  |  | ); | 
| 73 |  |  |  |  |  |  | my ($payload, $extension); | 
| 74 |  |  |  |  |  |  | if ( $self->payload ) { | 
| 75 |  |  |  |  |  |  | $payload = XML::EPP::SubResponse->new( | 
| 76 |  |  |  |  |  |  | payload => $self->payload, | 
| 77 |  |  |  |  |  |  | ); | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | if ($self->extension) { | 
| 81 |  |  |  |  |  |  | # We only support one extension at the moment... | 
| 82 |  |  |  |  |  |  | $extension = XML::EPP::Extension->new( | 
| 83 |  |  |  |  |  |  | ext_objs => [$self->extension], | 
| 84 |  |  |  |  |  |  | ); | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | XML::EPP->new( | 
| 90 |  |  |  |  |  |  | message => XML::EPP::Response->new( | 
| 91 |  |  |  |  |  |  | result => [$result], | 
| 92 |  |  |  |  |  |  | ($payload ? (response => $payload) : ()), | 
| 93 |  |  |  |  |  |  | ($extension ? (extension => $extension) : ()), | 
| 94 |  |  |  |  |  |  | ($self->msgQ ? (msgQ => $self->msgQ) : ()), | 
| 95 |  |  |  |  |  |  | ($tx_id ? (tx_id => $tx_id) : () ), | 
| 96 |  |  |  |  |  |  | ), | 
| 97 |  |  |  |  |  |  | ); | 
| 98 |  |  |  |  |  |  | } | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | has "client_id" => | 
| 101 |  |  |  |  |  |  | is => "ro", | 
| 102 |  |  |  |  |  |  | isa => "XML::EPP::trIDStringType", | 
| 103 |  |  |  |  |  |  | ; | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | # not all response types require a server_id | 
| 106 |  |  |  |  |  |  | has "server_id" => | 
| 107 |  |  |  |  |  |  | is => "ro", | 
| 108 |  |  |  |  |  |  | isa => "XML::EPP::trIDStringType", | 
| 109 |  |  |  |  |  |  | ; | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | use Module::Pluggable | 
| 112 |  |  |  |  |  |  | require => 1, | 
| 113 |  |  |  |  |  |  | search_path => [__PACKAGE__], | 
| 114 |  |  |  |  |  |  | ; | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | sub ids { | 
| 117 |  |  |  |  |  |  | my $self = shift; | 
| 118 |  |  |  |  |  |  | return ( | 
| 119 |  |  |  |  |  |  | $self->server_id || sprintf("0x%x",(0+$self)), | 
| 120 |  |  |  |  |  |  | $self->client_id||(), | 
| 121 |  |  |  |  |  |  | ); | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | __PACKAGE__->plugins; | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | no Moose; | 
| 127 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | 1; | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | __END__ | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | =head1 NAME | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | SRS::EPP::Response - EPP XML | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | ... | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | This is a base class for all EPP responses. | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | L<SRS::EPP::Message> | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =cut | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | # Local Variables: | 
| 152 |  |  |  |  |  |  | # mode:cperl | 
| 153 |  |  |  |  |  |  | # indent-tabs-mode: t | 
| 154 |  |  |  |  |  |  | # cperl-continued-statement-offset: 8 | 
| 155 |  |  |  |  |  |  | # cperl-brace-offset: 0 | 
| 156 |  |  |  |  |  |  | # cperl-close-paren-offset: 0 | 
| 157 |  |  |  |  |  |  | # cperl-continued-brace-offset: 0 | 
| 158 |  |  |  |  |  |  | # cperl-continued-statement-offset: 8 | 
| 159 |  |  |  |  |  |  | # cperl-extra-newline-before-brace: nil | 
| 160 |  |  |  |  |  |  | # cperl-indent-level: 8 | 
| 161 |  |  |  |  |  |  | # cperl-indent-parens-as-block: t | 
| 162 |  |  |  |  |  |  | # cperl-indent-wrt-brace: nil | 
| 163 |  |  |  |  |  |  | # cperl-label-offset: -8 | 
| 164 |  |  |  |  |  |  | # cperl-merge-trailing-else: t | 
| 165 |  |  |  |  |  |  | # End: |