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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
29 C4::Search::PazPar2 - implement client for PazPar2
31 [Note: may rename to Net::PazPar2 or somesuch if decide to put on CPAN separate
45 $self->{'endpoint'} = $endpoint;
46 $self->{'session'} = '';
47 $self->{'ua'} = LWP::UserAgent->new;
56 my $uri = URI->new($self->{'endpoint'});
57 $uri->query_param(command => 'init');
58 my $response = $self->{'ua'}->get($uri);
59 if ($response->is_success) {
60 my $message = XMLin($response->content);
61 if ($message->{'status'} eq 'OK') {
62 $self->{'session'} = $message->{'session'};
65 warn $response->status_line;
73 my $uri = URI->new($self->{'endpoint'});
74 $uri->query_param(command => 'search');
75 $uri->query_param(session => $self->{'session'});
76 $uri->query_param(query => $query);
77 my $response = $self->{'ua'}->get($uri);
78 if ($response->is_success) {
79 #print $response->content, "\n";
81 warn $response->status_line;
89 my $uri = URI->new($self->{'endpoint'});
90 $uri->query_param(command => 'stat');
91 $uri->query_param(session => $self->{'session'});
92 my $response = $self->{'ua'}->get($uri);
93 if ($response->is_success) {
94 return $response->content;
96 warn $response->status_line;
106 my $uri = URI->new($self->{'endpoint'});
107 $uri->query_param(command => 'show');
108 $uri->query_param(start => $start);
109 $uri->query_param(num => $count);
110 $uri->query_param(block => 1);
111 $uri->query_param(session => $self->{'session'});
112 my $response = $self->{'ua'}->get($uri);
113 if ($response->is_success) {
114 return $response->content;
116 warn $response->status_line;
127 my $uri = URI->new($self->{'endpoint'});
128 $uri->query_param(command => 'record');
129 $uri->query_param(id => $id);
130 $uri->query_param(offset => $offset);
131 $uri->query_param(binary => 1);
132 $uri->query_param(session => $self->{'session'});
133 my $response = $self->{'ua'}->get($uri);
134 if ($response->is_success) {
135 return $response->content;
137 warn $response->status_line;
146 my $uri = URI->new($self->{'endpoint'});
147 $uri->query_param(command => 'termlist');
148 $uri->query_param(name => $name);
149 $uri->query_param(session => $self->{'session'});
150 my $response = $self->{'ua'}->get($uri);
151 if ($response->is_success) {
152 return $response->content;
154 warn $response->status_line;
164 Koha Development Team <info@koha.org>
166 Galen Charlton <galen.charlton@liblime.com>