View | Details | Raw Unified | Return to bug 35581
Collapse All | Expand All

(-)a/Koha/Illbackend.pm (-6 / +6 lines)
Lines 1-4 Link Here
1
package Koha::Illbackend;
1
package Koha::ILL::Backend;
2
2
3
# Copyright PTFS Europe 2023
3
# Copyright PTFS Europe 2023
4
#
4
#
Lines 23-41 use base qw(Koha::Object); Link Here
23
23
24
=head1 NAME
24
=head1 NAME
25
25
26
Koha::Illbackend - Koha Illbackend Object class
26
Koha::ILL::Backend - Koha Illbackend Object class
27
27
28
=head2 Class methods
28
=head2 Class methods
29
29
30
=head3 new
30
=head3 new
31
31
32
New illbackend
32
New ILL Backend
33
33
34
=cut
34
=cut
35
35
36
sub new {
36
sub new {
37
    my $class = shift;
37
    my $class = shift;
38
    my $self = {};
38
    my $self  = {};
39
    return bless $self, $class;
39
    return bless $self, $class;
40
}
40
}
41
41
Lines 119-125 sub embed { Link Here
119
119
120
    foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
120
    foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
121
        if ( $embed_req eq 'statuses+strings' ) {
121
        if ( $embed_req eq 'statuses+strings' ) {
122
            $return_embed->{statuses} = $self->existing_statuses( $backend_id );
122
            $return_embed->{statuses} = $self->existing_statuses($backend_id);
123
        }
123
        }
124
    }
124
    }
125
    return $return_embed;
125
    return $return_embed;
Lines 129-135 sub embed { Link Here
129
129
130
=head3 _type
130
=head3 _type
131
131
132
    my $type = Koha::Illbackend->_type;
132
    my $type = Koha::ILL::Backend->_type;
133
133
134
Return this object's type
134
Return this object's type
135
135
(-)a/Koha/REST/V1/Illbackends.pm (-24 / +24 lines)
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" }
(-)a/api/v1/swagger/paths/ill_backends.yaml (-4 / +4 lines)
Lines 1-8 Link Here
1
---
1
---
2
/ill/backends:
2
/ill/backends:
3
  get:
3
  get:
4
    x-mojo-to: Illbackends#list
4
    x-mojo-to: ILL::Backends#list
5
    operationId: listIllbackends
5
    operationId: listIllBackends
6
    tags:
6
    tags:
7
      - ill_backends
7
      - ill_backends
8
    summary: List ILL backends
8
    summary: List ILL backends
Lines 52-59 Link Here
52
        ill: "1"
52
        ill: "1"
53
"/ill/backends/{ill_backend_id}":
53
"/ill/backends/{ill_backend_id}":
54
  get:
54
  get:
55
    x-mojo-to: Illbackends#get
55
    x-mojo-to: ILL::Backends#get
56
    operationId: getIllbackends
56
    operationId: getIllBackends
57
    tags:
57
    tags:
58
      - ill_backends
58
      - ill_backends
59
    summary: Get ILL backend
59
    summary: Get ILL backend
(-)a/t/db_dependent/Koha/Illbackend.t (-4 / +3 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 1;
23
23
24
use Koha::Illbackend;
24
use Koha::ILL::Backend;
25
25
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
27
use t::lib::Mocks;
27
use t::lib::Mocks;
Lines 36-42 subtest 'existing_statuses() tests' => sub { Link Here
36
    $schema->storage->txn_begin;
36
    $schema->storage->txn_begin;
37
    Koha::Illrequests->search->delete;
37
    Koha::Illrequests->search->delete;
38
38
39
    # Mock ILLBackend (as object)
39
    # Mock external ILLBackend (as object)
40
    my $backend = Test::MockObject->new;
40
    my $backend = Test::MockObject->new;
41
    $backend->set_isa('Koha::Illbackends::Mock');
41
    $backend->set_isa('Koha::Illbackends::Mock');
42
    $backend->set_always( 'name', 'Mock' );
42
    $backend->set_always( 'name', 'Mock' );
Lines 133-139 subtest 'existing_statuses() tests' => sub { Link Here
133
        }
133
        }
134
    );
134
    );
135
135
136
    my $backend_module = Koha::Illbackend->new;
136
    my $backend_module = Koha::ILL::Backend->new;
137
137
138
    my $existing_statuses = $backend_module->existing_statuses('Mock');
138
    my $existing_statuses = $backend_module->existing_statuses('Mock');
139
139
140
- 

Return to bug 35581