From: Bill Erickson Date: Mon, 22 Feb 2021 21:19:41 +0000 (-0500) Subject: LP1904036 Noncat batch retrieval API X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bed0cb55886fdbf0b3d99940a1ad8fa82741cd33;p=Evergreen.git LP1904036 Noncat batch retrieval API Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm index 39b3a21e19..3105ddf605 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm @@ -183,8 +183,8 @@ sub fetch_noncat { sub noncat_due_date { my($e, $circ) = @_; - my $otype = $e->retrieve_config_non_cataloged_type($circ->item_type) - or return $e->die_event; + my $otype = ref $circ->item_type ? $circ->item_type : + $e->retrieve_config_non_cataloged_type($circ->item_type); my $tz = $U->ou_ancestor_setting_value( $circ->circ_lib, @@ -248,6 +248,51 @@ sub fetch_open_noncats { ); } +__PACKAGE__->register_method( + method => 'fetch_open_noncats_batch', + stream => 1, + authoritative => 1, + api_name => 'open-ils.circ.open_non_cataloged_circulation.user.batch', + signature => { + desc => q/Returns a stream of open non-cat circulations for a given user/, + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'UserID', type => 'number'} + ], + return => { + desc => 'Stream of ancc objects, Event on error' + }, + } +); + +sub fetch_open_noncats_batch { + my ($self, $client, $auth, $user_id) = @_; + + my $e = new_editor(authtoken => $auth); + return $e->event unless $e->checkauth; + + if ($e->requestor->id ne $user_id) { + return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); + } + + my $ids = $U->simplereq( + 'open-ils.storage', + 'open-ils.storage.action.open_non_cataloged_circulation.user', + $user_id + ); + + for my $id (@$ids) { + my $circ = $e->retrieve_action_non_cataloged_circulation([ + $id, {flesh => 1, flesh_fields => {ancc => ['item_type', 'staff']}} + ]); + + noncat_due_date($e, $circ); + $client->respond($circ); + } + + return undef; +} + __PACKAGE__->register_method( method => 'delete_noncat',