class BankValInternational::GetABA

BankValInternational::GetABA

Class to control calls to getABAdetails

Synopsis

requires 'BankValInternational'

@obj1 = BankValInternational::GetABA.new
@ans = obj1.bankval_int_ibanval('json','AN_ABA','userID','PINNo')

Public Instance Methods

bankval_int_getaba(*args) click to toggle source

Method to control calls to getABAdetails

Parameters

1.Return Format

must be either ‘json’, ‘xml’ or ‘csv’

2.ABA 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 215
def bankval_int_getaba(*args)
  @format = args[0].downcase
  @aba = 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 235
def build_req_url()
  @service_url = "bankvalint/abadetails/userid/#{@userid}/pin/#{@pin}/aba/#{@aba}/#{@format}/"
end
format_error_string() click to toggle source
# File lib/BankValInternational.rb, line 252
def format_error_string()
  if @format == 'xml'
    @error_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><aba><result>" + @error_string + "</result><routingnumber></routingnumber><bankname></bankname><bankaddress></bankaddress><city></city><state></state><zipcode></zipcode><telephone></telephone><areacode></areacode><fips></fips><timezone></timezone><dst></dst><latitude></latitude><longitude></longitude><msa></msa><pmsa></pmsa><county></county></aba>"
  elsif @format == 'json'
    @error_string = "{\"result\":\"" + @error_string + "\",\"routingnumber\":\"\",\"bankname\":\"\",\"bankaddress\":\"\",\"city\":\"\",\"state\":\"\",\"zipcode\":\"\",\"telephone\":\"\",\"areacode\":\"\",\"fips\":\"\",\"timezone\":\"\",\"dst\":\"\",\"latitude\":\"\",\"longitude\":\"\",\"msa\":\"\",\"pmsa\":\"\",\"county\":\"\"}"
  end
end
format_validation() click to toggle source
# File lib/BankValInternational.rb, line 239
def format_validation()
  @error_string = nil
  if @format !~  /^json$|^xml$|^csv$/
    @error_string = "INVALID - Result Format"
  elsif @aba !~ /^[0-9]{9}$/
    @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