From a188139d906bf35c0e0a0184711b0f440c4bb02e Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Tue, 19 Jun 2012 15:10:07 -0400 Subject: [PATCH] Pass authtoken to OpenILS::SIP::Patron objects 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 Signed-off-by: Jason Stephenson Signed-off-by: Dan Scott --- Open-ILS/src/perlmods/lib/OpenILS/SIP.pm | 9 ++++++++- Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm | 8 ++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm index 75a8b53f6e..9e877a53f8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm @@ -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}, @_); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index 538a6a714a..d4463181ac 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -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. -- 2.11.0