Merge branch 'master' of github.com:dpavlin/Net-SIP2-Simple
[Biblio-SIP2.git] / sc-emulator.pl
index 3be7d9b..3488612 100755 (executable)
@@ -8,20 +8,35 @@ use autodie;
 
 our $user     = 'sip2-user';
 our $password = 'sip2-paasswd';
+our $patron   = 200000000042;
+our $barcode  = 1301132799;
+our $loc      = 'FFZG';
 
 require 'config.pl' if -e 'config.pl';
 
-our $sock = IO::Socket::INET->new( '10.60.0.251:6001' );
+use SIP2;
 
-sub sip2 {
-       my ( $send, $patt ) = @_;
-       warn ">>>> $send";
-       print $sock $send;
+SIP2::connect '10.60.0.251:6001';
 
-       my $in = <$sock>;
-       warn "<<<< $in";
-       die unless $in =~ $patt;
-}
+# login
+SIP2::send "9300CN$user|CO$password|";
 
-sip2 "9300CN$user|CO$password|\n" => qr/^941/;
+# SC Status
+SIP2::send "9900302.00";
+
+# Patron Information
+SIP2::send "6300020091214    085452          AO$loc|AA$patron|AC$password|";
+
+# Checkout
+SIP2::send "11YN20091214    124436                  AO$loc|AA$patron|AB$barcode|AC$password|BON|BIN|";
+
+# Checkin
+SIP2::send "09N20091214    08142820091214    081428AP|AO$loc|AB$barcode|AC|BIN|";
+
+
+# checkout another
+SIP2::send "09N20091216    15320820091216    153208AP|AOFFZG|AB200903160190|ACviva2koha|BIN|";
+
+# status
+SIP2::send "9900302.00";