BankValUK 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README +12 -21
- data/Rakefile +4 -20
- data/lib/BankVal.rb +42 -150
- data/test/bv_test.rb +22 -60
- metadata +21 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39256dc419214c12a48e30bce269abf92679464f929a63b0da6203c508afdf30
|
4
|
+
data.tar.gz: 42d1b7301081e33a76f937af41f13c8300a78a162997f3a63e755fa1a382387b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eccfe6eb93595690fc4038a71080abdbce4e1d3053f1362624e62ba1ebc81fa4d3e73cf6b3e1248552aa58ffe4b9c3ee98deba2f5dd842384bd9d8cd88959360
|
7
|
+
data.tar.gz: 2c1fe6683ec66bfe575a12d6ec910210a1fc27719ebeb5f45946312b99c0827f77ddb07dd328b7cc2388a6c61fba9ac183fbe5398db48c525b1b8bfef21ce7f8
|
data/LICENSE
CHANGED
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
== BankValUK
|
2
2
|
|
3
|
-
== Unified Software (c)
|
3
|
+
== Unified Software (c) 2021
|
4
4
|
|
5
5
|
==SYNOPSIS
|
6
6
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
require 'bankval::uk'
|
9
9
|
|
10
10
|
obj = BankVal::UK.new
|
11
|
-
ans = obj.bank_val_uk('
|
11
|
+
ans = obj.bank_val_uk('00-01-26','12345678','abcd123','12345')
|
12
12
|
|
13
13
|
==Description
|
14
14
|
|
@@ -16,16 +16,10 @@ This Gem controls the calling of REST web services from Unified Software's UK Ba
|
|
16
16
|
It will transparently call Unified's back up servers in the unlikely event of any issues with the main servers.
|
17
17
|
The services which can be used from this Gem are:
|
18
18
|
|
19
|
-
[
|
19
|
+
[BankValUK]Validates UK bank sort code / account numbers. Returns transposed sort code and account number plus latest EISCD (Extended Industry Sorting Code Directory) data.
|
20
20
|
|
21
21
|
object = BankVal::UK.new
|
22
|
-
method = object.bank_val_uk(
|
23
|
-
|
24
|
-
|
25
|
-
[getBranchDetails2]Look up UK bank branch information using latest EISCD (Extended Industry Sorting Code Directory) data.
|
26
|
-
|
27
|
-
object = BankVal::UK.new
|
28
|
-
method = object.bank_val_uk(format,sortcode,userid,pin)
|
22
|
+
method = object.bank_val_uk(sortcode,accountno,userid,pin)
|
29
23
|
|
30
24
|
|
31
25
|
==Including the Gem
|
@@ -44,7 +38,7 @@ Once Rubygems is installed you can install the BankValUK gem from Rubygems.org b
|
|
44
38
|
|
45
39
|
*opening a command prompt (win) or a console window (*nix) and typing 'gem install BankValInt'
|
46
40
|
|
47
|
-
Once the
|
41
|
+
Once the BankValUK gem is installed on your system it can be included in your code by adding the following two lines:
|
48
42
|
|
49
43
|
require 'rubygems'
|
50
44
|
require 'bankval'
|
@@ -58,24 +52,21 @@ the exposed method (again as shown above)
|
|
58
52
|
|
59
53
|
The required parameters for the services are as follows:
|
60
54
|
|
61
|
-
1.
|
62
|
-
|
63
|
-
2. Sort Code:: the IBAN to be validated
|
55
|
+
1. Sort Code:: the Sort code to be validated
|
64
56
|
|
65
|
-
|
57
|
+
2. Account Number:: the account number to be validated
|
66
58
|
|
67
|
-
|
59
|
+
3. UserID:: available from www.unifiedsoftware.co.uk
|
68
60
|
|
69
|
-
|
61
|
+
4. PIN:: available from www.unifiedsoftware.co.uk
|
70
62
|
|
71
|
-
The parameters must be passed in the order shown
|
72
|
-
account number not being passed in the web service getBankDetails2 will be called rather than bankValUKPlus2.
|
63
|
+
The parameters must be passed in the order shown.
|
73
64
|
|
74
65
|
==Method Returns
|
75
66
|
|
76
|
-
The methods will return the web services response as a string formatted in
|
67
|
+
The methods will return the web services response as a string formatted in json
|
77
68
|
|
78
69
|
==BankValUK Ruby Gem
|
79
70
|
|
80
|
-
==Unified Software
|
71
|
+
==Unified Software 2021
|
81
72
|
==www.unifiedsoftware.co.uk
|
data/Rakefile
CHANGED
@@ -2,20 +2,16 @@
|
|
2
2
|
# BankValUK rakefile
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require '
|
6
|
-
require 'rake/clean'
|
7
|
-
require 'rake/gempackagetask'
|
8
|
-
require 'rake/rdoctask'
|
5
|
+
require 'rubygems/package_task'
|
9
6
|
require 'rake/testtask'
|
10
|
-
require 'spec/rake/spectask'
|
11
7
|
|
12
8
|
spec = Gem::Specification.new do |s|
|
13
9
|
s.name = 'BankValUK'
|
14
|
-
s.version = '0.0.
|
10
|
+
s.version = '0.0.3'
|
15
11
|
s.has_rdoc = true
|
16
12
|
s.extra_rdoc_files = ['README', 'LICENSE']
|
17
13
|
s.summary = 'Handles calls to Unified Softwares BankValUK web services'
|
18
|
-
s.description = s.summary + ' including
|
14
|
+
s.description = s.summary + ' including BankValUK which validates UK bank accounts and returns EISCD data'
|
19
15
|
s.author = 'Alec Evans, Unified Software'
|
20
16
|
s.email = 'support@unifiedsoftware.co.uk'
|
21
17
|
s.homepage = 'http://www.unifiedsoftware.co.uk'
|
@@ -24,25 +20,13 @@ spec = Gem::Specification.new do |s|
|
|
24
20
|
s.bindir = "bin"
|
25
21
|
end
|
26
22
|
|
27
|
-
|
23
|
+
Gem::PackageTask.new(spec) do |p|
|
28
24
|
p.gem_spec = spec
|
29
25
|
p.need_tar = true
|
30
26
|
p.need_zip = true
|
31
27
|
end
|
32
28
|
|
33
|
-
Rake::RDocTask.new do |rdoc|
|
34
|
-
files =['README', 'LICENSE', 'lib/**/*.rb']
|
35
|
-
rdoc.rdoc_files.add(files)
|
36
|
-
rdoc.main = "README" # page to start on
|
37
|
-
rdoc.title = "BankValUK Docs"
|
38
|
-
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
39
|
-
rdoc.options << '--line-numbers'
|
40
|
-
end
|
41
|
-
|
42
29
|
Rake::TestTask.new do |t|
|
43
30
|
t.test_files = FileList['test/**/*.rb']
|
44
31
|
end
|
45
32
|
|
46
|
-
Spec::Rake::SpecTask.new do |t|
|
47
|
-
t.spec_files = FileList['spec/**/*.rb']
|
48
|
-
end
|
data/lib/BankVal.rb
CHANGED
@@ -5,75 +5,54 @@
|
|
5
5
|
#Module containing classes to handle calls to Unified Sotware's
|
6
6
|
#BankValUK web services
|
7
7
|
#
|
8
|
-
#*[BankVal::UK] Which handles calls to <i>
|
8
|
+
#*[BankVal::UK] Which handles calls to <i>BankValUK</i>
|
9
9
|
#
|
10
10
|
module BankVal
|
11
11
|
|
12
12
|
require 'net/https'
|
13
|
+
require 'json'
|
13
14
|
require 'uri'
|
14
15
|
|
15
16
|
#=BankVal::UK
|
16
17
|
#
|
17
|
-
#Class to control calls to <i>
|
18
|
+
#Class to control calls to <i>BankValUK</i>
|
18
19
|
#
|
19
20
|
#=Synopsis
|
20
21
|
#
|
21
22
|
# requires 'BankVal::UK'
|
22
23
|
#
|
23
24
|
# @obj1 = BankVal::UK.new
|
24
|
-
# @ans = obj1.bank_val_uk('json','A_SORT_CODE','userID','PINNo')
|
25
|
-
#
|
26
|
-
#or..
|
27
|
-
#
|
28
|
-
# @obj1 = BankVal::UK.new
|
29
25
|
# @ans = obj1.bank_val_uk('json','A_SORT_CODE','AN_ACCOUNT_No','userID','PINNo')
|
30
26
|
#
|
31
27
|
class BankVal::UK
|
32
|
-
@userid
|
33
|
-
@pin
|
34
|
-
@account
|
35
|
-
@sortcode
|
36
|
-
@format
|
37
|
-
@service_url
|
38
|
-
@error_string
|
39
28
|
|
40
|
-
#Method to control calls to
|
29
|
+
#Method to control calls to BankValUK sortcode and account number validation
|
41
30
|
#
|
42
31
|
#This method automatically controls calls to Unified software's
|
43
32
|
#BankValUK REST web services
|
44
33
|
#
|
45
34
|
#==Parameters
|
46
|
-
#1.
|
47
|
-
#2.
|
48
|
-
#3.
|
49
|
-
#4.
|
50
|
-
#5.PIN:: can obtained from http://www.unifiedsoftware.co.uk/freetrial/free-trial-home.html
|
35
|
+
#1.SortCode:: The sortcode to be validated
|
36
|
+
#2.Account:: The account number to be validated
|
37
|
+
#3.UserId:: can obtained from https://www.unifiedsoftware.co.uk/request-a-free-trial/
|
38
|
+
#4.PIN:: can obtained from https://www.unifiedsoftware.co.uk/request-a-free-trial/
|
51
39
|
#
|
52
40
|
#The parameters *must* be passed in the order described above,
|
53
|
-
#
|
54
|
-
#details only will result in getBranchDetails being called rather than BankValPlus2.
|
41
|
+
#
|
55
42
|
#
|
56
43
|
#==Returns
|
57
44
|
#
|
58
|
-
#The response from the webservice is returned as a string in
|
59
|
-
#*XML format
|
60
|
-
#*json format
|
61
|
-
#*csv format
|
62
|
-
# depending on the Return Format Parameter passed in
|
45
|
+
#The response from the webservice is returned as a string in json format
|
63
46
|
#
|
64
47
|
def bank_val_uk(*args)
|
65
|
-
@format = args[0].downcase
|
66
|
-
@sortcode = args[1].gsub(/[- .]/, "")
|
67
48
|
case args.size
|
68
|
-
when 5
|
69
|
-
@account = args[2]
|
70
|
-
@userid = args[3]
|
71
|
-
@pin = args[4]
|
72
49
|
when 4
|
50
|
+
@sortcode = args[0].gsub(/[- .]/, "")
|
51
|
+
@account = args[1]
|
73
52
|
@userid = args[2]
|
74
53
|
@pin = args[3]
|
75
54
|
else
|
76
|
-
return "ERROR - not enough parameters supplied"
|
55
|
+
return "{\"result\":\"ERROR - not enough parameters supplied\"}"
|
77
56
|
end
|
78
57
|
format_validation
|
79
58
|
if @error_string != nil
|
@@ -82,27 +61,26 @@ require 'uri'
|
|
82
61
|
return @error_string
|
83
62
|
end
|
84
63
|
build_req_url
|
85
|
-
|
64
|
+
build_post_data
|
65
|
+
return "#{BankVal::GoValidate.new.validate(@service_url, @post_data)}"
|
86
66
|
end
|
87
67
|
|
88
68
|
private
|
89
69
|
|
90
70
|
#method to build the base request url for the REST call
|
91
71
|
def build_req_url()
|
92
|
-
|
93
|
-
|
94
|
-
else
|
95
|
-
@service_url = "bankvaluk/branchdets2/userid/#{@userid}/pin/#{@pin}/sortcode/#{@sortcode}/#{@format}/"
|
96
|
-
end
|
72
|
+
@service_url = "bankvalnew"
|
73
|
+
end
|
97
74
|
|
75
|
+
#method to build post data string
|
76
|
+
def build_post_data()
|
77
|
+
@post_data = {'credentials':{'uname':'#{@userid}','pin':'#{@pin}'},'account':{'sortcode':'#{@sortcode}','account':'#{@account}'}}.to_json
|
98
78
|
end
|
99
79
|
|
100
80
|
#method to validate input and create error messages if they are invalid
|
101
81
|
def format_validation()
|
102
82
|
@error_string = nil
|
103
|
-
if @
|
104
|
-
@error_string = "INVALID - Result Format"
|
105
|
-
elsif @account != nil && @account !~ /^[0-9]{7,10}$/
|
83
|
+
if @account != nil && @account !~ /^[0-9]{7,10}$/
|
106
84
|
@error_string = "INVALID - Account"
|
107
85
|
elsif @sortcode !~ /^[0-9]{6}$/
|
108
86
|
@error_string = "INVALID - Sortcode"
|
@@ -115,134 +93,44 @@ require 'uri'
|
|
115
93
|
|
116
94
|
#method to wrap error string in the correct format, indentation should be left as it is
|
117
95
|
def format_error_string()
|
118
|
-
|
119
|
-
@error_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><branchdets><result>" + @error_string + "</result>
|
120
|
-
<sortcode></sortcode><bicbank></bicbank><bicbranch></bicbranch><subbranchsuffix></subbranchsuffix><bankname></bankname>
|
121
|
-
<owningbank></owningbank><longbank1></longbank1><longbank2></longbank2><ownbc></ownbc><ccode></ccode>
|
122
|
-
<supervisorybody></supervisorybody><deletedate></deletedate><changedate></changedate><printindicator></printindicator>
|
123
|
-
<bacsstatus></bacsstatus><bacschangedate></bacschangedate><bacsclosedate></bacsclosedate><bacsredirectfrom></bacsredirectfrom>
|
124
|
-
<bacsredtoscode></bacsredtoscode><bacssettbank></bacssettbank><bacssettsec></bacssettsec><bacssettsubsec>
|
125
|
-
</bacssettsubsec><bacshandbank></bacshandbank><bacshandst></bacshandst><bacsaccnumflg></bacsaccnumflg>
|
126
|
-
<bacsddiflg></bacsddiflg><bacsdrdisallowed></bacsdrdisallowed><bacscrdisallowed></bacscrdisallowed>
|
127
|
-
<bacscudisallowed></bacscudisallowed><bacsprdisallowed></bacsprdisallowed><bacsbsdisallowed></bacsbsdisallowed>
|
128
|
-
<bacsdvdisallowed></bacsdvdisallowed><bacsaudisallowed></bacsaudisallowed><spare1></spare1><spare2></spare2>
|
129
|
-
<spare3></spare3><spare4></spare4><chapsretind></chapsretind><chapssstatus></chapssstatus><chapsschangedate>
|
130
|
-
</chapsschangedate><chapssclosedate></chapssclosedate><chapsssettmem></chapsssettmem><chapssrbicbank></chapssrbicbank>
|
131
|
-
<chapssrbicbr></chapssrbicbr><chapsestatus></chapsestatus><chapsechangedate></chapsechangedate><chapseclosedate>
|
132
|
-
</chapseclosedate><chapserbicbank></chapserbicbank><chapserbicbr></chapserbicbr><chapsesettmem></chapsesettmem>
|
133
|
-
<chapseretind></chapseretind><chapseswift></chapseswift><spare5></spare5><ccccstatus></ccccstatus><ccccchangedate>
|
134
|
-
</ccccchangedate><ccccclosedate></ccccclosedate><ccccsettbank></ccccsettbank><ccccdasc></ccccdasc><ccccretind></ccccretind>
|
135
|
-
<ccccgbni></ccccgbni><fpsstatus></fpsstatus><fpschangedate></fpschangedate><fpsclosedate></fpsclosedate><fpsredirectfrom>
|
136
|
-
</fpsredirectfrom><fpsredirecttosc></fpsredirecttosc><fpssettbankct></fpssettbankct><fpsspare1></fpsspare1><fpssettbankbc>
|
137
|
-
</fpssettbankbc><fpshandbankct></fpshandbankct><fpsspare2></fpsspare2><fpshandbankbc></fpshandbankbc><fpsaccnumflag>
|
138
|
-
</fpsaccnumflag><fpsagencytype></fpsagencytype><fpsspare3></fpsspare3><printbti></printbti><printmainsc></printmainsc>
|
139
|
-
<printmajlocname></printmajlocname><printminlocname></printminlocname><printbranchname></printbranchname><printsecentryind>
|
140
|
-
</printsecentryind><printsecbrname></printsecbrname><printfbrtit1></printfbrtit1><printfbrtit2></printfbrtit2><printfbrtit3>
|
141
|
-
</printfbrtit3><printaddr1></printaddr1><printaddr2></printaddr2><printaddr3></printaddr3><printaddr4></printaddr4>
|
142
|
-
<printtown></printtown><printcounty></printcounty><printpcode1></printpcode1><printpcode2></printpcode2><printtelarea>
|
143
|
-
</printtelarea><printtelno></printtelno><printtelarea2></printtelarea2><printtelno2></printtelno2></branchdets>"
|
144
|
-
elsif @format == "xml" && @account != nil
|
145
|
-
@error_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><bankvalplus><result>" + @error_string + "</result>
|
146
|
-
<transposedsortcode></transposedsortcode><transposedaccount></transposedaccount><sortcode>
|
147
|
-
</sortcode><bicbank></bicbank><bicbranch></bicbranch><subbranchsuffix></subbranchsuffix>
|
148
|
-
<bankname></bankname><owningbank></owningbank><longbank1></longbank1><longbank2></longbank2>
|
149
|
-
<ownbc></ownbc><ccode></ccode><supervisorybody></supervisorybody><deletedate></deletedate>
|
150
|
-
<changedate></changedate><printindicator></printindicator><bacsstatus></bacsstatus><bacschangedate>
|
151
|
-
</bacschangedate><bacsclosedate></bacsclosedate><bacsredirectfrom></bacsredirectfrom><bacsredtoscode>
|
152
|
-
</bacsredtoscode><bacssettbank></bacssettbank><bacssettsec></bacssettsec><bacssettsubsec></bacssettsubsec>
|
153
|
-
<bacshandbank></bacshandbank><bacshandst></bacshandst><bacsaccnumflg></bacsaccnumflg><bacsddiflg></bacsddiflg>
|
154
|
-
<bacsdrdisallowed></bacsdrdisallowed><bacscrdisallowed></bacscrdisallowed><bacscudisallowed></bacscudisallowed>
|
155
|
-
<bacsprdisallowed></bacsprdisallowed><bacsbsdisallowed></bacsbsdisallowed><bacsdvdisallowed></bacsdvdisallowed>
|
156
|
-
<bacsaudisallowed></bacsaudisallowed><spare1></spare1><spare2></spare2><spare3></spare3><spare4></spare4>
|
157
|
-
<chapsretind></chapsretind><chapssstatus></chapssstatus><chapsschangedate></chapsschangedate><chapssclosedate>
|
158
|
-
</chapssclosedate><chapsssettmem></chapsssettmem><chapssrbicbank></chapssrbicbank><chapssrbicbr></chapssrbicbr>
|
159
|
-
<chapsestatus></chapsestatus><chapsechangedate></chapsechangedate><chapseclosedate></chapseclosedate><chapserbicbank>
|
160
|
-
</chapserbicbank><chapserbicbr></chapserbicbr><chapsesettmem></chapsesettmem><chapseretind></chapseretind><chapseswift>
|
161
|
-
</chapseswift><spare5></spare5><ccccstatus></ccccstatus><ccccchangedate></ccccchangedate><ccccclosedate></ccccclosedate>
|
162
|
-
<ccccsettbank></ccccsettbank><ccccdasc></ccccdasc><ccccretind></ccccretind><ccccgbni></ccccgbni><fpsstatus></fpsstatus>
|
163
|
-
<fpschangedate></fpschangedate><fpsclosedate></fpsclosedate><fpsredirectfrom></fpsredirectfrom><fpsredirecttosc></fpsredirecttosc>
|
164
|
-
<fpssettbankct></fpssettbankct><fpsspare1></fpsspare1><fpssettbankbc></fpssettbankbc><fpshandbankct></fpshandbankct>
|
165
|
-
<fpsspare2></fpsspare2><fpshandbankbc></fpshandbankbc><fpsaccnumflag></fpsaccnumflag><fpsagencytype></fpsagencytype>
|
166
|
-
<fpsspare3></fpsspare3><printbti></printbti><printmainsc></printmainsc><printmajlocname></printmajlocname><printminlocname>
|
167
|
-
</printminlocname><printbranchname></printbranchname><printsecentryind></printsecentryind><printsecbrname>
|
168
|
-
</printsecbrname><printfbrtit1></printfbrtit1><printfbrtit2></printfbrtit2><printfbrtit3></printfbrtit3><printaddr1>
|
169
|
-
</printaddr1><printaddr2></printaddr2><printaddr3></printaddr3><printaddr4></printaddr4><printtown></printtown><printcounty>
|
170
|
-
</printcounty><printpcode1></printpcode1><printpcode2></printpcode2><printtelarea></printtelarea><printtelno></printtelno>
|
171
|
-
<printtelarea2></printtelarea2><printtelno2></printtelno2></bankvalplus>"
|
172
|
-
elsif @format == "json" && @account == nil
|
173
|
-
@error_string = "{\"result\":\"" + @error_string + "\",\"sortcode\":\"\",\"bicbank\":\"\",\"bicbranch\":\"\",
|
174
|
-
\"subbranchsuffix\":\"\",\"bankname\":\"\",\"owningbank\":\"\",\"longbank1\":\"\",\"longbank2\":\"\",\"ownbc\":
|
175
|
-
\"\",\"ccode\":\"\",\"supervisorybody\":\"\",\"deletedate\":\"\",\"changedate\":\"\",\"printindicator\":\"\",\"bacsstatus\":
|
176
|
-
\"\",\"bacschangedate\":\"\",\"bacsclosedate\":\"\",\"bacsredirectfrom\":\"\",\"bacsredtoscode\":\"\",\"bacssettbank\":\"\",\"
|
177
|
-
bacssettsec\":\"\",\"bacssettsubsec\":\"\",\"bacshandbank\":\"\",\"bacshandst\":\"\",\"bacsaccnumflag\":\"\",\"bacsddiflg\":\"\"
|
178
|
-
,\"bacsdrdisallowed\":\"\",\"bacscrdisallowed\":\"\",\"bacscudisallowed\":\"\",\"bacsprdisallowed\"
|
179
|
-
:\"\",\"bacsbsdisallowed\":\"\",\"bacsdvdisallowed\":\"\",\"bacsaudisallowed\":\"\",\"spare1\":\"\",\"spare2\":\"\"
|
180
|
-
,\"spare3\":\"\",\"spare4\":\"\",\"chapsretind\":\"\",\"chapssstatus\":\"\",\"chapsschangedate\":\"\",\"chapssclosedate\"
|
181
|
-
:\"\",\"chapsssettmem\":\"\",\"chapssrbicbank\":\"\",\"chapssrbicbr\":\"\",\"chapsestatus\":\"\",\"chapsechangedate\":\"\"
|
182
|
-
,\"chapseclosedate\":\"\",\"chapserbicbank\":\"\",\"chapserbicbr\":\"\",\"chapsesettmem\":\"\",\"chapseretind\":\"\"
|
183
|
-
,\"chapseswift\":\"\",\"spare5\":\"\",\"ccccstatus\":\"\",\"ccccchangedate\":\"\",\"ccccclosedate\":\"\",\"ccccsettbank\"
|
184
|
-
:\"\",\"ccccdasc\":\"\",\"ccccretind\":\"\",\"ccccgbni\":\"\",\"fpsstatus\":\"\",\"fpschangedate\":\"\",\"fpsclosedate\"
|
185
|
-
:\"\",\"fpsredirectfrom\":\"\",\"fpsredirecttosc\":\"\",\"fpssettbankct\":\"\",\"fpsspare1\":\"\",\"fpssettbankbc\"
|
186
|
-
:\"\",\"fpshandbankct\":\"\",\"fpsspare2\":\"\",\"fpshandbankbc\":\"\",\"fpsaccnumflag\":\"\",\"fpsagencytype\":\"\",\"
|
187
|
-
fpsspare3\":\"\",\"printbti\":\"\",\"printmainsc\":\"\",\"printmajlocname\":\"\",\"printminlocname\":\"\",\"printbranchname\"
|
188
|
-
:\"\",\"printsecentryind\":\"\",\"printsecbrname\":\"\",\"printfbrtit1\":\"\",\"printfbrtit2\":\"\",\"printfbrtit3\":\"\",\"
|
189
|
-
printaddr1\":\"\",\"printaddr2\":\"\",\"printaddr3\":\"\",\"printaddr4\":\"\",\"printtown\":\"\",\"printcounty\"
|
190
|
-
:\"\",\"printpcode1\":\"\",\"printpcode2\":\"\",\"printtelarea\":\"\",\"printtelno\":\"\",\"printtelarea2\":\"\",\"
|
191
|
-
printtelno2\":\"\"}"
|
192
|
-
elsif @format == "json"
|
193
|
-
@error_string = "{\"result\":\"" + @error_string + "\",\"transposedsortcode\":\"\",\"transposedaccount\":\"\",\"sortcode\":\"\",\"bicbank\":\"\",\"bicbranch\":\"\",\"subbranchsuffix\":\"\",\"
|
194
|
-
bankname\":\"\",\"owningbank\":\"\",\"longbank1\":\"\",\"longbank2\":\"\",\"ownbc\":\"\",\"ccode\":\"\",\"supervisorybody\":\"\",\"deletedate\":\"\",\"
|
195
|
-
changedate\":\"\",\"printindicator\":\"\",\"bacsstatus\":\"\",\"bacschangedate\":\"\",\"bacsclosedate\":\"\",\"bacsredirectfrom\":\"\",\"
|
196
|
-
bacsredtoscode\":\"\",\"bacssettbank\":\"\",\"bacssettsec\":\"\",\"bacssettsubsec\":\"\",\"bacshandbank\":\"\",\"bacshandst\":\"\",\"
|
197
|
-
bacsaccnumflag\":\"\",\"bacsddiflg\":\"\",\"bacsdrdisallowed\":\"\",\"bacscrdisallowed\":\"\",\"bacscudisallowed\":\"\",\"
|
198
|
-
bacsprdisallowed\":\"\",\"bacsbsdisallowed\":\"\",\"bacsdvdisallowed\":\"\",\"bacsaudisallowed\":\"\",\"spare1\":\"\",\"spare2\":\"\",\"
|
199
|
-
spare3\":\"\",\"spare4\":\"\",\"chapsretind\":\"\",\"chapssstatus\":\"\",\"chapsschangedate\":\"\",\"chapssclosedate\":\"\",\"
|
200
|
-
chapsssettmem\":\"\",\"chapssrbicbank\":\"\",\"chapssrbicbr\":\"\",\"chapsestatus\":\"\",\"chapsechangedate\":\"\",\"
|
201
|
-
chapseclosedate\":\"\",\"chapserbicbank\":\"\",\"chapserbicbr\":\"\",\"chapsesettmem\":\"\",\"chapseretind\":\"\",\"
|
202
|
-
chapseswift\":\"\",\"spare5\":\"\",\"ccccstatus\":\"\",\"ccccchangedate\":\"\",\"ccccclosedate\":\"\",\"ccccsettbank\":\"\",\"
|
203
|
-
ccccdasc\":\"\",\"ccccretind\":\"\",\"ccccgbni\":\"\",\"fpsstatus\":\"\",\"fpschangedate\":\"\",\"fpsclosedate\":\"\",\"
|
204
|
-
fpsredirectfrom\":\"\",\"fpsredirecttosc\":\"\",\"fpssettbankct\":\"\",\"fpsspare1\":\"\",\"fpssettbankbc\":\"\",\"
|
205
|
-
fpshandbankct\":\"\",\"fpsspare2\":\"\",\"fpshandbankbc\":\"\",\"fpsaccnumflag\":\"\",\"fpsagencytype\":\"\",\"fpsspare3\":\"\",\"
|
206
|
-
printbti\":\"\",\"printmainsc\":\"\",\"printmajlocname\":\"\",\"printminlocname\":\"\",\"printbranchname\":\"\",\"
|
207
|
-
printsecentryind\":\"\",\"printsecbrname\":\"\",\"printfbrtit1\":\"\",\"printfbrtit2\":\"\",\"printfbrtit3\":\"\",\"
|
208
|
-
printaddr1\":\"\",\"printaddr2\":\"\",\"printaddr3\":\"\",\"printaddr4\":\"\",\"printtown\":\"\",\"printcounty\":\"\",\"
|
209
|
-
printpcode1\":\"\",\"printpcode2\":\"\",\"printtelarea\":\"\",\"printtelno\":\"\",\"printtelarea2\":\"\",\"printtelno2\":\"\"}"
|
210
|
-
end
|
96
|
+
@error_string = "{\"result\":\"#{@error_string}\"}"
|
211
97
|
end
|
212
98
|
|
213
99
|
end
|
214
100
|
|
215
101
|
|
216
|
-
#=
|
102
|
+
#=BankValUK::GoValidate
|
217
103
|
#
|
218
104
|
#Class to make calls to Unified Softwares web services
|
219
105
|
#
|
220
106
|
#
|
221
107
|
class BankVal::GoValidate
|
222
|
-
@base_url
|
223
108
|
|
224
109
|
#Method to make REST web service calls and return response
|
225
110
|
#if call to the main data centre fails the back up method is called
|
226
111
|
#to make a call to the back up data centre
|
227
112
|
#
|
228
113
|
#==Parameters
|
229
|
-
#1.
|
114
|
+
#1. ser_url is the services part of the URL for the REST call
|
115
|
+
#2. post_data is the data for the call
|
230
116
|
#
|
231
117
|
#==Returns
|
232
|
-
#The response from the web service in
|
118
|
+
#The response from the web service in JSON format
|
233
119
|
#
|
234
120
|
#
|
235
|
-
def validate(ser_url)
|
236
|
-
@base_url = "https://www.unifiedsoftware.co.uk/services/"
|
121
|
+
def validate(ser_url, post_data)
|
122
|
+
@base_url = "https://www.unifiedsoftware.co.uk/services/enhanced/"
|
237
123
|
uriobj = URI.parse(@base_url)
|
238
124
|
full_path = uriobj.path + ser_url
|
239
125
|
conn = Net::HTTP.new(uriobj.host, uriobj.port)
|
240
126
|
conn.use_ssl = true
|
241
127
|
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
242
128
|
begin
|
243
|
-
|
129
|
+
req = Net::HTTP::Post.new(full_path, 'Content-Type' => 'application/json')
|
130
|
+
req.body = post_data
|
131
|
+
webresponse = conn.request(req)
|
244
132
|
rescue Exception => err
|
245
|
-
|
133
|
+
return self.failover(ser_url, post_data)
|
246
134
|
end
|
247
135
|
if webresponse == nil
|
248
136
|
return "Unknown Error-Check Local Network"
|
@@ -256,25 +144,29 @@ printpcode1\":\"\",\"printpcode2\":\"\",\"printtelarea\":\"\",\"printtelno\":\"\
|
|
256
144
|
#
|
257
145
|
#==Parameters
|
258
146
|
#1. Serv_url is the services part of the URL for the REST call
|
147
|
+
#2. post_data is the data for the call
|
259
148
|
#
|
260
149
|
#==Returns
|
261
|
-
#The response from the web service as a string in
|
150
|
+
#The response from the web service as a string in json format
|
262
151
|
#or..
|
263
152
|
#error message in case of error
|
264
153
|
#
|
265
|
-
def failover(ser_url)
|
266
|
-
@base_url = "https://www.unifiedservices.co.uk/services/"
|
154
|
+
def failover(ser_url, post_data)
|
155
|
+
@base_url = "https://www.unifiedservices.co.uk/services/enhanced/"
|
267
156
|
uriobj = URI.parse(@base_url)
|
268
157
|
full_path = uriobj.path + ser_url
|
269
158
|
conn = Net::HTTP.new(uriobj.host, uriobj.port)
|
270
159
|
conn.use_ssl = true
|
271
160
|
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
272
161
|
begin
|
273
|
-
|
162
|
+
req = Net::HTTP::Post.new(full_path, 'Content-Type' => 'application/json')
|
163
|
+
req.body = post_data
|
164
|
+
webresponse = conn.request(req)
|
274
165
|
rescue Exception => err
|
275
|
-
|
166
|
+
print(err)
|
167
|
+
return "NETWORK ERROR"
|
276
168
|
end
|
277
|
-
return webresponse
|
169
|
+
return webresponse.body
|
278
170
|
end
|
279
171
|
end
|
280
172
|
|
data/test/bv_test.rb
CHANGED
@@ -9,100 +9,62 @@ require 'rexml/document'
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'json'
|
11
11
|
|
12
|
-
|
13
|
-
@obj
|
12
|
+
class BvTest < Test::Unit::TestCase
|
14
13
|
def setup
|
15
14
|
@obj = BankVal::UK.new
|
16
15
|
end
|
17
16
|
|
18
|
-
def test_return_validation_UK
|
19
|
-
#test1_1 'J-Son' is rejected as invalid result format
|
20
|
-
assert_match /INVALID - Result Format/,@obj.bank_val_uk('J-Son','89','abcd123','12345')
|
21
|
-
#tests 1_2 to 1_4 test that 'json','xml','csv' are not rejected as invalis result formats
|
22
|
-
assert_no_match /INVALID - Result Format/,@obj.bank_val_uk('json','89','abcd123','12345')
|
23
|
-
assert_no_match /INVALID - Result Format/,@obj.bank_val_uk('xml','89','abcd123','12345')
|
24
|
-
assert_no_match /INVALID - Result Format/,@obj.bank_val_uk('csv','89','abcd123','12345')
|
25
|
-
#test1_5 tests that csv is returned as the first part of the string will be 'INVALID'
|
26
|
-
assert_match /^INVALID/,@obj.bank_val_uk('csv','89','abcd123','12345')
|
27
|
-
#test1_6 tests 'json' fails the csv test5
|
28
|
-
assert_no_match /^INVALID/,@obj.bank_val_uk('json','89','abcd123','12345')
|
29
|
-
#test1_7 tests xml is returned as no parseError will be raised
|
30
|
-
assert_nothing_raised{
|
31
|
-
REXML::Document.new(@obj.bank_val_uk('xml','89','abcd123','12345')).root.name
|
32
|
-
}
|
33
|
-
#test1_8 tests 'json' fails this xml parse i.e. json doesn't return xml
|
34
|
-
assert_raise (NoMethodError){
|
35
|
-
REXML::Document.new(@obj.bank_val_uk('json','89','abcd123','12345')).root.name
|
36
|
-
}
|
37
|
-
#test1_9 tests 'csv' fails xml parse i.e. csv doesn't return xml
|
38
|
-
assert_raise (NoMethodError){
|
39
|
-
REXML::Document.new(@obj.bank_val_uk('csv','89','abcd123','12345')).root.name
|
40
|
-
}
|
41
|
-
#test1_10 tests 'xml' doesn't return json as parse error is raised
|
42
|
-
assert_raise (JSON::ParserError) {
|
43
|
-
JSON[@obj.bank_val_uk('xml','89','abcd123','12345')]
|
44
|
-
}
|
45
|
-
#test1_11 tests 'csv' doesn't return json
|
46
|
-
assert_raise (JSON::ParserError) {
|
47
|
-
JSON[@obj.bank_val_uk('csv','89','abcd123','12345')]
|
48
|
-
}
|
49
|
-
#test1_12 tests ''json' returns valid (parsable) json
|
50
|
-
assert_nothing_raised{
|
51
|
-
JSON[@obj.bank_val_uk('json','89','abcd123','12345')]
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
17
|
def test_sort_code_number_validation
|
56
18
|
#test2_1 check oversized sc is rejected
|
57
|
-
assert_match
|
19
|
+
assert_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12121212','13245678','abcd123','12345'))
|
58
20
|
#test2_1.5 undersized sc
|
59
|
-
assert_match
|
21
|
+
assert_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12122','13245678','abcd123','12345'))
|
60
22
|
#test2_2 check leading alpha is rejected
|
61
|
-
assert_match
|
23
|
+
assert_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('*12121','13245678','abcd123','12345'))
|
62
24
|
#test2_3 check trailing alpha is rejected
|
63
|
-
assert_match
|
25
|
+
assert_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12123:','13245678','abcd123','12345'))
|
64
26
|
#test2_4 check embedded alpha is rejected
|
65
|
-
assert_match
|
27
|
+
assert_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12g121','13245678','abcd123','12345'))
|
66
28
|
#test2_5 check correct size passes (error will be ID/PIN from server)
|
67
|
-
assert_match
|
29
|
+
assert_match(/^\{"Error":"IP Address is not on Whitelist"/, @obj.bank_val_uk('121212','13245678','abcd123','12345'))
|
68
30
|
#test2_6 check removal of hyphens full stops and spaces
|
69
|
-
assert_no_match
|
31
|
+
assert_no_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12 12 30','13245678','abcd123','12345'))
|
70
32
|
#test2_7 check removal of hyphens full stops and spaces
|
71
|
-
assert_no_match
|
33
|
+
assert_no_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12-12-30','13245678','abcd123','12345'))
|
72
34
|
#test2_8 check removal of hyphens full stops and spaces
|
73
|
-
assert_no_match
|
35
|
+
assert_no_match(/^\{"result":"INVALID - Sortcode"/, @obj.bank_val_uk('12.12.30','13245678','abcd123','12345'))
|
74
36
|
end
|
75
37
|
|
76
38
|
def test_account_validation
|
77
39
|
#test2.5_1 check over
|
78
|
-
assert_match
|
40
|
+
assert_match(/^\{"result":"INVALID - Account"/, @obj.bank_val_uk('121212','12345678901','abcd123','12345'))
|
79
41
|
#test2.5_2 check under
|
80
|
-
assert_match
|
42
|
+
assert_match(/^\{"result":"INVALID - Account"/, @obj.bank_val_uk('121212','123456','abcd123','12345'))
|
81
43
|
#test2.5_3 leading alpha
|
82
|
-
assert_match
|
44
|
+
assert_match(/^\{"result":"INVALID - Account"/, @obj.bank_val_uk('121212','g1234567','abcd123','12345'))
|
83
45
|
#test2.5_4 trailing alpha
|
84
|
-
assert_match
|
46
|
+
assert_match(/^\{"result":"INVALID - Account"/, @obj.bank_val_uk('121212','1234567h','abcd123','12345'))
|
85
47
|
#test2.5_5 embedded alpha
|
86
|
-
assert_match
|
48
|
+
assert_match(/^\{"result":"INVALID - Account"/, @obj.bank_val_uk('121212','1345h678','abcd123','12345'))
|
87
49
|
#test2.5_6 correct size passes
|
88
|
-
assert_match
|
50
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','12345678','abcd12','12345'))
|
89
51
|
end
|
90
52
|
|
91
53
|
def test_userid_validation #test with wireshark as well as returns are identical from server and client validation
|
92
54
|
#test3_1 too short user id 2nd element
|
93
|
-
assert_match
|
55
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','13245678','abcd12','12345'))
|
94
56
|
#test3_2 too long user id 2nd element
|
95
|
-
assert_match
|
57
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','13245678','abcd1234','12345'))
|
96
58
|
#test3_3 too short first element
|
97
|
-
assert_match
|
59
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','13245678','ab123','12345'))
|
98
60
|
end
|
99
61
|
|
100
62
|
def test_pin #test with wireshark as well (look for client hellos these will match each call to either server)
|
101
63
|
#test4_1 too short
|
102
|
-
assert_match
|
64
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','13245678','abcd012','1234'))
|
103
65
|
#test4_2 too long
|
104
|
-
assert_match
|
66
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','13245678','abcd123','123456'))
|
105
67
|
#test4_3 bad chars
|
106
|
-
assert_match
|
68
|
+
assert_match(/^\{"result":"ERROR - Invalid User ID\/PIN"/, @obj.bank_val_uk('121212','13245678','abcd123','12{45'))
|
107
69
|
end
|
108
70
|
end
|
metadata
CHANGED
@@ -1,72 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: BankValUK
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Alec Evans, Unified Software
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2010-09-01 00:00:00 +01:00
|
19
|
-
default_executable:
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
20
12
|
dependencies: []
|
21
|
-
|
22
|
-
|
13
|
+
description: Handles calls to Unified Softwares BankValUK web services including BankValUK
|
14
|
+
which validates UK bank accounts and returns EISCD data
|
23
15
|
email: support@unifiedsoftware.co.uk
|
24
16
|
executables: []
|
25
|
-
|
26
17
|
extensions: []
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
29
19
|
- README
|
30
20
|
- LICENSE
|
31
|
-
files:
|
21
|
+
files:
|
32
22
|
- LICENSE
|
33
23
|
- README
|
34
24
|
- Rakefile
|
35
25
|
- lib/BankVal.rb
|
36
26
|
- test/bv_test.rb
|
37
|
-
has_rdoc: true
|
38
27
|
homepage: http://www.unifiedsoftware.co.uk
|
39
28
|
licenses: []
|
40
|
-
|
29
|
+
metadata: {}
|
41
30
|
post_install_message:
|
42
31
|
rdoc_options: []
|
43
|
-
|
44
|
-
require_paths:
|
32
|
+
require_paths:
|
45
33
|
- lib
|
46
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
-
|
48
|
-
requirements:
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
49
36
|
- - ">="
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
version: "0"
|
55
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
|
-
requirements:
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
58
41
|
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
version: "0"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
64
44
|
requirements: []
|
65
|
-
|
66
45
|
rubyforge_project:
|
67
|
-
rubygems_version:
|
46
|
+
rubygems_version: 2.7.6
|
68
47
|
signing_key:
|
69
|
-
specification_version:
|
48
|
+
specification_version: 4
|
70
49
|
summary: Handles calls to Unified Softwares BankValUK web services
|
71
50
|
test_files: []
|
72
|
-
|