Koha/Koha/AuthorisedValueCategory.pm
Pedro Amorim bbc0e8fe32
Bug 32997: Add REST API endpoint to list authorised values for multiple given categories
This patch adds /api/v1/authorised_value_categories endpoint that
retrieves authorised value categories for the given names and their
authorised values if x-koha-embed: authorised_values is also given.

To test:
Apply patch
curl -u koha:koha --request GET \"http://localhost:8081/api/v1/authorised_value_categories?q=%7B%22me.category_name%22%3A%5B%22LOC%22%2C%22YES_NO%22%5D%7D\" --header \"x-koha-embed:authorised_values\"

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-03-02 12:00:15 -03:00

71 lines
1.5 KiB
Perl

package Koha::AuthorisedValueCategory;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::Database;
use Koha::Exceptions;
use base qw(Koha::Object);
=head1 NAME
Koha::AuthorisedValueCategory - Koha AuthorisedValueCategory Object class
=head1 API
=head2 Class Methods
=cut
=head3 authorised_values
Returns the authorised values for this authorised value category
=cut
sub authorised_values {
my ( $self ) = @_;
my $authorised_values_rs = $self->_result->authorised_values;
return Koha::AuthorisedValues->_new_from_dbic($authorised_values_rs);
}
=head3 delete
Overridden delete method to prevent system default deletions
=cut
sub delete {
my ($self) = @_;
Koha::Exceptions::CannotDeleteDefault->throw if $self->is_system;
return $self->SUPER::delete;
}
=head3 type
=cut
sub _type {
return 'AuthorisedValueCategory';
}
1;