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 do_permit($patronid, $barcode, $type =~ /noncat/ );
36 do_checkout($patronid, $barcode, $type =~ /noncat/, $nc_type ) unless ($type =~ /permit/);
42 #----------------------------------------------------------------
45 my( $patronid, $barcode, $noncat ) = @_;
47 my $args = { patron => $patronid, barcode => $barcode };
50 $args->{noncat_type} = $nc_type;
55 CIRC(), 'open-ils.circ.checkout.permit', $authtoken, $args );
57 oils_event_die($resp);
58 my $e = time() - $start;
59 printl("Permit succeeded : duration $e" );
63 my( $patronid, $barcode, $noncat, $nc_type ) = @_;
65 my $args = { patron => $patronid, barcode => $barcode };
68 $args->{noncat_type} = $nc_type;
71 my $start_checkout = time();
72 my $resp = osrf_request(
74 'open-ils.circ.checkout', $authtoken, $args );
77 oils_event_die($resp);
79 my $d = $finish - $start_checkout;
80 my $dd = $finish - $start;
82 printl("Checkout took $d");
83 printl("Total process took $dd");
84 printl("Title: " . $resp->{payload}->{record}->title );
85 printl("Copy: " . $resp->{payload}->{copy}->barcode );