3 #----------------------------------------------------------------
4 # Code for testing the container API
5 #----------------------------------------------------------------
7 require '../oils_header.pl';
8 use vars qw/ $apputils $memcache $user $authtoken $authtime /;
9 use strict; use warnings;
10 use Time::HiRes qw/time/;
12 #----------------------------------------------------------------
13 err("\nusage: $0 <config> <oils_login_username> ".
14 " <oils_login_password> <patronid> <copy_barcode> [<type>, <noncat_type>]\n".
15 "Where <type> is one of:\n".
16 "\t'permit' to run the permit only\n".
17 "\t'noncat_permit' to run the permit script against a noncat item\n".
18 "\t'noncat' to check out a noncat item\n".
19 "\t(blank) to do a regular checkout\n" ) unless $ARGV[4];
20 #----------------------------------------------------------------
27 my $type = shift || "";
33 osrf_connect($config);
34 oils_login($username, $password);
35 my($key,$precat) = do_permit($patronid, $barcode, $type =~ /noncat/ );
36 printl("Item is pre-cataloged...") if $precat;
37 do_checkout($key, $patronid, $barcode,
38 $precat, $type =~ /noncat/, $nc_type ) unless ($type =~ /permit/);
44 #----------------------------------------------------------------
47 my( $patronid, $barcode, $noncat ) = @_;
50 my $args = { patron => $patronid, barcode => $barcode };
53 $args->{noncat_type} = $nc_type;
58 CIRC(), 'open-ils.circ.checkout.permit', $authtoken, $args );
60 if( oils_event_equals($resp, 'ITEM_NOT_CATALOGED') ) {
62 } else { oils_event_die($resp); }
64 my $e = time() - $start;
65 my $key = $resp->{payload};
66 printl("Permit OK: \n\ttime =\t$e\n\tkey =\t$key" );
68 return ( $key, $precat );
72 my( $key, $patronid, $barcode, $precat, $noncat, $nc_type ) = @_;
74 my $args = { permit_key => $key, patron => $patronid, barcode => $barcode };
78 $args->{noncat_type} = $nc_type;
83 $args->{dummy_title} = "Dummy Title";
84 $args->{dummy_author} = "Dummy Author";
87 my $start_checkout = time();
88 my $resp = osrf_request(
90 'open-ils.circ.checkout', $authtoken, $args );
93 oils_event_die($resp);
95 my $d = $finish - $start_checkout;
96 my $dd = $finish - $start;
98 printl("Checkout OK:");
99 printl("\ttime = $d");
100 printl("\ttotal time = $dd");
101 printl("\ttitle = " . $resp->{payload}->{record}->title ) unless($noncat or $precat);
102 printl("\tdue_date = " . $resp->{payload}->{circ}->due_date ) unless $noncat;