Bug 32537: Add no-block option to SIP cli emulator
authorNick Clemens <nick@bywatersolutions.com>
Tue, 27 Dec 2022 20:21:15 +0000 (20:21 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 3 Feb 2023 13:30:08 +0000 (10:30 -0300)
This patch adds the option to pass a no-block option and use this
in checkout/checkin/renew messages

To test:
1 - perl misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkin --item 39999000010831
2 - Confirm out like:
    SEND: 09N20221227    20183920221227    201839APCPL|AOCPL|AB39999000010831|ACterm1|BIN|
    (Note the N after 09)
3 - Apply patch
4 - Restart SIP, repeat 1
5 - Confirm still an N
6 - perl misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkin --item 39999000010831 -n N
7 - Confirm still an N
8 - perl misc/sip_cli_emulator.pl -a localhost -p 6001 -l CPL -su term1 -sp term1 -m checkin --item 39999000010831 -n Y
9 - Confirm the send has a Y after 09

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
misc/sip_cli_emulator.pl

index 8336ced..441234d 100755 (executable)
@@ -54,6 +54,7 @@ my $fee_identifier;
 my $transaction_id;
 my $pickup_location;
 my $hold_mode;
+my $no_block;
 
 my $terminator = q{};
 
@@ -83,6 +84,7 @@ GetOptions(
     "transaction-id=s"  => \$transaction_id,
     "pickup-location=s" => \$pickup_location,
     "hold-mode=s"       => \$hold_mode,
+    "n|no-block=s"      => \$no_block,
 
     "t|terminator=s" => \$terminator,
 
@@ -101,6 +103,8 @@ if (   $help
     exit();
 }
 
+$no_block //= 'N';
+
 $terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF;
 
 # Set perl to expect the same record terminator it is sending
@@ -174,7 +178,7 @@ my $handlers = {
         subroutine => \&build_checkout_command_message,
         parameters => {
             SC_renewal_policy => 'Y',
-            no_block          => 'N',
+            no_block          => $no_block,
             transaction_date  => $transaction_date,
             nb_due_date       => undef,
             institution_id    => $location_code,
@@ -198,7 +202,7 @@ my $handlers = {
         name       => 'Checkin',
         subroutine => \&build_checkin_command_message,
         parameters => {
-            no_block          => 'N',
+            no_block          => $no_block,
             transaction_date  => $transaction_date,
             return_date       => $transaction_date,
             current_location  => $location_code,
@@ -220,7 +224,7 @@ my $handlers = {
         subroutine => \&build_renew_command_message,
         parameters => {
             third_party_allowed => 'N',
-            no_block            => 'N',
+            no_block            => $no_block,
             transaction_date    => $transaction_date,
             nb_due_date         => undef,
             institution_id      => $location_code,
@@ -654,6 +658,7 @@ Options:
   --transaction-id  Transaction id for Fee Paid message, optional
   --pickup-location Pickup location (branchcode) for Hold message, optional
   --hold-mode       Accepts "+" to add hold or "-" to cancel hold, defaults to +
+  -n --no-block     Accepts "N" for standard operatoin, "Y" for no-block, defaults to "N"
 
   -m --message     SIP2 message to execute