my $name_parts = [ $uobj->{first_given_name}, $uobj->{second_given_name}, $uobj->{family_name} ];
my $name = join(' ', @$name_parts);
+ my $circs = _get_user_circs($target_user, $token);
+
return {
id => $target_user,
name => $name,
holds => $user_summary->{holds}->{total},
holds_detail => $user_summary->{holds},
balance => $user_summary->{fines}->{balance_owed},
+ },
+ circs => $circs,
+ }
+}
+
+sub _get_user_circs {
+ my $user = shift;
+ my $token = shift;
+ return unless ($user && $token);
+
+ my $target_user = $user;
+
+ my $circ = OpenSRF::AppSession->create('open-ils.circ');
+
+ my $req = $circ->request(
+ 'open-ils.circ.actor.user.checked_out',
+ $token,
+ $target_user
+ );
+
+ my @circs;
+
+ while (my $resp = $req->recv(timeout=>60)) {
+ # XXX: check for failure
+ my $circ = $resp->{content}->{circ};
+ my $record = $resp->{content}->{record};
+ my $copy = $resp->{content}->{copy};
+
+ push @circs, {
+ title => $record->title,
+ author => $record->author,
+ due_date => $circ->due_date,
+ barcode => $copy->barcode,
+ raw_record => $record->to_bare_hash,
+ raw_circ => $circ->to_bare_hash,
+ raw_copy => $copy->to_bare_hash,
}
}
+
+ return \@circs;
+
}
1;