]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/checkout.pl
made checkout methods take hash refs instead of named params list since
[Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / checkout.pl
1 #!/usr/bin/perl
2
3 #----------------------------------------------------------------
4 # Code for testing the container API
5 #----------------------------------------------------------------
6
7 require '../oils_header.pl';
8 use vars qw/ $apputils $memcache $user $authtoken $authtime /;
9 use strict; use warnings;
10
11 #----------------------------------------------------------------
12 err("\nusage: $0 <config> <oils_login_username> ".
13         " <oils_login_password> <patronid> <copy_barcode> [<type>, <noncat_type>]\n".
14         "Where <type> is one of:\n".
15         "\t'permit' to run the permit only\n".
16         "\t'noncat_permit' to run the permit script against a noncat item\n".
17         "\t'noncat' to check out a noncat item\n".
18         "\t(blank) to do a regular checkout\n" ) unless $ARGV[4];
19 #----------------------------------------------------------------
20
21 my $config              = shift; 
22 my $username    = shift;
23 my $password    = shift;
24 my $patronid    = shift;
25 my $barcode             = shift;
26 my $type                        = shift || "";
27 my $nc_type             = shift;
28
29 sub go {
30         osrf_connect($config);
31         oils_login($username, $password);
32         do_permit($patronid, $barcode, $type =~ /noncat/ ); 
33         do_checkout($patronid, $barcode, $type =~ /noncat/, $nc_type ) unless ($type =~ /permit/);
34         oils_logout();
35 }
36
37 go();
38
39 #----------------------------------------------------------------
40
41 sub do_permit {
42         my( $patronid, $barcode, $noncat ) = @_;
43
44         my $args = { patron => $patronid };
45
46         $args->{barcode} = $barcode;
47         if($noncat) {
48                 $args->{noncat} = 1;
49                 $args->{noncat_type} = $nc_type;
50         }
51
52         my $resp = simplereq( 
53                 CIRC(), 'open-ils.circ.checkout.permit', $authtoken, $args );
54         
55         oils_event_die($resp);
56         printl("Permit succeeded for patron $patronid");
57 }
58
59 sub do_checkout {
60         my( $patronid, $barcode, $noncat, $nc_type ) = @_;
61
62         my $args = { patron => $patronid };
63         $args->{barcode} = $barcode;
64         if($noncat) {
65                 $args->{noncat} = 1;
66                 $args->{noncat_type} = $nc_type;
67         }
68
69         my $resp = osrf_request(
70                 'open-ils.circ', 
71                 'open-ils.circ.checkout', $authtoken, $args );
72
73         oils_event_die($resp);
74         printl("Checkout succeeded");
75 }
76
77
78
79