]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Renew.pm
Revert "LP#1635737 Use new OpenSRF interval_to_seconds() context"
[working/Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / SIP / Transaction / Renew.pm
1 #
2 # Status of a Renew Transaction
3 #
4
5 package OpenILS::SIP::Transaction::Renew;
6 use warnings; use strict;
7
8 use Sys::Syslog qw(syslog);
9 use OpenILS::SIP;
10 use OpenILS::SIP::Transaction;
11 use OpenILS::Application::AppUtils;
12 my $U = 'OpenILS::Application::AppUtils';
13
14 our @ISA = qw(OpenILS::SIP::Transaction);
15
16 my %fields = (
17           renewal_ok => 0,
18           );
19
20 sub new {
21     my $class = shift;;
22     my $self = $class->SUPER::new(@_);
23
24     $self->{_permitted}->{$_} = $fields{$_} for keys %fields;
25     @{$self}{keys %fields} = values %fields;
26
27     return bless $self, $class;
28 }
29
30 sub do_renew {
31     my $self = shift;
32
33     my $resp = $U->simplereq(
34         'open-ils.circ',
35         'open-ils.circ.renew', $self->{authtoken},
36         { barcode => $self->item->id, patron_barcode => $self->patron->id });
37
38     if( my $code = $U->event_code($resp) ) {
39         syslog('LOG_INFO', "OILS: Renewal failed with event $code : " . $resp->{textcode});
40         $self->renewal_ok(0);
41         $self->ok(0);
42         return $self;
43     }
44
45     $self->item->{due_date} = $resp->{payload}->{circ}->due_date;
46     syslog('LOG_INFO', "OILS: Renewal succeeded with due_date = " . $self->item->{due_date});
47
48     $self->renewal_ok(1);
49     $self->ok(1);
50
51     return $self;
52 }
53
54
55 1;