Fix NCIP::ILS::Evergreen->place_hold.
authorJason Stephenson <jason@sigio.com>
Sat, 11 Oct 2014 17:38:23 +0000 (13:38 -0400)
committerJason Stephenson <jason@sigio.com>
Sat, 11 Oct 2014 17:38:23 +0000 (13:38 -0400)
We better take into account what open-ils.circ.holds.create returns.

We check for an array of errors and use the first one.

We also look up the hold for the id returned. I forgot that it only
returns the id and not the whole hold object created.

Signed-off-by: Jason Stephenson <jason@sigio.com>
lib/NCIP/ILS/Evergreen.pm

index 48fbc05..7a6bff5 100644 (file)
@@ -2330,8 +2330,19 @@ sub place_hold {
             $self->{session}->{authtoken},
             $hold
         );
-        if (ref($hold) eq 'HASH') {
+        if (ref($hold)) {
+            $hold = $hold->[0] if (ref($hold) eq 'ARRAY');
             $hold = _problem_from_event('Request Not Possible', $hold);
+        } else {
+            # open-ils.circ.holds.create.override returns the id on
+            # success, so we retrieve the full hold object from the
+            # database to return it.
+            $hold = $U->simplereq(
+                'open-ils.pcrud',
+                'open-ils.pcrud.ahr.retrieve',
+                $self->{session}->{authtoken},
+                $hold
+            );
         }
     } elsif ($r->{last_event}) {
         $hold = _problem_from_event('Request Not Possible', $r->{last_event});