File Coverage

blib/lib/SWIFT/Factory/BasicHeader.pm
Criterion Covered Total %
statement 23 39 58.9
branch n/a
condition n/a
subroutine 8 12 66.6
pod 3 3 100.0
total 34 54 62.9


line stmt bran cond sub pod time code
1             package SWIFT::Factory::BasicHeader;
2 1     1   18408 use strict;
  1         3  
  1         41  
3 1     1   8 use warnings;
  1         2  
  1         39  
4              
5 1     1   5 use vars qw($VERSION);
  1         7  
  1         79  
6             $VERSION = '0.03';
7              
8             BEGIN{
9 1     1   3 *provide=*string;
10 1         26 *borken=*invalid;
11             }
12              
13 1     1   6 use constant APP_ID_FIN=>'F';
  1         1  
  1         158  
14 1     1   6 use constant APP_ID_GPA=>'A';
  1         1  
  1         55  
15 1     1   5 use constant APP_ID_GPA_LOG=>'L';
  1         2  
  1         51  
16              
17 1     1   5 use constant SERVICE_ID_USER_2_USER=>1;
  1         2  
  1         541  
18              
19             ###########################################################################################################
20             # The Basic Header is block number 1 of a SWIFT message.
21             # This block appears in all SWIFT messages.
22             #
23             # The block is normally built for "input", which in SWIFT
24             # speak means "input to the SWIFT network".
25             #
26             # This module will implement an "Input Basic Header".
27             #
28             # To create an output basic block, subclass this class and
29             # implement the required specifics.
30             ###########################################################################################################
31             sub new {
32 0     0 1   my$self={};
33 0           bless($self,shift())->_init(@_);
34             }
35              
36             ###########################################################################################################
37             # The class cannot guarantee that the provided string will be valid in the SWIFT network.
38             # It can point out that it's found some invalid data, though.
39             # Return number of problems detected.
40             sub invalid {
41 0     0 1   my$self=shift;
42              
43             # Implement verifications here!
44 0           0;
45             }
46              
47             ###########################################################################################################
48             sub string {
49 0     0 1   my$self=shift;
50 0           '{1:'.
51             $self->{APP_ID}.
52             sprintf("%02u",$self->{SERVICE_ID}).
53             $self->{BIC}.
54             $self->{TERMINAL}.
55             $self->{BRANCH_CODE}.
56             sprintf("%04u",$self->{SESS_NBR}).
57             sprintf("%06u",$self->{I_SEQ_NBR}).
58             '}';
59             }
60              
61             ###########################################################################################################
62             sub _init {
63 0     0     my$self=shift;
64 0           my%args=(
65             APPLICATION_ID=>APP_ID_FIN,
66             SERVICE_ID=>SERVICE_ID_USER_2_USER,
67             BIC=>'X'x8, # Reciever BIC for SWIFT input msg.
68             TERMINAL=>'X', # Reciever Terminal for SWIFT input msg.
69             BRANCH_CODE=>'X'x3, # Reciever Branch code for SWIFT input msg.
70             SESSION_NBR=>0,
71             INPUT_SEQUENCE_NBR=>0,
72             @_
73             );
74 0           $self->{APP_ID}=$args{APPLICATION_ID};
75 0           $self->{SERVICE_ID}=$args{SERVICE_ID};
76 0           $self->{BIC}=$args{BIC};
77 0           $self->{TERMINAL}=$args{TERMINAL};
78 0           $self->{BRANCH_CODE}=$args{BRANCH_CODE};
79 0           $self->{SESS_NBR}=$args{SESSION_NBR};
80 0           $self->{I_SEQ_NBR}=$args{INPUT_SEQUENCE_NBR};
81 0           $self;
82             }
83              
84             ###########################################################################################################
85             'Choppers rule';
86             __END__