Pass authtoken to OpenILS::SIP::Patron objects
authorJeff Godin <jgodin@tadl.org>
Tue, 19 Jun 2012 19:10:07 +0000 (15:10 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 2 Aug 2012 02:59:04 +0000 (22:59 -0400)
To support retrieval of billing details, OpenILS::SIP::Patron
objects need an auth token.

Teach OpenILS::SIP->find_patron to pass patron objects an auth
token, and also move existing "find patron by what key: barcode or
database id?" logic into find_patron (and out of
OpenILS::SIP::Patron->new).

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>

Open-ILS/src/perlmods/lib/OpenILS/SIP.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm

index 75a8b53..9e877a5 100644 (file)
@@ -234,10 +234,17 @@ sub login {
        return $self->{authtoken} = $key;
 }
 
+#
+# find_patron($barcode);
+# find_patron(barcode => $barcode);   # same as above
+# find_patron(usr => $id);
 
 sub find_patron {
        my $self = shift;
-       return OpenILS::SIP::Patron->new(@_);
+    my $key  =  (@_ > 1) ? shift : 'barcode';  # if we have multiple args, the first is the key index (default barcode)
+    my $patron_id = shift;
+
+       return OpenILS::SIP::Patron->new($key => $patron_id, authtoken => $self->{authtoken}, @_);
 }
 
 
index 538a6a7..d446318 100644 (file)
@@ -29,14 +29,9 @@ our (@ISA, @EXPORT_OK);
 
 my $INET_PRIVS;
 
-#
-# OpenILS::SIP::Patron->new($barcode);
-# OpenILS::SIP::Patron->new(barcode => $barcode);   # same as above
-# OpenILS::SIP::Patron->new(    usr => $id);       
-
 sub new {
     my $class = shift;
-    my $key   = (@_ > 1) ? shift : 'barcode';  # if we have multiple args, the first is the key index (default barcode)
+    my $key   = shift;
     my $patron_id = shift;
     my %args = @_;
 
@@ -110,6 +105,7 @@ sub new {
 
     $self->flesh_user_penalties($user, $e) unless $args{slim_user};
 
+    $self->{authtoken} = $args{authtoken} if $args{authtoken};
     $self->{editor} = $e;
     $self->{user}   = $user;
     $self->{id}     = ($key eq 'barcode') ? $patron_id : $user->card->barcode;   # The barcode IS the ID to SIP.