Commit 1c6c56bc authored by Benjamin Rokseth's avatar Benjamin Rokseth
Browse files

koha: expose picklist in new API

parent d79f8295
......@@ -7,7 +7,10 @@ use Modern::Perl;
use Exception::Class (
"Deichman::Exception",
"Deichman::Exception::File::NotFound" => {
description => "File not found",
isa => "Deichman::Exception",
},
"Deichman::Exception::Patron",
"Deichman::Exception::Patron::NotFound" => {
description => "Patron not found",
......
......@@ -52,6 +52,7 @@ use RESTAPI::Patron::Dooraccess;
use RESTAPI::Patron::Favourites;
use RESTAPI::Patron::LoansAndReservations;
use RESTAPI::Patron::PasswordRecovery;
use RESTAPI::PickList;
use RESTAPI::PrintSlip;
use RESTAPI::Session;
......@@ -62,6 +63,7 @@ mount "RESTAPI::Patron::Dooraccess";
mount "RESTAPI::Patron::Favourites";
mount "RESTAPI::Patron::LoansAndReservations";
mount "RESTAPI::Patron::PasswordRecovery";
mount "RESTAPI::PickList";
mount "RESTAPI::PrintSlip";
mount "RESTAPI::Session";
......
package RESTAPI::PickList;
# Simply expose plukkliste.json in api, to be moved later
use strict;
use warnings;
use Raisin::API;
use HTTP::Status qw(:constants);
use Types::Standard qw(HashRef Any Int Str);
use Try::Tiny;
use Deichman::Exception;
binmode STDOUT, ":utf8";
use utf8;
use JSON;
desc "Print slip operations";
resource picklist => sub {
summary "Get list of items to pick";
get sub {
try {
# an extra roundtrip of decode-encode json never hurts...
my $json;
local $/; #Enable 'slurp' mode
open my $fh, "<", "/koha/holdsqueue/plukkliste.json" or Deichman::Exception::File::NotFound->throw();
$json = <$fh>;
close $fh;
my $data = decode_json($json);
{ $data }
} catch {
if ($_->isa("Deichman::Exception::File::NotFound")) {
res->status(HTTP_NOT_FOUND);
} else {
app->log(error => $_->description);
res->status(HTTP_INTERNAL_SERVER_ERROR);
}
undef;
}
};
};
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment