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

(-)a/Koha/Patron.pm (+18 lines)
Lines 519-524 sub get_overdues { Link Here
519
    return $issues;
519
    return $issues;
520
}
520
}
521
521
522
=head3 get_suggestions
523
524
my $suggestions = $patron->get_suggestions
525
526
Return user's suggestions
527
528
=cut
529
530
sub get_suggestions {
531
    my ($self) = @_;
532
    my $suggestions = Koha::Suggestions->search(
533
        {
534
            'suggestedby' => $self->borrowernumber
535
        }
536
    );
537
    return $suggestions;
538
}
539
522
=head3 type
540
=head3 type
523
541
524
=cut
542
=cut
(-)a/Koha/REST/V1.pm (+29 lines)
Lines 25-30 use Koha::Issues; Link Here
25
use Koha::Holds;
25
use Koha::Holds;
26
use Koha::OldIssues;
26
use Koha::OldIssues;
27
use Koha::Patrons;
27
use Koha::Patrons;
28
use Koha::Suggestions;
28
29
29
=head1 NAME
30
=head1 NAME
30
31
Lines 215-220 sub check_object_ownership { Link Here
215
        borrowernumber  => \&_object_ownership_by_borrowernumber,
216
        borrowernumber  => \&_object_ownership_by_borrowernumber,
216
        checkout_id     => \&_object_ownership_by_checkout_id,
217
        checkout_id     => \&_object_ownership_by_checkout_id,
217
        reserve_id      => \&_object_ownership_by_reserve_id,
218
        reserve_id      => \&_object_ownership_by_reserve_id,
219
        suggestionid      => \&_object_ownership_by_suggestionid,
220
        suggestedby      => \&_object_ownership_by_suggestedby,
218
    };
221
    };
219
222
220
    foreach my $param ( keys %{ $parameters } ) {
223
    foreach my $param ( keys %{ $parameters } ) {
Lines 291-294 sub _object_ownership_by_reserve_id { Link Here
291
    return $reserve && $user->borrowernumber == $reserve->borrowernumber;
294
    return $reserve && $user->borrowernumber == $reserve->borrowernumber;
292
}
295
}
293
296
297
=head3 _object_ownership_by_suggestionid
298
299
Finds a Koha::Suggestion-object by C<$suggestionid> and checks if it
300
belongs to C<$user>.
301
302
=cut
303
304
sub _object_ownership_by_suggestionid {
305
    my ($c, $user, $suggestionid) = @_;
306
307
    my $suggestion = Koha::Suggestions->find($suggestionid);
308
    return $suggestion && $user->borrowernumber == $suggestion->suggestedby;
309
}
310
311
=head3 _object_ownership_by_suggestedby
312
313
Compares C<$suggestedby> to currently logged in C<$user>.
314
315
=cut
316
317
sub _object_ownership_by_suggestedby {
318
    my ($c, $user, $suggestedby) = @_;
319
320
    return $user->borrowernumber == $suggestedby;
321
}
322
294
1;
323
1;
(-)a/Koha/REST/V1/Suggestions.pm (+264 lines)
Line 0 Link Here
1
package Koha::REST::V1::Suggestions;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use C4::Auth qw( haspermission );
23
use C4::Context;
24
use C4::Koha;
25
26
use Koha::Suggestion;
27
use Koha::Suggestions;
28
29
use Koha::ItemTypes;
30
use Koha::Libraries;
31
32
use Try::Tiny;
33
34
sub list {
35
    my ($c, $args, $cb) = @_;
36
37
    my $suggestions;
38
    my $filter;
39
    $args //= {};
40
41
    for my $filter_param ( keys %$args ) {
42
        $filter->{$filter_param} = { LIKE => $args->{$filter_param} . '%' };
43
    }
44
45
    return try {
46
        $suggestions = Koha::Suggestions->search($filter)->unblessed;
47
        return $c->$cb( $suggestions, 200 );
48
    }
49
    catch {
50
        if ( $_->isa('DBIx::Class::Exception') ) {
51
            return $c->$cb( { error => $_->{msg} }, 500 );
52
        }
53
        else {
54
            return $c->$cb(
55
                { error => 'Something went wrong, check the logs.' }, 500 );
56
        }
57
    };
58
}
59
60
sub get {
61
    my ($c, $args, $cb) = @_;
62
63
    my $suggestion = Koha::Suggestions->find($args->{suggestionid});
64
    unless ($suggestion) {
65
        return $c->$cb({error => 'Suggestion not found'}, 404);
66
    }
67
68
    return $c->$cb($suggestion->unblessed, 200);
69
}
70
71
sub add {
72
    my ( $c, $args, $cb ) = @_;
73
74
    my $error = _validate_body($c, $args, $cb, 0);
75
    return $error if $error;
76
77
    my $suggestion = Koha::Suggestion->new( $args->{body} );
78
79
    return try {
80
        $suggestion->store;
81
        return $c->$cb( $suggestion->unblessed, 200 );
82
    }
83
    catch {
84
        if ( $_->isa('DBIx::Class::Exception') ) {
85
            return $c->$cb( { error => $_->msg }, 500 );
86
        }
87
        else {
88
            return $c->$cb(
89
                { error => 'Something went wrong, check the logs.' }, 500 );
90
        }
91
    };
92
}
93
94
sub update {
95
    my ( $c, $args, $cb ) = @_;
96
97
    my $suggestion;
98
99
    return try {
100
101
        $suggestion = Koha::Suggestions->find( $args->{suggestionid} );
102
103
        my $body = $args->{body};
104
105
        # Remove unchaned fields so that we can use our body validation from the add subroutine
106
        foreach my $param ( keys %{ $body } ) {
107
            if (exists $body->{$param}) {
108
                delete $body->{$param} if $body->{$param} eq $suggestion->unblessed->{$param};
109
            }
110
        }
111
112
        my $error = _validate_body($c, $args, $cb, 1);
113
        return $error if $error;
114
115
        $suggestion->set( $body );
116
        $suggestion->store();
117
        return $c->$cb( $suggestion->unblessed, 200 );
118
    }
119
    catch {
120
        if ( not defined $suggestion ) {
121
            return $c->$cb( { error => 'Object not found' }, 404 );
122
        }
123
        elsif ( $_->isa('Koha::Exceptions::Object') ) {
124
            return $c->$cb( { error => $_->message }, 500 );
125
        }
126
        else {
127
            return $c->$cb(
128
                { error => 'Something went wrong, check the logs.' }, 500 );
129
        }
130
    };
131
132
}
133
134
sub delete {
135
    my ( $c, $args, $cb ) = @_;
136
137
    my $suggestion;
138
139
    return try {
140
        $suggestion = Koha::Suggestions->find( $args->{suggestionid} );
141
        $suggestion->delete;
142
        return $c->$cb( '', 200 );
143
    }
144
    catch {
145
        if ( not defined $suggestion ) {
146
            return $c->$cb( { error => 'Object not found' }, 404 );
147
        }
148
        elsif ( $_->isa('DBIx::Class::Exception') ) {
149
            return $c->$cb( { error => $_->msg }, 500 );
150
        }
151
        else {
152
            return $c->$cb(
153
                { error => 'Something went wrong, check the logs.' }, 500 );
154
        }
155
    };
156
157
}
158
159
sub _validate_body {
160
    my ( $c, $args, $cb, $updating ) = @_;
161
162
    my $body = $args->{body};
163
    my $user = $c->stash('koha.user');
164
165
    my $has_acquisition = C4::Auth::haspermission($user->userid, {acquisition => 1});
166
167
    if (not $has_acquisition) {
168
        # Regular user cannot change anything ...
169
        my @allowed_fields = ('suggestedby', 'title', 'author', 'copyrightdate', 'isbn',
170
            'publishercode', 'collectiontitle', 'place', 'itemtype', 'patronreason', 'note');
171
172
        # Hmm, how about branches?
173
        if ( C4::Context->preference('AllowPurchaseSuggestionBranchChoice') ) {
174
            push(@allowed_fields, 'branchcode');
175
        }
176
177
        foreach my $param ( keys %{ $body } ) {
178
            unless (/^$param$/ ~~ @allowed_fields) {
179
                # Ouch ! Some mandatory field is missing!
180
                my $verb = $updating ? 'updated ' : 'specified ';
181
                return $c->$cb({error => 'You ' . $verb . $param . ', but allowed fields are only ' .
182
                        join(', ', @allowed_fields)}, 403);
183
            }
184
        }
185
    }
186
187
    if (not $updating) {
188
        # Check for missing fields
189
        my @mandatory_fields = split /,/, C4::Context->preference('OPACSuggestionMandatoryFields');
190
        my @missing_fields = ();
191
        for my $mandatory_field (@mandatory_fields) {
192
            push(@missing_fields, $mandatory_field) if (not exists $body->{$mandatory_field});
193
        }
194
195
        if ( @missing_fields ) {
196
            return $c->$cb({error => 'Missing mandatory fields: ' . join(', ', @missing_fields)}, 400);
197
        }
198
    }
199
200
    # Is suggester anonymous?
201
    my $is_anonymous = not (defined $body->{suggestedby} and
202
        $body->{suggestedby} ne '' and
203
        $body->{suggestedby} ne C4::Context->preference('AnonymousPatron'));
204
205
    # Refuse if are anonymous suggestions disabled
206
    if ( $is_anonymous ) {
207
        return $c->$cb({error => 'Anonymous suggestions are disabled'}, 403)
208
        unless C4::Context->preference('AnonSuggestions');
209
    }
210
211
    # Refuse adding another suggestion if max reached for a user
212
    my $max_open_suggestions = C4::Context->preference('MaxOpenSuggestions');
213
    if ( $max_open_suggestions gt 0 and not $is_anonymous ) {
214
        my $count = Koha::Suggestions->search({suggestedby => $body->{suggestedby}})->count();
215
216
        return $c->$cb({error => 
217
                'You have ' . $count . ' opened suggestions out of ' . $max_open_suggestions}, 403)
218
        if ( $count >= $max_open_suggestions );
219
    }
220
221
    # Check STATUS is valid
222
    if ( exists $body->{STATUS} ) {
223
        return $c->$cb({error => 'STATUS must be one of ASKED, CHECKED, ACCEPTED, or REJECTED'}, 400)
224
        unless ($body->{STATUS} =~ m/^(ASKED|CHECKED|ACCEPTED|REJECTED)$/);
225
    }
226
227
    # Check itemtype is valid
228
    if ( exists $body->{itemtype} ) {
229
        my @item_types = map {$_->unblessed->{itemtype}} Koha::ItemTypes->search;
230
        return $c->$cb({error => 'itemtype must be one of ' . join(', ', @item_types)}, 400)
231
        unless /^$body->{itemtype}$/ ~~ @item_types;
232
    }
233
234
    # Check branchcode is valid
235
    if ( exists $body->{branchcode} ) {
236
        my @branch_codes = map {$_->unblessed->{branchcode}} Koha::Libraries->search;
237
        return $c->$cb({error => 'branchcode must be one of ' . join(', ', @branch_codes)}, 400)
238
        unless /^$body->{branchcode}$/ ~~ @branch_codes;
239
    }
240
241
    # Check patron reason is valid
242
    if ( exists $body->{patronreason} ) {
243
        my @authorized_values = map { $_->{authorised_value} } @{ C4::Koha::GetAuthorisedValues('OPAC_SUG') };
244
        return $c->$cb({error => 'patronreason must be one of ' . join(', ', @authorized_values)}, 400)
245
        unless /^$body->{patronreason}$/ ~~ @authorized_values;
246
    }
247
248
    # Check suggestedby patron exists
249
    if ( exists $body->{suggestedby} ) {
250
        return $c->$cb({error => 'suggestedby patron not found'}, 400)
251
        unless Koha::Patrons->find($body->{suggestedby});
252
    }
253
254
    # Check managedby patron exists
255
    if ( exists $body->{managedby} ) {
256
        return $c->$cb({error => 'managedby patron not found'}, 400)
257
        unless Koha::Patrons->find($body->{managedby});
258
    }
259
260
    # Everything's fine ..
261
    return 0;
262
}
263
264
1;
(-)a/api/v1/swagger/definitions.json (+3 lines)
Lines 11-16 Link Here
11
  "hold": {
11
  "hold": {
12
    "$ref": "definitions/hold.json"
12
    "$ref": "definitions/hold.json"
13
  },
13
  },
14
  "suggestion": {
15
    "$ref": "definitions/suggestion.json"
16
  },
14
  "error": {
17
  "error": {
15
    "$ref": "definitions/error.json"
18
    "$ref": "definitions/error.json"
16
  }
19
  }
(-)a/api/v1/swagger/definitions/suggestion.json (+131 lines)
Line 0 Link Here
1
{
2
  "type": "object",
3
  "properties": {
4
    "suggestionid": {
5
      "type": "string",
6
      "description": "unique identifier assigned automatically by Koha"
7
    },
8
    "suggestedby": {
9
      "type": "string",
10
      "description": "borrowernumber for the person making the suggestion, foreign key linking to the borrowers table"
11
    },
12
    "suggesteddate": {
13
      "type": "string",
14
      "description": "the suggestion was submitted"
15
    },
16
    "managedby": {
17
      "type": ["string", "null"],
18
      "description": "borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table"
19
    },
20
    "manageddate": {
21
      "type": ["string", "null"],
22
      "description": "date the suggestion was updated"
23
    },
24
    "acceptedby": {
25
      "type": ["string", "null"],
26
      "description": "borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table"
27
    },
28
    "accepteddate": {
29
      "type": ["string", "null"],
30
      "description": "date the suggestion was marked as accepted"
31
    },
32
    "rejectedby": {
33
      "type": ["string", "null"],
34
      "description": "borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table"
35
    },
36
    "rejecteddate": {
37
      "type": ["string", "null"],
38
      "description": "date the suggestion was marked as rejected"
39
    },
40
    "STATUS": {
41
      "type": "string",
42
      "description": "suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)"
43
    },
44
    "note": {
45
      "type": ["string", "null"],
46
      "description": "note entered on the suggestion"
47
    },
48
    "author": {
49
      "type": ["string", "null"],
50
      "description": "author of the suggested item"
51
    },
52
    "title": {
53
      "type": ["string", "null"],
54
      "description": "title of the suggested item"
55
    },
56
    "copyrightdate": {
57
      "type": ["string", "null"],
58
      "description": "copyright date of the suggested item"
59
    },
60
    "publishercode": {
61
      "type": ["string", "null"],
62
      "description": "publisher of the suggested item"
63
    },
64
    "date": {
65
      "type": ["string", "null"],
66
      "description": "date created"
67
    },
68
    "volumedesc": {
69
      "type": ["string", "null"],
70
      "description": "volume description"
71
    },
72
    "publicationyear": {
73
      "type": "string",
74
      "description": "year of publication"
75
    },
76
    "place": {
77
      "type": ["string", "null"],
78
      "description": "publication place of the suggested item"
79
    },
80
    "isbn": {
81
      "type": ["string", "null"],
82
      "description": "isbn of the suggested item"
83
    },
84
    "biblionumber": {
85
      "type": ["string", "null"],
86
      "description": "foreign key linking the suggestion to the biblio table after the suggestion has been ordered"
87
    },
88
    "reason": {
89
      "type": ["string", "null"],
90
      "description": "reason for accepting or rejecting the suggestion"
91
    },
92
    "patronreason": {
93
      "type": ["string", "null"],
94
      "description": "reason for making the suggestion"
95
    },
96
    "budgetid": {
97
      "type": ["string", "null"],
98
      "description": "foreign key linking the suggested budget to the aqbudgets table"
99
    },
100
    "branchcode": {
101
      "type": ["string", "null"],
102
      "description": "foreign key linking the suggested branch to the branches table"
103
    },
104
    "collectiontitle": {
105
      "type": ["string", "null"],
106
      "description": "collection name for the suggested item"
107
    },
108
    "itemtype": {
109
      "type": ["string", "null"],
110
      "description": "suggested item type"
111
    },
112
    "quantity": {
113
      "type": ["string", "null"],
114
      "description": "suggested quantity to be purchased"
115
    },
116
    "currency": {
117
      "type": ["string", "null"],
118
      "description": "suggested currency for the suggested price"
119
    },
120
    "price": {
121
      "type": ["string", "null"],
122
      "description": "suggested price"
123
    },
124
    "total": {
125
      "type": ["string", "null"],
126
      "description": "suggested total cost (price*quantity updated for currency)"
127
    }
128
  },
129
  "additionalProperties": false,
130
  "required": ["title"]
131
}
(-)a/api/v1/swagger/parameters.json (+3 lines)
Lines 10-14 Link Here
10
  },
10
  },
11
  "holdIdPathParam": {
11
  "holdIdPathParam": {
12
    "$ref": "parameters/hold.json#/holdIdPathParam"
12
    "$ref": "parameters/hold.json#/holdIdPathParam"
13
  },
14
  "suggestionidPathParam": {
15
    "$ref": "parameters/suggestion.json#/suggestionidPathParam"
13
  }
16
  }
14
}
17
}
(-)a/api/v1/swagger/parameters/suggestion.json (+9 lines)
Line 0 Link Here
1
{
2
  "suggestionidPathParam": {
3
    "name": "suggestionid",
4
    "in": "path",
5
    "description": "Internal suggestion identifier",
6
    "required": true,
7
    "type": "integer"
8
  }
9
}
(-)a/api/v1/swagger/paths.json (+6 lines)
Lines 16-20 Link Here
16
  },
16
  },
17
  "/patrons/{borrowernumber}": {
17
  "/patrons/{borrowernumber}": {
18
    "$ref": "paths/patrons.json#/~1patrons~1{borrowernumber}"
18
    "$ref": "paths/patrons.json#/~1patrons~1{borrowernumber}"
19
  },
20
  "/suggestions": {
21
    "$ref": "paths/suggestions.json#/~1suggestions"
22
  },
23
  "/suggestions/{suggestionid}": {
24
    "$ref": "paths/suggestions.json#/~1suggestions~1{suggestionid}"
19
  }
25
  }
20
}
26
}
(-)a/api/v1/swagger/paths/suggestions.json (-1 / +311 lines)
Line 0 Link Here
0
- 
1
{
2
  "/suggestions": {
3
    "get": {
4
      "x-mojo-controller": "Koha::REST::V1::Suggestions",
5
      "operationId": "list",
6
      "tags": ["patrons", "suggestions"],
7
      "parameters": [
8
        {
9
          "name": "suggestionid",
10
          "in": "query",
11
          "type": "integer",
12
          "description": "Internal suggestion identifier"
13
        },
14
        {
15
          "name": "suggestedby",
16
          "in": "query",
17
          "type": "integer",
18
          "description": "borrowernumber for the person making the suggestion, foreign key linking to the borrowers table"
19
        },
20
        {
21
          "name": "managedby",
22
          "in": "query",
23
          "type": "integer",
24
          "description": "borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table"
25
        },
26
        {
27
          "name": "acceptedby",
28
          "in": "query",
29
          "type": "integer",
30
          "description": "borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table"
31
        },
32
        {
33
          "name": "rejectedby",
34
          "in": "query",
35
          "type": "integer",
36
          "description": "borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table"
37
        },
38
        {
39
          "name": "STATUS",
40
          "in": "query",
41
          "type": "string",
42
          "description": "suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)"
43
        },
44
        {
45
          "name": "author",
46
          "in": "query",
47
          "type": "string",
48
          "description": "author of the suggested item"
49
        },
50
        {
51
          "name": "title",
52
          "in": "query",
53
          "type": "string",
54
          "description": "title of the suggested item"
55
        },
56
        {
57
          "name": "publishercode",
58
          "in": "query",
59
          "type": "string",
60
          "description": "publisher of the suggested item"
61
        },
62
        {
63
          "name": "date",
64
          "in": "query",
65
          "type": "string",
66
          "description": "date created"
67
        },
68
        {
69
          "name": "publicationyear",
70
          "in": "query",
71
          "type": "string",
72
          "description": "year of publication"
73
        },
74
        {
75
          "name": "isbn",
76
          "in": "query",
77
          "type": "string",
78
          "description": "isbn of the suggested item"
79
        },
80
        {
81
          "name": "collectiontitle",
82
          "in": "query",
83
          "type": "string",
84
          "description": "collection name for the suggested item"
85
        },
86
        {
87
          "name": "itemtype",
88
          "in": "query",
89
          "type": "string",
90
          "description": "suggested item type"
91
        }
92
      ],
93
      "produces": [
94
          "application/json"
95
      ],
96
      "responses": {
97
        "200": {
98
          "description": "A list of suggestions",
99
          "schema": {
100
            "type": "array",
101
            "items": {
102
              "$ref": "../definitions.json#/suggestion"
103
            }
104
          }
105
        },
106
        "403": {
107
          "description": "Access forbidden",
108
          "schema": {
109
            "$ref": "../definitions.json#/error"
110
          }
111
        }
112
      },
113
      "x-koha-authorization": {
114
        "allow-owner": true,
115
        "permissions": {
116
          "acquisition": "1"
117
        }
118
      }
119
    },
120
    "post": {
121
      "x-mojo-controller": "Koha::REST::V1::Suggestions",
122
      "operationId": "add",
123
      "tags": ["patrons", "suggestions"],
124
      "parameters": [{
125
        "name": "body",
126
        "in": "body",
127
        "description": "A JSON object containing informations about the new suggestion",
128
        "required": true,
129
        "schema": {
130
          "$ref": "../definitions.json#/suggestion"
131
        }
132
      }],
133
      "produces": [
134
        "application/json"
135
      ],
136
      "responses": {
137
        "200": {
138
          "description": "Suggestion added",
139
          "schema": {
140
            "$ref": "../definitions.json#/suggestion"
141
          }
142
        },
143
        "400": {
144
          "description": "Bad request",
145
          "schema": {
146
            "$ref": "../definitions.json#/error"
147
          }
148
        },
149
        "403": {
150
          "description": "Access forbidden",
151
          "schema": {
152
            "$ref": "../definitions.json#/error"
153
          }
154
        },
155
        "500": {
156
          "description": "Internal error",
157
          "schema": {
158
            "$ref": "../definitions.json#/error"
159
          }
160
        }
161
      },
162
      "x-koha-authorization": {
163
        "allow-owner": true,
164
        "permissions": {
165
          "acquisition": "1"
166
        }
167
      }
168
    }
169
  },
170
  "/suggestions/{suggestionid}": {
171
    "get": {
172
      "x-mojo-controller": "Koha::REST::V1::Suggestions",
173
      "operationId": "get",
174
      "tags": ["patrons", "suggestions"],
175
      "parameters": [{
176
          "$ref": "../parameters.json#/suggestionidPathParam"
177
        }
178
      ],
179
      "produces": [
180
          "application/json"
181
      ],
182
      "responses": {
183
        "200": {
184
          "description": "A suggestion",
185
          "schema": {
186
            "$ref": "../definitions.json#/suggestion"
187
          }
188
        },
189
        "403": {
190
          "description": "Access forbidden",
191
          "schema": {
192
            "$ref": "../definitions.json#/error"
193
          }
194
        },
195
        "404": {
196
          "description": "Suggestion not found",
197
          "schema": {
198
            "$ref": "../definitions.json#/error"
199
          }
200
        }
201
      },
202
      "x-koha-authorization": {
203
        "allow-owner": true,
204
        "allow-guarantor": true,
205
        "permissions": {
206
          "acquisition": "1"
207
        }
208
      }
209
    },
210
    "put": {
211
      "x-mojo-controller": "Koha::REST::V1::Suggestions",
212
      "operationId": "update",
213
      "tags": ["patrons", "suggestions"],
214
      "parameters": [{
215
        "$ref": "../parameters.json#/suggestionidPathParam"
216
      }, {
217
        "name": "body",
218
        "in": "body",
219
        "description": "A JSON object containing informations about the new hold",
220
        "required": true,
221
        "schema": {
222
          "$ref": "../definitions.json#/suggestion"
223
        }
224
      }],
225
      "produces": [
226
        "application/json"
227
      ],
228
      "responses": {
229
        "200": {
230
          "description": "A suggestion",
231
          "schema": {
232
            "$ref": "../definitions.json#/suggestion"
233
          }
234
        },
235
        "400": {
236
          "description": "Bad request",
237
          "schema": {
238
            "$ref": "../definitions.json#/error"
239
          }
240
        },
241
        "403": {
242
          "description": "Access forbidden",
243
          "schema": {
244
            "$ref": "../definitions.json#/error"
245
          }
246
        },
247
        "404": {
248
          "description": "Suggestion not found",
249
          "schema": {
250
            "$ref": "../definitions.json#/error"
251
          }
252
        },
253
        "500": {
254
          "description": "Internal error",
255
          "schema": {
256
            "$ref": "../definitions.json#/error"
257
          }
258
        }
259
      },
260
      "x-koha-authorization": {
261
        "allow-owner": true,
262
        "permissions": {
263
          "acquisition": "1"
264
        }
265
      }
266
    },
267
    "delete": {
268
      "x-mojo-controller": "Koha::REST::V1::Suggestions",
269
      "operationId": "delete",
270
      "tags": ["patrons", "suggestions"],
271
      "parameters": [{
272
        "$ref": "../parameters.json#/suggestionidPathParam"
273
      }],
274
      "produces": [
275
        "application/json"
276
      ],
277
      "responses": {
278
        "200": {
279
          "description": "Suggestion deleted",
280
          "schema": {
281
            "type": "string"
282
          }
283
        },
284
        "403": {
285
          "description": "Access forbidden",
286
          "schema": {
287
            "$ref": "../definitions.json#/error"
288
          }
289
        },
290
        "404": {
291
          "description": "Suggestion not found",
292
          "schema": {
293
            "$ref": "../definitions.json#/error"
294
          }
295
        },
296
        "500": {
297
          "description": "Internal error",
298
          "schema": {
299
            "$ref": "../definitions.json#/error"
300
          }
301
        }
302
      },
303
      "x-koha-authorization": {
304
        "allow-owner": true,
305
        "permissions": {
306
          "acquisition": "1"
307
        }
308
      }
309
    }
310
  }
311
}

Return to bug 17314