1 package C4::External::Syndetics;
2 # Copyright (C) 2006 LibLime
3 # <jmf at liblime dot com>
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
23 use HTTP::Request::Common;
28 use vars qw($VERSION @ISA @EXPORT);
35 &get_syndetics_summary
42 C4::External::Syndetics - Functions for retrieving Syndetics content in Koha
46 This module provides facilities for retrieving Syndetics.com content in Koha
48 =head2 get_syndetics_summary
52 my $syndetics_summary= &get_syndetics_summary( $xisbn );
56 Get Summary data from Syndetics
60 sub get_syndetics_summary {
64 $isbn = _normalize_match_point ($isbn);
66 # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2'
67 my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode');
69 my $url = "http://syndetics.com/index.aspx?isbn=$isbn/SUMMARY.XML&client=$syndetics_client_code&type=xw10";
71 my $content = get($url);
72 warn "could not retrieve $url" unless $content;
73 my $xmlsimple = XML::Simple->new();
74 my $response = $xmlsimple->XMLin(
76 forcearray => [ qw(Fld520) ],
78 # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a
79 my $summary = \@{$response->{VarFlds}->{VarDFlds}->{Notes}->{Fld520}} if $response;
80 return $summary if $summary;
83 sub get_syndetics_toc {
87 $isbn = _normalize_match_point ($isbn);
89 # grab the AWSAccessKeyId: mine is '0V5RRRRJZ3HR2RQFNHR2'
90 my $syndetics_client_code = C4::Context->preference('SyndeticsClientCode');
92 my $url = "http://syndetics.com/index.aspx?isbn=$isbn/TOC.XML&client=$syndetics_client_code&type=xw10";
94 my $content = get($url);
95 warn "could not retrieve $url" unless $content;
96 my $xmlsimple = XML::Simple->new();
97 my $response = $xmlsimple->XMLin(
99 forcearray => [ qw(Fld970) ],
101 # manipulate response USMARC VarFlds VarDFlds Notes Fld520 a
102 my $toc = \@{$response->{VarFlds}->{VarDFlds}->{SSIFlds}->{Fld970}} if $response;
106 sub _normalize_match_point {
107 my $match_point = shift;
108 (my $normalized_match_point) = $match_point =~ /([\d-]*[X]*)/;
109 $normalized_match_point =~ s/-//g;
111 return $normalized_match_point;
121 Joshua Ferraro <jmf@liblime.com>