Lines 45-51
List Koha::Checkout objects
Link Here
|
45 |
sub list { |
45 |
sub list { |
46 |
my $c = shift->openapi->valid_input or return; |
46 |
my $c = shift->openapi->valid_input or return; |
47 |
|
47 |
|
48 |
my $checked_in = $c->validation->param('checked_in'); |
48 |
my $checked_in = delete $c->validation->output->{checked_in}; |
49 |
|
49 |
|
50 |
try { |
50 |
try { |
51 |
my $checkouts_set; |
51 |
my $checkouts_set; |
Lines 56-104
sub list {
Link Here
|
56 |
$checkouts_set = Koha::Checkouts->new; |
56 |
$checkouts_set = Koha::Checkouts->new; |
57 |
} |
57 |
} |
58 |
|
58 |
|
59 |
my $args = $c->validation->output; |
59 |
my $checkouts = $c->objects->search( $checkouts_set ); |
60 |
my $attributes = {}; |
|
|
61 |
|
60 |
|
62 |
# Extract reserved params |
61 |
return $c->render( |
63 |
my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($args); |
62 |
status => 200, |
64 |
|
63 |
openapi => $checkouts |
65 |
# Merge sorting into query attributes |
|
|
66 |
$c->dbic_merge_sorting( |
67 |
{ |
68 |
attributes => $attributes, |
69 |
params => $reserved_params, |
70 |
result_set => $checkouts_set |
71 |
} |
72 |
); |
73 |
|
74 |
# Merge pagination into query attributes |
75 |
$c->dbic_merge_pagination( |
76 |
{ |
77 |
filter => $attributes, |
78 |
params => $reserved_params |
79 |
} |
80 |
); |
64 |
); |
81 |
|
|
|
82 |
# Call the to_model function by reference, if defined |
83 |
if ( defined $filtered_params ) { |
84 |
# remove checked_in |
85 |
delete $filtered_params->{checked_in}; |
86 |
# Apply the mapping function to the passed params |
87 |
$filtered_params = $checkouts_set->attributes_from_api($filtered_params); |
88 |
$filtered_params = $c->build_query_params( $filtered_params, $reserved_params ); |
89 |
} |
90 |
|
91 |
# Perform search |
92 |
my $checkouts = $checkouts_set->search( $filtered_params, $attributes ); |
93 |
|
94 |
if ($checkouts->is_paged) { |
95 |
$c->add_pagination_headers({ |
96 |
total => $checkouts->pager->total_entries, |
97 |
params => $args, |
98 |
}); |
99 |
} |
100 |
|
101 |
return $c->render( status => 200, openapi => $checkouts->to_api ); |
102 |
} catch { |
65 |
} catch { |
103 |
$c->unhandled_exception($_); |
66 |
$c->unhandled_exception($_); |
104 |
}; |
67 |
}; |
105 |
- |
|
|