]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction.pm
Merge branch 'master' of git.evergreen-ils.org:Evergreen into template-toolkit-opac
[working/Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / SIP / Transaction.pm
1 #
2 # Transaction: Superclass of all the transactional status objects
3 #
4
5 package OpenILS::SIP::Transaction;
6
7 use Carp;
8 use strict; use warnings;
9 use Sys::Syslog qw(syslog);
10
11 use OpenILS::SIP;
12 use OpenILS::SIP::Msg qw/:const/;
13
14
15 my %fields = (
16       ok            => 0,
17       patron        => undef,
18       item          => undef,
19       desensitize   => 0,
20       alert         => '',
21       transation_id => undef,
22       sip_fee_type  => '01', # Other/Unknown
23       fee_amount    => undef,
24       sip_currency  => 'CAD',
25       screen_msg    => '',
26       print_line    => '',
27       editor        => undef,
28       authtoken     => '',
29 );
30
31 our $AUTOLOAD;
32
33 sub new {
34     my( $class, %args ) = @_;
35
36     my $self = { _permitted => \%fields, %fields };
37
38         bless $self, $class;
39         $self->authtoken($args{authtoken});
40
41         syslog('LOG_DEBUG', "OILS: Created new transaction with authtoken %s", $self->authtoken);
42
43         my $e = OpenILS::SIP->editor();
44         $e->{authtoken} = $self->authtoken;
45
46         return $self;
47 }
48
49 sub DESTROY { 
50         # be cool
51 }
52
53 sub AUTOLOAD {
54         my $self = shift;
55         my $class = ref($self) or croak "$self is not an object";
56         my $name = $AUTOLOAD;
57
58         $name =~ s/.*://;
59
60         unless (exists $self->{_permitted}->{$name}) {
61                 croak "Can't access '$name' field of class '$class'";
62         }
63
64         if (@_) {
65                 return $self->{$name} = shift;
66         } else {
67                 return $self->{$name};
68         }
69 }
70
71 1;