]> git.evergreen-ils.org Git - working/NCIPServer.git/blob - lib/NCIP/ILS.pm
Fixup NCIP::ILS::make_header.
[working/NCIPServer.git] / lib / NCIP / ILS.pm
1 # ---------------------------------------------------------------
2 # Copyright © 2014 Jason J.A. Stephenson <jason@sigio.com>
3 #
4 # This file is part of NCIPServer.
5 #
6 # NCIPServer is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # NCIPServer is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with NCIPServer.  If not, see <http://www.gnu.org/licenses/>.
18 # ---------------------------------------------------------------
19 package NCIP::ILS;
20
21 sub new {
22     my $invocant = shift;
23     my $class = ref $invocant || $invocant;
24     my $self = bless {@_}, $class;
25     return $self;
26 }
27
28 # Methods required for SHAREit:
29
30 sub acceptitem {
31 }
32
33 sub cancelrequestitem {
34 }
35
36 sub checkinitem {
37 }
38
39 sub checkoutitem {
40 }
41
42 sub lookupuser {
43 }
44
45 sub renewitem {
46 }
47
48 sub requestitem {
49 }
50
51 # Other methods, just because.
52
53 # Handle a LookupVersion Request.  You probably want to just call this
54 # one from your subclasses rather than reimplement it.
55 sub lookupversion {
56 }
57
58 # A few helper methods:
59
60 # All subclasses will possibly want to create a ResponseHeader and the
61 # code for that would be highly redundant.  We supply a default
62 # implementation here that can retrieve the agency information from
63 # the InitiationHeader of the message, swap their values, and return a
64 # NCIP::Header.
65 sub make_header {
66     my $self = shift;
67     my $request = shift;
68
69     my $initheader;
70     my $header;
71
72     for my $key (keys %$request) {
73         if ($request->{$key}->{InitiationHeader}) {
74             $initheader = $request->{$key}->{InitiationHeader};
75             last;
76         }
77     }
78
79     if ($initheader && $initheader->{FromAgencyId}
80             && $initheader->{ToAgencyId}) {
81         $header = NCIP::Header->new(
82             FromAgencyId => $initheader->{ToAgencyId},
83             ToAgencyId => $initheader->{FromAgencyId}
84         );
85     }
86
87     return $header;
88 }
89
90 1;