From 4ce5ab1657044d1b29b01f5d6614c4710ddcc48a Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 14 Sep 2014 13:14:02 -0400 Subject: [PATCH] Add error checking to NCIP::ILS::Evergreen->checkinitem(). Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 57 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index bc72da0..239baf6 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -575,7 +575,7 @@ sub checkinitem { # transits, to force the checkin despite the copy status, as # well as void overdues. my $params = { - barcode => $copy->barcode(), + copy_barcode => $copy->barcode(), force => 1, noop => 1, void_overdues => 1 @@ -586,40 +586,41 @@ sub checkinitem { $self->{session}->{authtoken}, $params ); + if (ref($result) eq 'ARRAY') { + $result = $result->[0]; + } if ($result->{textcode} eq 'SUCCESS') { # Delete the copy. Since delete_copy checks ownership # before attempting to delete the copy, we don't bother # checking who owns it. $self->delete_copy($copy); - } - - # We should check for errors here, but I'll leave that for - # later. - - # We need the circulation user for the information below, so we retrieve it. - my $circ_user = $self->retrieve_user_by_id($circ->usr()); - my $data = { - ItemId => NCIP::Item::Id->new( - { - AgencyId => $request->{$message}->{ItemId}->{AgencyId}, - ItemIdentifierType => $request->{$message}->{ItemId}->{ItemIdentifierType}, - ItemIdentifierValue => $request->{$message}->{ItemId}->{ItemIdentifierValue} - } - ), - UserId => NCIP::User::Id->new( - { - UserIdentifierType => 'Barcode Id', - UserIdentifierValue => $circ_user->card->barcode() - } - ) - }; + # We need the circulation user for the information below, so we retrieve it. + my $circ_user = $self->retrieve_user_by_id($circ->usr()); + my $data = { + ItemId => NCIP::Item::Id->new( + { + AgencyId => $request->{$message}->{ItemId}->{AgencyId}, + ItemIdentifierType => $request->{$message}->{ItemId}->{ItemIdentifierType}, + ItemIdentifierValue => $request->{$message}->{ItemId}->{ItemIdentifierValue} + } + ), + UserId => NCIP::User::Id->new( + { + UserIdentifierType => 'Barcode Id', + UserIdentifierValue => $circ_user->card->barcode() + } + ) + }; - $response->data($data); + $response->data($data); - # At some point in the future, we should probably check if - # they requested optional user or item elements and return - # those. For the time being, we ignore those at the risk of - # being considered non-compliant. + # At some point in the future, we should probably check if + # they requested optional user or item elements and return + # those. For the time being, we ignore those at the risk of + # being considered non-compliant. + } else { + $response->problem(_problem_from_event('Checkin Failed', $result)); + } return $response } -- 2.43.2