1 package Koha::REST::V1::ImportBatchProfiles;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Mojo::Base 'Mojolicious::Controller';
22 use Koha::ImportBatchProfiles;
23 use Koha::ImportBatchProfile;
25 use Try::Tiny qw( catch try );
29 Koha::REST::V1::ImportBatchProfiles - Koha REST API for handling profiles for import batches (V1)
39 Method that handles listing Koha::ImportBatchProfile objects
44 my $c = shift->openapi->valid_input or return;
47 my $profiles_set = Koha::ImportBatchProfiles->new;
48 my $profiles = $c->objects->search( $profiles_set );
55 $c->unhandled_exception($_);
61 Method that handles adding a new Koha::ImportBatchProfile object
66 my $c = shift->openapi->valid_input or return;
68 my $body = $c->validation->param('body');
71 my $profile = Koha::ImportBatchProfile->new_from_api( $body )->store;
74 openapi => $profile->to_api
78 $c->unhandled_exception($_);
84 Method that handles modifying a Koha::Hold object
89 my $c = shift->openapi->valid_input or return;
92 my $profile_id = $c->validation->param('import_batch_profile_id');
93 my $profile = Koha::ImportBatchProfiles->find( $profile_id );
95 return $c->render( status => 404,
96 openapi => {error => "Import batch profile not found"} );
99 my $body = $c->req->json;
101 $profile->set_from_api($body)->store;
105 openapi => $profile->to_api
109 $c->unhandled_exception($_);
115 Method that handles deleting a Koha::ImportBatchProfile object
120 my $c = shift->openapi->valid_input or return;
122 my $profile_id = $c->validation->param('import_batch_profile_id');
123 my $profile = Koha::ImportBatchProfiles->find( $profile_id );
126 return $c->render( status => 404,
127 openapi => {error => "Import batch profile not found"} );
139 $c->unhandled_exception($_);