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 $patron = $self->koha_patron; |
60 |
$self->client( WebService::ILS::OneClickDigital::PartnerPatron->new( |
61 |
client_secret => $client_secret, |
62 |
library_id => $library_id, |
63 |
user_id => $patron->email, |
64 |
user_agent_params => { agent => $class->agent_string } |
65 |
) ); |
66 |
} |
67 |
return $self; |
68 |
} |
69 |
|
70 |
=head1 METHODS |
71 |
|
72 |
L<WebService::ILS::OneClickDigital::PartnerPatron> methods used without mods: |
73 |
|
74 |
=over 4 |
75 |
|
76 |
=item C<error_message()> |
77 |
|
78 |
=back |
79 |
|
80 |
=cut |
81 |
|
82 |
use vars qw{$AUTOLOAD}; |
83 |
sub AUTOLOAD { |
84 |
my $self = shift; |
85 |
(my $method = $AUTOLOAD) =~ s/.*:://; |
86 |
return $self->client->$method(@_); |
87 |
} |
88 |
sub DESTROY { } |
89 |
|
90 |
1; |