|
Line 0
Link Here
|
|
|
1 |
# Copyright 2016 Catalyst |
| 2 |
# |
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 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 |
| 8 |
# version. |
| 9 |
# |
| 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. |
| 13 |
# |
| 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. |
| 17 |
|
| 18 |
package Koha::ExternalContent::OneClickDigital; |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
use Carp; |
| 22 |
|
| 23 |
use base qw(Koha::ExternalContent); |
| 24 |
use WebService::ILS::OneClickDigital::PartnerPatron; |
| 25 |
use C4::Context; |
| 26 |
use Koha::Logger; |
| 27 |
|
| 28 |
use constant logger => Koha::Logger->get(); |
| 29 |
|
| 30 |
=head1 NAME |
| 31 |
|
| 32 |
Koha::ExternalContent::OneClickDigital |
| 33 |
|
| 34 |
=head1 SYNOPSIS |
| 35 |
|
| 36 |
use Koha::ExternalContent::OneClickDigital; |
| 37 |
my $od_client = Koha::ExternalContent::OneClickDigital->new(); |
| 38 |
my $od_auth_url = $od_client->auth_url(); |
| 39 |
|
| 40 |
=head1 DESCRIPTION |
| 41 |
|
| 42 |
A (very) thin wrapper around C<WebService::ILS::OneClickDigital::Patron> |
| 43 |
|
| 44 |
Takes "OneClickDigital*" Koha preferences |
| 45 |
|
| 46 |
=cut |
| 47 |
|
| 48 |
sub new { |
| 49 |
my $class = shift; |
| 50 |
my $params = shift || {}; |
| 51 |
$params->{koha_session_id} or croak "No koha_session_id"; |
| 52 |
|
| 53 |
my $self = $class->SUPER::new($params); |
| 54 |
unless ($params->{client}) { |
| 55 |
my $client_secret = C4::Context->preference('OneClickDigitalClientSecret') |
| 56 |
or croak("OneClickDigitalClientSecret pref not set"); |
| 57 |
my $library_id = C4::Context->preference('OneClickDigitalLibraryID') |
| 58 |
or croak("OneClickDigitalLibraryID pref not set"); |
| 59 |
my $domain = C4::Context->preference('OneClickDigitalDomain'); |
| 60 |
my $patron = $self->koha_patron; |
| 61 |
$self->client( WebService::ILS::OneClickDigital::PartnerPatron->new( |
| 62 |
client_secret => $client_secret, |
| 63 |
library_id => $library_id, |
| 64 |
$domain && $domain gt '' ? (domain => $domain) : (), |
| 65 |
user_id => $patron->email, |
| 66 |
user_agent_params => { agent => $class->agent_string } |
| 67 |
) ); |
| 68 |
} |
| 69 |
return $self; |
| 70 |
} |
| 71 |
|
| 72 |
=head1 METHODS |
| 73 |
|
| 74 |
L<WebService::ILS::OneClickDigital::PartnerPatron> methods used without mods: |
| 75 |
|
| 76 |
=over 4 |
| 77 |
|
| 78 |
=item C<error_message()> |
| 79 |
|
| 80 |
=back |
| 81 |
|
| 82 |
=cut |
| 83 |
|
| 84 |
use vars qw{$AUTOLOAD}; |
| 85 |
sub AUTOLOAD { |
| 86 |
my $self = shift; |
| 87 |
(my $method = $AUTOLOAD) =~ s/.*:://; |
| 88 |
return $self->client->$method(@_); |
| 89 |
} |
| 90 |
sub DESTROY { } |
| 91 |
|
| 92 |
1; |