From 46a23a07caf513bcd931854b264c11396e1099db Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Tue, 28 May 2013 17:09:38 -0400 Subject: [PATCH] Add support for get_user LibraryREST call Add support for get_user LibraryREST call Signed-off-by: Jeff Godin --- Open-ILS/src/perlmods/lib/OpenILS/LibraryREST.pm | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/LibraryREST.pm b/Open-ILS/src/perlmods/lib/OpenILS/LibraryREST.pm index acaba8a91e..94477a820a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/LibraryREST.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/LibraryREST.pm @@ -70,4 +70,34 @@ sub get_auth { return 0; } +sub get_user { + my $self = shift; + my $user = shift; + my $token = shift; + return unless ($user && $token); + + my $target_user = shift | $user; + + my $user_summary = $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.opac.vital_stats', + $token + ); + + my $uobj = $user_summary->{user}; + + my $name_parts = [ $uobj->{first_given_name}, $uobj->{second_given_name}, $uobj->{family_name} ]; + my $name = join(' ', @$name_parts); + + return { + user => { + name => $name, + name_parts => $name_parts, + }, + checkouts => $user_summary->{checkouts}, + holds => $user_summary->{holds}, + balance => $user_summary->{fines}->{balance_owed}, + } +} + 1; -- 2.11.0