From 0c2b784c396e05567a2ac100fd15e257b586faca Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 29 May 2020 19:10:47 -0400 Subject: [PATCH] add open-ils.curbside.patron.ready_holds_at_lib.count Surprisingly, there isn't already a method for getting a patron's ready holds at specific library. Signed-off-by: Galen Charlton --- .../perlmods/lib/OpenILS/Application/Curbside.pm | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm index 6f39615e33..de1f6889bf 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm @@ -61,6 +61,45 @@ __PACKAGE__->register_method( } ); +sub fetch_holds_for_patron_at_pickup_lib { + my ($self, $conn, $authtoken, $usr, $org) = @_; + + my $e = new_editor(xact => 1, authtoken => $authtoken); + return $e->die_event unless $e->checkauth; + + $org ||= $e->requestor->ws_ou; + + return new OpenILS::Event("CURBSIDE_NOT_ALLOWED") unless ($U->is_true( + $U->ou_ancestor_setting_value($org, 'circ.curbside') + )); + + return new OpenILS::Event("BAD_PARAMS", "desc" => "No user ID supplied") unless $usr; + + my $holds = $e->search_action_hold_request({ + usr => $usr, + current_shelf_lib => $org, + pickup_lib => $org, + shelf_time => {'!=' => undef}, + cancel_time => undef, + fulfillment_time => undef + }, { idlist => 1 }); + + return scalar(@$holds); + +} +__PACKAGE__->register_method( + method => "fetch_holds_for_patron_at_pickup_lib", + api_name => "open-ils.curbside.patron.ready_holds_at_lib.count", + signature => { + params => [ + {type => 'string', desc => 'Authentication token'}, + {type => 'number', desc => 'Patron ID'}, + {type => 'number', desc => 'Optional pickup library. If not supplied, taken from WS of session.'}, + ], + return => { desc => 'Number of holds on the shelf for the patron at the specified library'} + } +); + sub fetch_delivered { # returns appointments delivered TODAY my ($self, $conn, $authtoken, $org, $limit, $offset) = @_; -- 2.11.0