1 # Copyright 2016 Catalyst
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 package Koha
::ExternalContent
::RecordedBooks
;
23 use base
qw(Koha::ExternalContent);
24 use WebService
::ILS
::RecordedBooks
::PartnerPatron
;
25 use WebService
::ILS
::RecordedBooks
::Partner
;
28 __PACKAGE__
->mk_accessors(qw(domain is_identified));
32 Koha::ExternalContent::RecordedBooks
36 use Koha::ExternalContent::RecordedBooks;
37 my $rb_client = Koha::ExternalContent::RecordedBooks->new();
38 my $rb_auth_url = $od_client->auth_url();
42 A (very) thin wrapper around C<WebService::ILS::RecordedBooks::Patron>
44 Takes "RecordedBooks*" Koha preferences
54 my $rb_client = Koha::ExternalContent::RecordedBooks->new();
56 Create the object for interacting with RecordedBooks
62 my $params = shift || {};
64 my $self = $class->SUPER::new
($params);
65 unless ($params->{client
}) {
66 my $client_secret = C4
::Context
->preference('RecordedBooksClientSecret')
67 or croak
("RecordedBooksClientSecret pref not set");
68 my $library_id = C4
::Context
->preference('RecordedBooksLibraryID')
69 or croak
("RecordedBooksLibraryID pref not set");
70 my $domain = C4
::Context
->preference('RecordedBooksDomain');
71 my $patron = $params->{koha_session_id
} ?
$self->koha_patron : undef;
74 $email = $patron->email
75 or $self->logger->warn("User with no email, cannot identify with RecordedBooks");
80 $client = eval { WebService
::ILS
::RecordedBooks
::PartnerPatron
->new(
81 client_secret
=> $client_secret,
82 library_id
=> $library_id,
86 $self->logger->warn("Invalid RecordedBooks user $email ($@)") if $@
;
87 $self->is_identified($client);
89 $client ||= WebService
::ILS
::RecordedBooks
::Partner
->new(
90 client_secret
=> $client_secret,
91 library_id
=> $library_id,
94 $self->client( $client );
101 L<WebService::ILS::RecordedBooks::PartnerPatron> methods used without mods:
105 =item C<error_message()>
111 use vars
qw{$AUTOLOAD};
114 (my $method = $AUTOLOAD) =~ s/.*:://;
115 return $self->client->$method(@_);