}
my $handler = NCIP::Handler->new(
{
- namespace => $self->namespace(),
- type => $request_type,
- ils => $self->ils
+ namespace => $self->namespace(),
+ type => $request_type,
+ ils => $self->ils,
+ template_dir => $self->config->('NCIP.templates.value'),
}
);
return $handler->handle( $self->xmldoc );
if ($nodes) {
warn "got nodes";
my @childnodes = $nodes->[0]->childNodes();
- warn $nodes;
- if ( $childnodes[1] ) {
- return $childnodes[1]->localname();
+ if ( $childnodes[0] ) {
+ return $childnodes[0]->localname();
}
else {
warn "Got a node, but no child node";
}
sub _error {
- my $self = shift;
+ my $self = shift;
my $error_detail = shift;
my $vars;
$vars->{'error_detail'} = $error_detail;
#===============================================================================
use Modern::Perl;
-use Object::Tiny qw{ type namespace ils };
+use Object::Tiny qw{ type namespace ils templates };
use Module::Load;
+use Template;
sub new {
my $class = shift;
my $params = shift;
my $subclass = __PACKAGE__ . "::" . $params->{type};
load $subclass || die "Can't load module $subclass";
- my $self = bless {
+ my $self = bless {
type => $params->{type},
namespace => $params->{namespace},
- ils => $params->{ils}
+ ils => $params->{ils},
+ templates => $params->{template_dir}
}, $subclass;
return $self;
}
+sub render_output {
+ my $self = shift;
+ my $templatename = shift;
+
+ my $vars = shift;
+ my $template = Template->new(
+ { INCLUDE_PATH => $self->templates, } );
+ my $output;
+ $template->process( $templatename, $vars, \$output );
+ return $output;
+}
1;
my $user = NCIP::User->new(
{ userid => $user_id->textContent(), ils => $self->ils } );
$user->initialise();
- use Data::Dumper;
- warn Dumper $user->userdata();
- return $user->userid();
+ my $vars;
+ $vars->{'messagetype'} = 'LookupUserResponse';
+ $vars->{'user'} = $user;
+ my $output = $self->render_output('response.tt',$vars);
+ return $output;
+
}
}
<Value>[% toagency %]</Value>
</UniqueAgencyId>
</ToAgencyId>
- </ResponserHeader>
+ </ResponseHeader>
</[% messagetype %]>
</NCIPMessage>