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;
107 my $uri = URI->new($self->{'endpoint'});
108 $uri->query_param(command => 'show');
109 $uri->query_param(start => $start);
110 $uri->query_param(num => $count);
111 $uri->query_param(block => 1);
112 $uri->query_param(session => $self->{'session'});
113 $uri->query_param(sort => $sort);
114 my $response = $self->{'ua'}->get($uri);
115 if ($response->is_success) {
116 return $response->content;
118 warn $response->status_line;
129 my $uri = URI->new($self->{'endpoint'});
130 $uri->query_param(command => 'record');
131 $uri->query_param(id => $id);
132 $uri->query_param(offset => $offset);
133 $uri->query_param(binary => 1);
134 $uri->query_param(session => $self->{'session'});
135 my $response = $self->{'ua'}->get($uri);
136 if ($response->is_success) {
137 return $response->content;
139 warn $response->status_line;
148 my $uri = URI->new($self->{'endpoint'});
149 $uri->query_param(command => 'termlist');
150 $uri->query_param(name => $name);
151 $uri->query_param(session => $self->{'session'});
152 my $response = $self->{'ua'}->get($uri);
153 if ($response->is_success) {
154 return $response->content;
156 warn $response->status_line;
166 Koha Development Team <info@koha.org>
168 Galen Charlton <galen.charlton@liblime.com>