|
Lines 1-4
Link Here
|
| 1 |
package Koha::REST::V1::Hold; |
1 |
package Koha::REST::V1::Holds; |
| 2 |
|
2 |
|
| 3 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
| 4 |
# |
4 |
# |
|
Lines 181-190
sub add {
Link Here
|
| 181 |
if ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { |
181 |
if ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { |
| 182 |
my $broken_fk = $_->broken_fk; |
182 |
my $broken_fk = $_->broken_fk; |
| 183 |
|
183 |
|
| 184 |
if ( grep { $_ eq $broken_fk } keys %{$Koha::REST::V1::Hold::to_api_mapping} ) { |
184 |
if ( grep { $_ eq $broken_fk } keys %{$Koha::REST::V1::Holds::to_api_mapping} ) { |
| 185 |
$c->render( |
185 |
$c->render( |
| 186 |
status => 404, |
186 |
status => 404, |
| 187 |
openapi => $Koha::REST::V1::Hold::to_api_mapping->{$broken_fk} . ' not found.' |
187 |
openapi => $Koha::REST::V1::Holds::to_api_mapping->{$broken_fk} . ' not found.' |
| 188 |
); |
188 |
); |
| 189 |
} |
189 |
} |
| 190 |
else { |
190 |
else { |
|
Lines 284-291
sub _to_api {
Link Here
|
| 284 |
my $hold = shift; |
284 |
my $hold = shift; |
| 285 |
|
285 |
|
| 286 |
# Rename attributes |
286 |
# Rename attributes |
| 287 |
foreach my $column ( keys %{ $Koha::REST::V1::Hold::to_api_mapping } ) { |
287 |
foreach my $column ( keys %{ $Koha::REST::V1::Holds::to_api_mapping } ) { |
| 288 |
my $mapped_column = $Koha::REST::V1::Hold::to_api_mapping->{$column}; |
288 |
my $mapped_column = $Koha::REST::V1::Holds::to_api_mapping->{$column}; |
| 289 |
if ( exists $hold->{ $column } |
289 |
if ( exists $hold->{ $column } |
| 290 |
&& defined $mapped_column ) |
290 |
&& defined $mapped_column ) |
| 291 |
{ |
291 |
{ |
|
Lines 313-320
attribute names.
Link Here
|
| 313 |
sub _to_model { |
313 |
sub _to_model { |
| 314 |
my $hold = shift; |
314 |
my $hold = shift; |
| 315 |
|
315 |
|
| 316 |
foreach my $attribute ( keys %{ $Koha::REST::V1::Hold::to_model_mapping } ) { |
316 |
foreach my $attribute ( keys %{ $Koha::REST::V1::Holds::to_model_mapping } ) { |
| 317 |
my $mapped_attribute = $Koha::REST::V1::Hold::to_model_mapping->{$attribute}; |
317 |
my $mapped_attribute = $Koha::REST::V1::Holds::to_model_mapping->{$attribute}; |
| 318 |
if ( exists $hold->{ $attribute } |
318 |
if ( exists $hold->{ $attribute } |
| 319 |
&& defined $mapped_attribute ) |
319 |
&& defined $mapped_attribute ) |
| 320 |
{ |
320 |
{ |