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

(-)a/Koha/REST/V1/Patrons/OldHolds.pm (+66 lines)
Line 0 Link Here
1
package Koha::REST::V1::Patrons::OldHolds;
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::Patrons;
23
24
=head1 NAME
25
26
Koha::REST::V1::Patrons::OldHolds
27
28
=head1 API
29
30
=head2 Methods
31
32
=head3 list
33
34
Controller function that handles listing Koha::OldHold objects for the requested patron
35
36
=cut
37
38
sub list {
39
    my $c = shift->openapi->valid_input or return;
40
41
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
42
43
    unless ( $patron ) {
44
        return $c->render(
45
            status  => 404,
46
            openapi => {
47
                error => 'Patron not found'
48
            }
49
        );
50
    }
51
52
    return try {
53
54
        my $old_holds = $c->objects->search( $patron->old_holds );
55
56
        return $c->render(
57
            status  => 200,
58
            openapi => $old_holds
59
        );
60
    }
61
    catch {
62
        $c->unhandled_exception($_);
63
    };
64
}
65
66
1;
(-)a/api/v1/swagger/paths/patrons_old_holds.yaml (+62 lines)
Line 0 Link Here
1
---
2
"/patrons/{patron_id}/old_holds":
3
  get:
4
    x-mojo-to: Patrons::OldHolds#list
5
    operationId: getPatronOldHolds
6
    tags:
7
      - old_holds
8
    summary: List old holds for a patron
9
    parameters:
10
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
11
      - $ref: "../swagger.yaml#/parameters/match"
12
      - $ref: "../swagger.yaml#/parameters/order_by"
13
      - $ref: "../swagger.yaml#/parameters/page"
14
      - $ref: "../swagger.yaml#/parameters/per_page"
15
      - $ref: "../swagger.yaml#/parameters/q_param"
16
      - $ref: "../swagger.yaml#/parameters/q_body"
17
      - $ref: "../swagger.yaml#/parameters/request_id_header"
18
      - name: x-koha-embed
19
        in: header
20
        required: false
21
        description: Embed list sent as a request header
22
        type: array
23
        items:
24
          type: string
25
          enum:
26
            - cancellation_requested
27
          collectionFormat: csv
28
    produces:
29
      - application/json
30
    responses:
31
      "200":
32
        description: The patron old holds
33
        schema:
34
          type: array
35
          items:
36
            $ref: "../swagger.yaml#/definitions/hold"
37
      "401":
38
        description: Authentication required
39
        schema:
40
          $ref: "../swagger.yaml#/definitions/error"
41
      "403":
42
        description: Access forbidden
43
        schema:
44
          $ref: "../swagger.yaml#/definitions/error"
45
      "404":
46
        description: Patron not found
47
        schema:
48
          $ref: "../swagger.yaml#/definitions/error"
49
      "500":
50
        description: |
51
          Internal server error. Possible `error_code` attribute values:
52
53
          * `internal_server_error`
54
        schema:
55
          $ref: "../swagger.yaml#/definitions/error"
56
      "503":
57
        description: Under maintenance
58
        schema:
59
          $ref: "../swagger.yaml#/definitions/error"
60
    x-koha-authorization:
61
      permissions:
62
        borrowers: edit_borrowers
(-)a/api/v1/swagger/swagger.yaml (-1 / +2 lines)
Lines 409-414 paths: Link Here
409
    $ref: "./paths/patrons_extended_attributes.yaml#/~1patrons~1{patron_id}~1extended_attributes~1{extended_attribute_id}"
409
    $ref: "./paths/patrons_extended_attributes.yaml#/~1patrons~1{patron_id}~1extended_attributes~1{extended_attribute_id}"
410
  "/patrons/{patron_id}/holds":
410
  "/patrons/{patron_id}/holds":
411
    $ref: "./paths/patrons_holds.yaml#/~1patrons~1{patron_id}~1holds"
411
    $ref: "./paths/patrons_holds.yaml#/~1patrons~1{patron_id}~1holds"
412
  "/patrons/{patron_id}/old_holds":
413
    $ref: "./paths/patrons_old_holds.yaml#/~1patrons~1{patron_id}~1old_holds"
412
  "/patrons/{patron_id}/password":
414
  "/patrons/{patron_id}/password":
413
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password"
415
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password"
414
  "/patrons/{patron_id}/password/expiration_date":
416
  "/patrons/{patron_id}/password/expiration_date":
415
- 

Return to bug 35247