]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/checkout.pl
2998e58dac210f01c6af0c50e331426c88f1ebb1
[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>]\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         "\tblahk 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
28 my $method = 'open-ils.circ.checkout_permit_';
29
30 sub go {
31         osrf_connect($config);
32         oils_login($username, $password);
33         do_permit($patronid, $barcode, $type =~ /noncat/ ); 
34         do_checkout($patronid, $barcode, $type =~ /noncat/ ) unless ($type =~ /permit/);
35         oils_logout();
36 }
37
38 go();
39
40 #----------------------------------------------------------------
41
42 sub do_permit {
43         my( $patronid, $barcode, $noncat ) = @_;
44
45         my @args = ( $authtoken, 'patron', $patronid );
46         push(@args, ('barcode', $barcode)) unless $noncat;
47         push(@args, ('noncat', 1)) if $noncat;
48
49         my $resp = simplereq( 
50                 CIRC(), 'open-ils.circ.permit_checkout_', @args );
51         
52         oils_event_die($resp);
53         printl("Permit succeeded for patron $patronid");
54 }
55
56 sub do_checkout {
57 }
58