3 # This file is part of Koha.
5 # Copyright 2020 Koha Development Team
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use JSON qw( to_json );
25 use C4::Auth qw( check_cookie_auth );
26 use Koha::AuthorisedValues;
30 svc/authorised_values - Web service for adding authorised values
36 our ( $query, $response ) = C4::Service->init( parameters => 'manage_auth_values' );
38 sub add_authorised_value {
39 my $category = $query->param('category');
40 my $value = $query->param('value');
41 my $description = $query->param('description');
42 my $opac_description = $query->param('opac_description');
43 my $image_url = $query->param('image_url');
46 my $av = Koha::AuthorisedValue->new(
48 category => $category,
49 authorised_value => $value,
51 lib_opac => $opac_description,
52 imageurl => $image_url,
57 category => $av->category,
58 value => $av->authorised_value,
59 description => $av->lib,
60 opac_description => $av->lib_opac,
61 image_url => $av->imageurl,
64 C4::Service->return_error ( $@ ) if $@;
66 C4::Service->return_success( $response );
69 C4::Service->dispatch(
70 [ 'POST /', [ 'category', 'value', 'description', 'opac_description' ], \&add_authorised_value ],