Class: BankVal::UK

Inherits:
Object
  • Object
show all
Defined in:
lib/BankVal.rb

Overview

BankVal::UK

Class to control calls to BankValPlus2 GetBranchDetails2

Synopsis

requires ‘BankVal::UK’

or..

Instance Method Summary collapse

Instance Method Details

#bank_val_uk(*args) ⇒ Object

Method to control calls to BankValPlus2 GetBranchDetails2

This method automatically controls calls to Unified software’s BankValUK REST web services

Parameters

1.Return Format

Either ‘csv’,‘json’,‘xml’

2.SortCode

The sortcode to be validated

3.Account

The account number to be validated (optional)

4.UserId

can obtained from www.unifiedsoftware.co.uk/freetrial/free-trial-home.html

5.PIN

can obtained from www.unifiedsoftware.co.uk/freetrial/free-trial-home.html

The parameters must be passed in the order described above, although the Account number is optional. Supplying a return format,sort code and login details only will result in getBranchDetails being called rather than BankValPlus2.

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



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/BankVal.rb', line 64

def bank_val_uk(*args)      
  @format = args[0].downcase
  @sortcode = args[1].gsub(/[- .]/, "")
  case args.size
  when 5
    @account = args[2]
    @userid = args[3]
    @pin = args[4]
  when 4
    @userid = args[2]
    @pin = args[3]
  else
    return "ERROR - not enough parameters supplied"
  end
  format_validation
  if @error_string != nil
    format_error_string
    @error_string.gsub!(/\n/,'')
    return @error_string
  end
  build_req_url
  return "#{BankVal::GoValidate.new.validate(@service_url)}"
end