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

(-)a/Koha/REST/V1/CirculationRules.pm (+30 lines)
Lines 41-44 sub get_kinds { Link Here
41
    );
41
    );
42
}
42
}
43
43
44
45
=head3 list_effective_rules
46
47
List all effective rules for the requested patron/item/branch combination
48
49
=cut
50
51
sub list_effective_rules {
52
    my $c = shift->openapi->valid_input or return;
53
54
    my $item_type       = $c->param('itemtype');
55
    my $library         = $c->param('library');
56
    my $patron_category = $c->param('category');
57
    my $rules           = $c->param('rules') // [ keys %{Koha::CirculationRules->rule_kinds} ];
58
59
    my $effective_rules = Koha::CirculationRules->get_effective_rules(
60
        {
61
            categorycode => $patron_category,
62
            itemtype     => $item_type,
63
            branchcode   => $library,
64
            rules => $rules
65
        }
66
    );
67
68
    return $c->render(
69
        status  => 200,
70
        openapi => $effective_rules
71
    );
72
}
73
44
1;
74
1;
(-)a/api/v1/swagger/paths/circulation-rules.yaml (+55 lines)
Lines 30-32 Link Here
30
        description: Under maintenance
30
        description: Under maintenance
31
        schema:
31
        schema:
32
          $ref: "../swagger.yaml#/definitions/error"
32
          $ref: "../swagger.yaml#/definitions/error"
33
/circulation-rules/{itemtype}/{library}/{category}:
34
  get:
35
    x-mojo-to: CirculationRules#list_effective_rules
36
    operationId: listCirculationRules
37
    tags:
38
      - circulation_rules
39
    summary: Get circulation rules for this item/library/patron combination
40
    produces:
41
      - application/json
42
    parameters:
43
      - name: itemtype
44
        in: path
45
        description: The itemtype
46
        required: true
47
        type: string
48
      - name: library
49
        in: path
50
        description: The library code
51
        required: true
52
        type: string
53
      - name: category
54
        in: path
55
        description: The patron category
56
        required: true
57
        type: string
58
      - name: rules
59
        in: query
60
        description: A comma-separated list of rule kinds
61
        type: array
62
        items:
63
          type: string
64
        collectionFormat: csv
65
    responses:
66
      "200":
67
        description: A list of rules for this itemtype, library and patron category combination
68
        schema:
69
          type: object
70
      "403":
71
        description: Access forbidden
72
        schema:
73
          $ref: "../swagger.yaml#/definitions/error"
74
      "500":
75
        description: |
76
          Internal server error. Possible `error_code` attribute values:
77
78
          * `internal_server_error`
79
        schema:
80
          $ref: "../swagger.yaml#/definitions/error"
81
      "503":
82
        description: Under maintenance
83
        schema:
84
          $ref: "../swagger.yaml#/definitions/error"
85
    x-koha-authorization:
86
      permissions:
87
        - circulate: circulate_remaining_permissions
(-)a/api/v1/swagger/swagger.yaml (-1 / +2 lines)
Lines 281-286 paths: Link Here
281
    $ref: "./paths/checkouts.yaml#/~1checkouts~1availability"
281
    $ref: "./paths/checkouts.yaml#/~1checkouts~1availability"
282
  /circulation-rules/kinds:
282
  /circulation-rules/kinds:
283
    $ref: ./paths/circulation-rules.yaml#/~1circulation-rules~1kinds
283
    $ref: ./paths/circulation-rules.yaml#/~1circulation-rules~1kinds
284
  /circulation-rules/{itemtype}/{library}/{category}:
285
    $ref: ./paths/circulation-rules.yaml#/~1circulation-rules~1{itemtype}~1{library}~1{category}
284
  /cities:
286
  /cities:
285
    $ref: ./paths/cities.yaml#/~1cities
287
    $ref: ./paths/cities.yaml#/~1cities
286
  "/cities/{city_id}":
288
  "/cities/{city_id}":
287
- 

Return to bug 36641