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

(-)a/Koha/AdditionalContent.pm (+37 lines)
Lines 142-147 sub translated_content { Link Here
142
    return $content;
142
    return $content;
143
}
143
}
144
144
145
=head3 public_read_list
146
147
This method returns the list of publicly readable database fields for both API and UI output purposes
148
149
=cut
150
151
sub public_read_list {
152
    return [
153
        'id',         'category',       'code',
154
        'location',   'branchcode',     'published_on',
155
        'updated_on', 'expirationdate', 'number',
156
        'borrowernumber'
157
    ];
158
}
159
160
=head3 to_api_mapping
161
162
This method returns the mapping for representing a Koha::AdditionalContent object
163
on the API.
164
165
=cut
166
167
sub to_api_mapping {
168
    return {
169
        id             => 'additional_content_id',
170
        category       => 'category',
171
        code           => 'code',
172
        location       => 'location',
173
        branchcode     => 'library_id',
174
        published_on   => 'published_on',
175
        updated_on     => 'updated_on',
176
        expirationdate => 'expirationdate',
177
        number         => 'number',
178
        borrowernumber => 'patron_id',
179
    };
180
}
181
145
=head3 _type
182
=head3 _type
146
183
147
=cut
184
=cut
(-)a/Koha/REST/V1/AdditionalContents.pm (+60 lines)
Line 0 Link Here
1
package Koha::REST::V1::AdditionalContents;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::AdditionalContents;
23
24
use Try::Tiny qw( catch try );
25
26
=head1 API
27
28
=head2 Methods
29
30
=head3 list_public
31
32
Controller function that handles retrieving a list of additional contents
33
34
=cut
35
36
sub list_public {
37
    my $c = shift->openapi->valid_input or return;
38
39
    return try {
40
41
        my @public_locations = (
42
            @{ Koha::AdditionalContents::get_html_customizations_options('opac') },
43
            'staff_and_opac',
44
            'opac_only'
45
        );
46
47
        my $public_additional_contents_query =
48
            Koha::AdditionalContents::get_public_query_search_params( { location => { '-in' => \@public_locations } } );
49
50
        my $additional_contents =
51
            $c->objects->search( Koha::AdditionalContents->search($public_additional_contents_query) );
52
53
        return $c->render( status => 200, openapi => $additional_contents );
54
    } catch {
55
        $c->unhandled_exception($_);
56
    };
57
58
}
59
60
1;
(-)a/api/v1/swagger/definitions/additional_content.yaml (+43 lines)
Line 0 Link Here
1
---
2
additionalProperties: false
3
properties:
4
  additional_content_id:
5
    description: Internal identifier for the additional content
6
    type: integer
7
  category:
8
    description: Category of the additional content
9
    type: string
10
  code:
11
    description: Code of the additional content
12
    type: string
13
  location:
14
    description: Location of the additional content
15
    type: string
16
  library_id:
17
    description: Library id of the additional content
18
    type:
19
      - string
20
      - "null"
21
  published_on:
22
    description: Publication date of the additional content
23
    type: string
24
  updated_on:
25
    description: Last modification date of the additional content
26
    type: string
27
  expirationdate:
28
    description: Expiration date of the additional content
29
    type: string
30
  number:
31
    description: The order in which this additional content appears in that specific location
32
    type: integer
33
  patron_id:
34
    description: The author of the additional content
35
    type:
36
      - string
37
      - "null"
38
required:
39
  - additional_content_id
40
  - category
41
  - code
42
  - location
43
type: object
(-)a/api/v1/swagger/paths/additional_contents.yaml (+68 lines)
Line 0 Link Here
1
---
2
"/public/additional_contents":
3
  get:
4
    x-mojo-to: AdditionalContents#list_public
5
    operationId: listAdditionalContents
6
    parameters:
7
      - description: Case insensitive search on additional_contents id
8
        in: query
9
        name: additional_content_id
10
        required: false
11
        type: string
12
      - description: Case insensitive search on additional_contents category
13
        in: query
14
        name: category
15
        required: false
16
        type: string
17
      - description: Case insensitive search on additional_contents code
18
        in: query
19
        name: code
20
        required: false
21
        type: string
22
      - description: Case insensitive search on additional_contents location
23
        in: query
24
        name: location
25
        required: false
26
        type: string
27
      - description: Case insensitive search on additional_contents library_id
28
        in: query
29
        name: library_id
30
        required: false
31
        type: string
32
      - $ref: "../swagger.yaml#/parameters/match"
33
      - $ref: "../swagger.yaml#/parameters/order_by"
34
      - $ref: "../swagger.yaml#/parameters/page"
35
      - $ref: "../swagger.yaml#/parameters/per_page"
36
      - $ref: "../swagger.yaml#/parameters/q_param"
37
      - $ref: "../swagger.yaml#/parameters/q_body"
38
    produces:
39
      - application/json
40
    responses:
41
      200:
42
        description: A list of additional contents
43
        schema:
44
          items:
45
            $ref: ../swagger.yaml#/definitions/additional_content
46
          type: array
47
      400:
48
        description: |
49
          Bad request. Possible `error_code` attribute values:
50
51
            * `invalid_query`
52
        schema:
53
          $ref: "../swagger.yaml#/definitions/error"
54
      403:
55
        description: Access forbidden
56
        schema:
57
          $ref: ../swagger.yaml#/definitions/error
58
      500:
59
        description: Internal error
60
        schema:
61
          $ref: ../swagger.yaml#/definitions/error
62
      503:
63
        description: Under maintenance
64
        schema:
65
          $ref: ../swagger.yaml#/definitions/error
66
    summary: List public additional contents
67
    tags:
68
      - additional_contents
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 4-9 basePath: /api/v1 Link Here
4
definitions:
4
definitions:
5
  account_line:
5
  account_line:
6
    $ref: ./definitions/account_line.yaml
6
    $ref: ./definitions/account_line.yaml
7
  additional_content:
8
    $ref: ./definitions/additional_content.yaml
7
  advancededitormacro:
9
  advancededitormacro:
8
    $ref: ./definitions/advancededitormacro.yaml
10
    $ref: ./definitions/advancededitormacro.yaml
9
  allows_renewal:
11
  allows_renewal:
Lines 507-512 paths: Link Here
507
    $ref: ./paths/preservation_waiting_list.yaml#/~1preservation~1waiting-list~1items
509
    $ref: ./paths/preservation_waiting_list.yaml#/~1preservation~1waiting-list~1items
508
  "/preservation/waiting-list/items/{item_id}":
510
  "/preservation/waiting-list/items/{item_id}":
509
    $ref: "./paths/preservation_waiting_list.yaml#/~1preservation~1waiting-list~1items~1{item_id}"
511
    $ref: "./paths/preservation_waiting_list.yaml#/~1preservation~1waiting-list~1items~1{item_id}"
512
  "/public/additional_contents":
513
    $ref: ./paths/additional_contents.yaml#/~1public~1additional_contents
510
  "/public/biblios/{biblio_id}":
514
  "/public/biblios/{biblio_id}":
511
    $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}"
515
    $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}"
512
  "/public/checkouts/availability":
516
  "/public/checkouts/availability":
513
- 

Return to bug 39900