From bd6d86ca5e0fabd5176e51c675b9b66dc50ef02f Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 7 Aug 2014 07:59:56 -0400 Subject: [PATCH] Add lookupversion implemenation to NCIP::ILS. Also fix a few typos. Signed-off-by: Jason Stephenson --- lib/NCIP/Header.pm | 2 +- lib/NCIP/ILS.pm | 16 ++++++++++++++++ lib/NCIP/Response.pm | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/NCIP/Header.pm b/lib/NCIP/Header.pm index 0ae1960..d7d5646 100644 --- a/lib/NCIP/Header.pm +++ b/lib/NCIP/Header.pm @@ -25,7 +25,7 @@ use parent qw(Class::Accessor); # The fields are as defined in Z39.83-1-2012. Ext is provided but is # not used by the current iteration of NCIPServer. -NCIP::Problem->mk_accessors(qw(FromSystemId FromSystemAuthentication +NCIP::Header->mk_accessors(qw(FromSystemId FromSystemAuthentication FromAgencyId FromAgencyAuthentication ToSystemId ToAgencyId Ext)); diff --git a/lib/NCIP/ILS.pm b/lib/NCIP/ILS.pm index 581b009..aae5939 100644 --- a/lib/NCIP/ILS.pm +++ b/lib/NCIP/ILS.pm @@ -18,6 +18,11 @@ # --------------------------------------------------------------- package NCIP::ILS; +use Modern::Perl; +use NCIP::Const; +use NCIP::Header; +use NCIP::Response; + sub new { my $invocant = shift; my $class = ref $invocant || $invocant; @@ -53,6 +58,17 @@ sub requestitem { # Handle a LookupVersion Request. You probably want to just call this # one from your subclasses rather than reimplement it. sub lookupversion { + my $self = shift; + my $request = shift; + + my $response = NCIP::Response->new({type => "LookupVersionResponse"}); + $response->header($self->make_header($request)); + my $payload = { + versions => [ NCIP::Const::SUPPORTED_VERSIONS ] + }; + $response->data($payload); + + return $response; } # A few helper methods: diff --git a/lib/NCIP/Response.pm b/lib/NCIP/Response.pm index e702d10..00c9266 100644 --- a/lib/NCIP/Response.pm +++ b/lib/NCIP/Response.pm @@ -41,6 +41,6 @@ use parent qw(Class::Accessor); # supplied the other must be left undefined/unset. Only 1 header is # supported, but it is entirely optional according to the standard. -NCIP::Problem->mk_accessors(qw(type data problem header)); +NCIP::Response->mk_accessors(qw(type data problem header)); 1; -- 2.11.0