Finance-BankVal-International-GetSWIFT
view release on metacpan or search on metacpan
lib/Finance/BankVal/International/GetSWIFT.pm view on Meta::CPAN
sub loadUidPin {
my $fileOpened = open UIDCONF, "InternationalLoginConfig.txt";
if ( ! $fileOpened){
$error .= "No UserID / PIN supplied, please visit http://www.unifiedsoftware.co.uk/freetrial/free-trial-home.html: ";
}else{
while (<UIDCONF>){
if ($_ =~ /^UserID/){
chomp(my @line = split (/ |\t/,$_));
$userid = $line[-1];
}elsif($_ =~ /^PIN/){
chomp(my @line = split (/ |\t/,$_));
$pin = $line[-1];
}
}
#check to see if conf file has empty params - if so return error message directing to free trial page
if (($userid !~ /\w/) || ($pin !~ /\w/)){
$error .= "No UserID / PIN supplied, please visit http://www.unifiedsoftware.co.uk/freetrial/free-trial-home.html: ";
}
close UIDCONF;
}
}
sub formatErrorMsg{
if($format eq "xml"){
$responseString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><swiftbic><result>" . $responseString . "</result>"
. "<bic></bic><name1></name1><name2></name2><name3></name3><address1></address1><address2></address2><address3>"
. "</address3><address4></address4><location></location><country></country></swiftbic>";
}elsif($format eq "json"){
$responseString = "{\"result\":\"" . $responseString . "\",\"bic\":\"\",\"name1\":\"\",\"name2\":\"\",\"name3\""
. ":\"\",\"address1\":\"\",\"address2\":\"\",\"address3\":\"\",\"address4\":\"\",\"location\":\"\",\"country\""
. ":\"\"}";
}
}
1;
__END__
=head1 NAME
Finance::BankVal::International::GetSWIFT
=head1 SYNOPSIS
use Finance::BankVal::International::GetSWIFT qw(&getSWIFT);
my $ans = getSWIFT('XML','ABICCODE','xmpl123','12345');
===============or for OO==================
use Finance::BankVal::International::GetSWIFT;
$abaObj = Finance::BankVal::International::GetSWIFT->new();
my $ans = $abaObj->getSWIFT('XML','ABICCODE','xmpl123','12345');
=head1 DESCRIPTION
This module handles all of the restful web service calls to Unified Software's
BankValInternational SWIFT BIC service. It also handles fail over to the back up services
transparently to the calling script. It can be called in a procedural or OO fashion
(see synopsis)
The exportable method &getSWIFT(); takes a number of parameters including;
1: Format - the response format (either xml, json or csv)
2: SWIFT BIC - the BIC code to be validated
3: UserID - available from www.unifiedsoftware.co.uk
4: PIN - available from www.unifiedsoftware.co.uk
(UserID and PIN are available from http://www.unifiedsoftware.co.uk/freetrial/free-trial-home.html)
The order of the parameters B<must> be as above. The UserID and PIN can be stored in the InternationalLoginConfig.txt
file bundled with this module, the use of this file saves passing the PIN and user ID data with each call to getSWIFT.
For example, a call to validate a SWIFT BIC passing the user ID and PIN as parameters
and printing the reply to console should follow this form:
=====================================================================
#!/usr/bin/perl
use Finance::BankVal::International::GetSWIFT qw(&getSWIFT);
my $ans = getSWIFT('XML','ABICCODE','xmpl123','12345');
print $ans;
=============================OR for OO===============================
use Finance::BankVal::International::GetSWIFT;
$swiftObj = Finance::BankVal::International::GetSWIFT->new();
my $ans = $swiftObj->getSWIFT('XML','ABICCODE','xmpl123','12345');
print $ans;
=====================================================================
valid parameter lists are:-
getSWIFT('$format','$swiftbic','$userID','$PIN');
getSWIFT('$format','$swiftbic');
n.b. the last parameter list requires that the user ID and PIN are stored
in the I<InternationalLoginConfig.txt> file bundled with this module.
=head2 EXPORT
None by default.
&getSWIFT is exported on request i.e. "use Finance::BankVal::International::GetSWIFT qw(&getSWIFT);"
r for OO "use Finance::BankVal::International::GetSWIFT;"
=head1 DEPENDENCIES
This module requires these other modules and libraries:
use LWP::UserAgent;
( run in 1.308 second using v1.01-cache-2.11-cpan-e1769b4cff6 )