1 package C4
::Search
::PazPar2
;
3 # Copyright (C) 2007 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
29 C4::Search::PazPar2 - implement client for PazPar2
31 [Note: may rename to Net::PazPar2 or somesuch if decide to put on CPAN separate
47 $self->{'endpoint'} = $endpoint;
48 $self->{'session'} = '';
49 $self->{'ua'} = LWP
::UserAgent
->new;
58 my $uri = URI
->new($self->{'endpoint'});
59 $uri->query_param(command
=> 'init');
60 my $response = $self->{'ua'}->get($uri);
61 if ($response->is_success) {
62 my $message = XMLin
($response->content);
63 if ($message->{'status'} eq 'OK') {
64 $self->{'session'} = $message->{'session'};
67 warn $response->status_line;
75 my $uri = URI
->new($self->{'endpoint'});
76 $uri->query_param(command
=> 'search');
77 $uri->query_param(session
=> $self->{'session'});
78 $uri->query_param(query
=> $query);
79 my $response = $self->{'ua'}->get($uri);
80 if ($response->is_success) {
81 #print $response->content, "\n";
83 warn $response->status_line;
91 my $uri = URI
->new($self->{'endpoint'});
92 $uri->query_param(command
=> 'stat');
93 $uri->query_param(session
=> $self->{'session'});
94 my $response = $self->{'ua'}->get($uri);
95 if ($response->is_success) {
96 return $response->content;
98 warn $response->status_line;
109 my $uri = URI
->new($self->{'endpoint'});
110 $uri->query_param(command
=> 'show');
111 $uri->query_param(start
=> $start);
112 $uri->query_param(num
=> $count);
113 $uri->query_param(block
=> 1);
114 $uri->query_param(session
=> $self->{'session'});
115 $uri->query_param(sort => $sort);
116 my $response = $self->{'ua'}->get($uri);
117 if ($response->is_success) {
118 return $response->content;
120 warn $response->status_line;
131 my $uri = URI
->new($self->{'endpoint'});
132 $uri->query_param(command
=> 'record');
133 $uri->query_param(id
=> $id);
134 $uri->query_param(offset
=> $offset);
135 $uri->query_param(binary
=> 1);
136 $uri->query_param(session
=> $self->{'session'});
137 my $response = $self->{'ua'}->get($uri);
138 if ($response->is_success) {
139 return $response->content;
141 warn $response->status_line;
150 my $uri = URI
->new($self->{'endpoint'});
151 $uri->query_param(command
=> 'termlist');
152 $uri->query_param(name
=> $name);
153 $uri->query_param(session
=> $self->{'session'});
154 my $response = $self->{'ua'}->get($uri);
155 if ($response->is_success) {
156 return $response->content;
158 warn $response->status_line;
168 Koha Development Team <http://koha-community.org/>
170 Galen Charlton <galen.charlton@liblime.com>