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

(-)a/Koha/REST/V1/CirculationRules.pm (-1 / +4 lines)
Lines 51-57 sub list_rules { Link Here
51
51
52
    return try {
52
    return try {
53
        my $effective       = $c->param('effective') // 1;
53
        my $effective       = $c->param('effective') // 1;
54
        my $kinds           = $c->param('rules')     // [ keys %{ Koha::CirculationRules->rule_kinds } ];
54
        my $kinds =
55
            defined( $c->param('rules') )
56
            ? [ split /\s*,\s*/, $c->param('rules') ]
57
            : [ keys %{ Koha::CirculationRules->rule_kinds } ];
55
        my $item_type       = $c->param('item_type_id');
58
        my $item_type       = $c->param('item_type_id');
56
        my $branchcode      = $c->param('library_id');
59
        my $branchcode      = $c->param('library_id');
57
        my $patron_category = $c->param('patron_category_id');
60
        my $patron_category = $c->param('patron_category_id');
(-)a/api/v1/swagger/paths/circulation_rules.yaml (-1 / +1 lines)
Lines 36-42 Link Here
36
        type: array
36
        type: array
37
        items:
37
        items:
38
          type: string
38
          type: string
39
        collectionFormat: multi
39
        collectionFormat: csv
40
    responses:
40
    responses:
41
      "200":
41
      "200":
42
        description: A list of rules for this item type, library and patron category combination
42
        description: A list of rules for this item type, library and patron category combination
(-)a/t/db_dependent/api/v1/circulation_rules.t (-3 / +6 lines)
Lines 36-42 subtest 'list_rules() tests' => sub { Link Here
36
36
37
    my $expected_rules = [ keys %{ Koha::CirculationRules->rule_kinds } ];
37
    my $expected_rules = [ keys %{ Koha::CirculationRules->rule_kinds } ];
38
38
39
    plan tests => ( scalar( @{$expected_rules} ) * 2 ) + 36;
39
    plan tests => ( scalar( @{$expected_rules} ) * 2 ) + 39;
40
40
41
    $schema->storage->txn_begin;
41
    $schema->storage->txn_begin;
42
42
Lines 139-147 subtest 'list_rules() tests' => sub { Link Here
139
        );
139
        );
140
140
141
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules")->status_is(200)
141
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules")->status_is(200)
142
        ->json_is( '/0/fine'     => 2, "Defaul fine rule returned when no library is added to request query" )
142
        ->json_is( '/0/fine'     => 2, "Default fine rule returned when no library is added to request query" )
143
        ->json_is( '/0/finedays' => 5, "Default finedays rule returned when no library is added to request query" );
143
        ->json_is( '/0/finedays' => 5, "Default finedays rule returned when no library is added to request query" );
144
144
145
    # Limit to only rules we're interested in
146
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules=fine,finedays")->status_is(200)
147
        ->json_is( '/0' => { fine => 2, finedays => 5 }, "Only the two rules we asked for are returned" );
148
145
    # Warn on unsupported query parameter
149
    # Warn on unsupported query parameter
146
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules_blah=blah")->status_is(400)
150
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules_blah=blah")->status_is(400)
147
        ->json_is( [ { path => '/query/rules_blah', message => 'Malformed query string' } ] );
151
        ->json_is( [ { path => '/query/rules_blah', message => 'Malformed query string' } ] );
148
- 

Return to bug 36641