]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction.pm
Merge branch 'master' of git.evergreen-ils.org:Evergreen-DocBook into doc_consolidati...
[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       transaction_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       fee_ack       => 0,
30 );
31
32 our $AUTOLOAD;
33
34 sub new {
35     my( $class, %args ) = @_;
36
37     my $self = { _permitted => \%fields, %fields };
38
39         bless $self, $class;
40         $self->authtoken($args{authtoken});
41
42         syslog('LOG_DEBUG', "OILS: Created new transaction with authtoken %s", $self->authtoken);
43
44         my $e = OpenILS::SIP->editor();
45         $e->{authtoken} = $self->authtoken;
46
47         return $self;
48 }
49
50 sub DESTROY { 
51         # be cool
52 }
53
54 sub AUTOLOAD {
55         my $self = shift;
56         my $class = ref($self) or croak "$self is not an object";
57         my $name = $AUTOLOAD;
58
59         $name =~ s/.*://;
60
61         unless (exists $self->{_permitted}->{$name}) {
62                 croak "Can't access '$name' field of class '$class'";
63         }
64
65         if (@_) {
66                 return $self->{$name} = shift;
67         } else {
68                 return $self->{$name};
69         }
70 }
71
72 1;