class BankValInternational::GetSWIFT
BankValInternational::GetSWIFT
¶ ↑
Class to control calls to getBankDetails2
Synopsis¶ ↑
requires 'BankValInternational' @obj1 = BankValInternational::GetSWIFT.new @ans = obj1.bankval_int_get_swift('xml','A_SWIFT_BIC','userID','PINNo')
Public Instance Methods
bankval_int_getswift(*args)
click to toggle source
Method to control calls to getBankDetails2
Parameters¶ ↑
- 1.Return Format
-
must be either ‘json’, ‘xml’ or ‘csv’
- 2.Swift BIC Number
-
the number for validation
- 3.UserId
-
can obtained from www.unifiedsoftware.co.uk/freetrial/free-trial-home.html
- 4.PIN
-
can obtained from www.unifiedsoftware.co.uk/freetrial/free-trial-home.html
The parameters must be passed in the order shown above
Returns¶ ↑
The response from the webservice is returned as a string in either: *XML format *json format *csv format depending on the Return Format Parameter passed in
# File lib/BankValInternational.rb, line 134 def bankval_int_getswift(*args) @format = args[0].downcase @swiftbic = args[1] @userid = args[2] @pin = args[3] if args.size !=4 return "ERROR - not enough parameters supplied" end format_validation if @error_string != nil format_error_string return @error_string end build_req_url return "#{BankValInternational::GoValidate.new.validate(@service_url)}" end
Private Instance Methods
build_req_url()
click to toggle source
method to build the base request url for the REST call
# File lib/BankValInternational.rb, line 154 def build_req_url() @service_url = "bankvalint/bankdetails2/userid/#{@userid}/pin/#{@pin}/swiftbic/#{@swiftbic}/#{@format}/" end
format_error_string()
click to toggle source
# File lib/BankValInternational.rb, line 170 def format_error_string() if @format == 'xml' @error_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><swiftbic><result>" + @error_string + "</result><bic></bic><name1></name1><name2></name2><name3></name3><address1></address1><address2></address2><address3></address3><address4></address4><location></location><country></country></swiftbic>" elsif @format == 'json' @error_string = "{\"result\":\"" + @error_string + "\",\"bic\":\"\",\"name1\":\"\",\"name2\":\"\",\"name3\":\"\",\"address1\":\"\",\"address2\":\"\",\"address3\":\"\",\"address4\":\"\",\"location\":\"\",\"country\":\"\"}" end end
format_validation()
click to toggle source
# File lib/BankValInternational.rb, line 157 def format_validation @error_string = nil if @format !~ /^json$|^xml$|^csv$/ @error_string = "INVALID - Result Format" elsif @swiftbic !~ /^[A-Z,0-9]{8}$/ @error_string = "INVALID" elsif @pin !~ /^[0-9]{5}$/ @error_string = "ERROR - Invalid User ID/PIN" elsif @userid !~ /^[a-zA-Z\-_][a-zA-Z][a-zA-Z]*\D\d\d\d$/ @error_string = "ERROR - Invalid User ID/PIN" end end