1 # Copyright 2016 Catalyst
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 package Koha
::ExternalContent
::RecordedBooks
;
23 use base
qw(Koha::ExternalContent);
24 use WebService
::ILS
::RecordedBooks
::PartnerPatron
;
25 use WebService
::ILS
::RecordedBooks
::Partner
;
29 use constant logger
=> Koha
::Logger
->get();
31 __PACKAGE__
->mk_accessors(qw(domain is_identified));
35 Koha::ExternalContent::RecordedBooks
39 use Koha::ExternalContent::RecordedBooks;
40 my $rb_client = Koha::ExternalContent::RecordedBooks->new();
41 my $rb_auth_url = $od_client->auth_url();
45 A (very) thin wrapper around C<WebService::ILS::RecordedBooks::Patron>
47 Takes "RecordedBooks*" Koha preferences
57 my $rb_client = Koha::ExternalContent::RecordedBooks->new();
59 Create the object for interacting with RecordedBooks
65 my $params = shift || {};
67 my $self = $class->SUPER::new
($params);
68 unless ($params->{client
}) {
69 my $client_secret = C4
::Context
->preference('RecordedBooksClientSecret')
70 or croak
("RecordedBooksClientSecret pref not set");
71 my $library_id = C4
::Context
->preference('RecordedBooksLibraryID')
72 or croak
("RecordedBooksLibraryID pref not set");
73 my $domain = C4
::Context
->preference('RecordedBooksDomain');
74 my $patron = $params->{koha_session_id
} ?
$self->koha_patron : undef;
77 $email = $patron->email
78 or $self->logger->warn("User with no email, cannot identify with RecordedBooks");
83 $client = eval { WebService
::ILS
::RecordedBooks
::PartnerPatron
->new(
84 client_secret
=> $client_secret,
85 library_id
=> $library_id,
89 $self->logger->warn("Invalid RecordedBooks user $email ($@)") if $@
;
90 $self->is_identified($client);
92 $client ||= WebService
::ILS
::RecordedBooks
::Partner
->new(
93 client_secret
=> $client_secret,
94 library_id
=> $library_id,
97 $self->client( $client );
104 L<WebService::ILS::RecordedBooks::PartnerPatron> methods used without mods:
108 =item C<error_message()>
114 use vars
qw{$AUTOLOAD};
117 (my $method = $AUTOLOAD) =~ s/.*:://;
118 return $self->client->$method(@_);