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

(-)a/Koha/REST/V1/PatronCategories.pm (+54 lines)
Line 0 Link Here
1
package Koha::REST::V1::PatronCategories;
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 Try::Tiny    qw( catch try );
23
24
=head1 NAME
25
26
Koha::REST::V1::PatronCategories
27
28
=head1 API
29
30
=head2 Methods
31
32
=head3 list
33
34
Controller function that handles listing Koha::Patron::Category objects
35
36
=cut
37
38
sub list {
39
    my $c = shift->openapi->valid_input or return;
40
41
    return try {
42
        my $patron_categories_rs = Koha::Patron::Categories->search;
43
        my $categories           = $c->objects->search($patron_categories_rs);
44
45
        return $c->render(
46
            status  => 200,
47
            openapi => $categories
48
        );
49
    } catch {
50
        $c->unhandled_exception($_);
51
    };
52
}
53
54
1;
(-)a/api/v1/swagger/definitions/patron_category.yaml (+106 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  patron_category_id:
5
    type: string
6
    description: Internal patron category identifier
7
  name:
8
    type:
9
      - string
10
      - "null"
11
    description: Name of the patron category
12
  enrolment_period:
13
    type:
14
      - number
15
      - "null"
16
    description: Number of months the patron is enrolled for
17
  enrolment_period_date:
18
    type:
19
      - string
20
      - "null"
21
    format: date
22
    description: Date the patron is enrolled until
23
  password_expiry_days:
24
    type:
25
      - number
26
      - "null"
27
    description: Number of days after which the patron must reset their password
28
    description: Date the patron is enrolled until
29
  upper_age_limit:
30
    type:
31
      - number
32
      - "null"
33
    description: Age limit for the patron
34
  date_of_birth_required:
35
    type:
36
      - boolean
37
      - "null"
38
    description: The minimum age required for the patron category
39
  enrolment_fee:
40
    type:
41
      - number
42
      - "null"
43
    description: Enrollment fee for the patron
44
  overdue_notice_required:
45
    type:
46
      - boolean
47
      - "null"
48
    description: Are overdue notices sent to this patron category (1 for yes, 0 for no)
49
  reserve_fee:
50
    type:
51
      - number
52
      - "null"
53
    description: Cost to place holds
54
  hide_lost_items:
55
    type: boolean
56
    description: Are lost items shown to this category (1 for yes, 0 for no)
57
  category_type:
58
    type: string
59
    description: Type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
60
  block_expired_patron_opac_actions:
61
    type: number
62
    description: Whether or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
63
  default_privacy:
64
    type: string
65
    enum:
66
      - default
67
      - never
68
      - forever
69
    description: Default privacy setting for this patron category
70
  check_prev_checkout:
71
    type: string
72
    description: Produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.'
73
  can_place_ill_in_opac:
74
    type: boolean
75
    description: Can this patron category place interlibrary loan requests
76
  can_be_guarantee:
77
    type: boolean
78
    description: If patrons of this category can be guarantees
79
  reset_password:
80
    type:
81
      - boolean
82
      - "null"
83
    description: If patrons of this category can do the password reset flow
84
  change_password:
85
    type:
86
      - boolean
87
      - "null"
88
    description: If patrons of this category can change their passwords in the OPAC
89
  min_password_length:
90
    type:
91
      - number
92
      - "null"
93
    description: Set minimum password length for patrons in this category
94
  require_strong_password:
95
    type:
96
      - boolean
97
      - "null"
98
    description: Set required password strength for patrons in this category
99
  exclude_from_local_holds_priority:
100
    type:
101
      - boolean
102
      - "null"
103
    description: Exclude patrons of this category from local holds priority
104
additionalProperties: false
105
required:
106
  - patron_category_id
(-)a/api/v1/swagger/paths/patron_categories.yaml (+40 lines)
Line 0 Link Here
1
---
2
/patron_categories:
3
  get:
4
    x-mojo-to: PatronCategories#list
5
    operationId: listPatronCategories
6
    tags:
7
      - patron_categories
8
    summary: List patron categories
9
    produces:
10
      - application/json
11
    parameters: []
12
    responses:
13
      "200":
14
        description: A list of patron categories
15
        schema:
16
          type: array
17
          items:
18
            $ref: "../swagger.yaml#/definitions/patron_category"
19
      "401":
20
        description: Authentication required
21
        schema:
22
          $ref: "../swagger.yaml#/definitions/error"
23
      "403":
24
        description: Access forbidden
25
        schema:
26
          $ref: "../swagger.yaml#/definitions/error"
27
      "500":
28
        description: |
29
          Internal server error. Possible `error_code` attribute values:
30
31
          * `internal_server_error`
32
        schema:
33
          $ref: "../swagger.yaml#/definitions/error"
34
      "503":
35
        description: Under maintenance
36
        schema:
37
          $ref: "../swagger.yaml#/definitions/error"
38
    x-koha-authorization:
39
      permissions:
40
        catalogue: "1"
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 126-131 definitions: Link Here
126
    $ref: ./definitions/patron_account_credit.yaml
126
    $ref: ./definitions/patron_account_credit.yaml
127
  patron_balance:
127
  patron_balance:
128
    $ref: ./definitions/patron_balance.yaml
128
    $ref: ./definitions/patron_balance.yaml
129
  patron_category:
130
    $ref: ./definitions/patron_category.yaml
129
  patron_extended_attribute:
131
  patron_extended_attribute:
130
    $ref: ./definitions/patron_extended_attribute.yaml
132
    $ref: ./definitions/patron_extended_attribute.yaml
131
  preservation_config:
133
  preservation_config:
Lines 423-428 paths: Link Here
423
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password"
425
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password"
424
  "/patrons/{patron_id}/password/expiration_date":
426
  "/patrons/{patron_id}/password/expiration_date":
425
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
427
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
428
  /patron_categories:
429
    $ref: ./paths/patron_categories.yaml#/~1patron_categories
426
  /preservation/config:
430
  /preservation/config:
427
    $ref: ./paths/preservation_config.yaml#/~1preservation~1config
431
    $ref: ./paths/preservation_config.yaml#/~1preservation~1config
428
  /preservation/trains:
432
  /preservation/trains:
429
- 

Return to bug 26297