Lines 1-19
Link Here
|
1 |
package Koha::REST::V1::Illbackends; |
1 |
package Koha::REST::V1::ILL::Backends; |
2 |
|
2 |
|
3 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
4 |
# |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it under the |
5 |
# Koha is free software; you can redistribute it and/or modify it |
6 |
# terms of the GNU General Public License as published by the Free Software |
6 |
# under the terms of the GNU General Public License as published by |
7 |
# Foundation; either version 3 of the License, or (at your option) any later |
7 |
# the Free Software Foundation; either version 3 of the License, or |
8 |
# version. |
8 |
# (at your option) any later version. |
9 |
# |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
10 |
# Koha is distributed in the hope that it will be useful, but |
11 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
13 |
# GNU General Public License for more details. |
13 |
# |
14 |
# |
14 |
# You should have received a copy of the GNU General Public License along |
15 |
# You should have received a copy of the GNU General Public License |
15 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
Lines 21-31
use Mojo::Base 'Mojolicious::Controller';
Link Here
|
21 |
|
21 |
|
22 |
use Koha::Illrequest::Config; |
22 |
use Koha::Illrequest::Config; |
23 |
use Koha::Illrequests; |
23 |
use Koha::Illrequests; |
24 |
use Koha::Illbackend; |
24 |
use Koha::ILL::Backend; |
25 |
|
25 |
|
26 |
=head1 NAME |
26 |
=head1 NAME |
27 |
|
27 |
|
28 |
Koha::REST::V1::Illbackends |
28 |
Koha::REST::V1::ILL::Backends |
29 |
|
29 |
|
30 |
=head2 Operations |
30 |
=head2 Operations |
31 |
|
31 |
|
Lines 38-46
Return a list of available ILL backends and its capabilities
Link Here
|
38 |
sub list { |
38 |
sub list { |
39 |
my $c = shift->openapi->valid_input; |
39 |
my $c = shift->openapi->valid_input; |
40 |
|
40 |
|
41 |
my $config = Koha::Illrequest::Config->new; |
41 |
my $config = Koha::ILL::Request::Config->new; |
42 |
my $backends = $config->available_backends; |
42 |
my $backends = $config->available_backends; |
43 |
my $backend_module = Koha::Illbackend->new; |
43 |
my $backend_module = Koha::ILL::Backend->new; |
44 |
|
44 |
|
45 |
my @data; |
45 |
my @data; |
46 |
foreach my $b (@$backends) { |
46 |
foreach my $b (@$backends) { |
Lines 73-90
sub get {
Link Here
|
73 |
|
73 |
|
74 |
return try { |
74 |
return try { |
75 |
|
75 |
|
76 |
#FIXME: Should we move load_backend into Koha::Illbackend... |
76 |
#FIXME: Should we move load_backend into Koha::ILL::Backend... |
77 |
# or maybe make Koha::Ill::Backend a base class for all |
77 |
# or maybe make Koha::Ill::Backend a base class for all |
78 |
# backends? |
78 |
# backends? |
79 |
my $backend = Koha::Illrequest->new->load_backend($backend_id); |
79 |
my $backend = Koha::Illrequest->new->load_backend($backend_id); |
80 |
|
80 |
|
81 |
my $backend_module = Koha::Illbackend->new; |
81 |
my $backend_module = Koha::ILL::Backend->new; |
82 |
|
82 |
|
83 |
my $embed = |
83 |
my $embed = $backend_module->embed( |
84 |
$backend_module->embed( $backend_id, |
84 |
$backend_id, |
85 |
$c->req->headers->header('x-koha-embed') ); |
85 |
$c->req->headers->header('x-koha-embed') |
|
|
86 |
); |
86 |
|
87 |
|
87 |
#TODO: We need a to_api method in Koha::Illbackend |
88 |
#TODO: We need a to_api method in Koha::ILL::Backend |
88 |
my $return = { |
89 |
my $return = { |
89 |
ill_backend_id => $backend_id, |
90 |
ill_backend_id => $backend_id, |
90 |
capabilities => $backend->capabilities, |
91 |
capabilities => $backend->capabilities, |
Lines 94-101
sub get {
Link Here
|
94 |
status => 200, |
95 |
status => 200, |
95 |
openapi => $embed ? { %$return, %$embed } : $return, |
96 |
openapi => $embed ? { %$return, %$embed } : $return, |
96 |
); |
97 |
); |
97 |
} |
98 |
} catch { |
98 |
catch { |
|
|
99 |
return $c->render( |
99 |
return $c->render( |
100 |
status => 404, |
100 |
status => 404, |
101 |
openapi => { error => "ILL backend does not exist" } |
101 |
openapi => { error => "ILL backend does not exist" } |