ruby_postcode_anywhere 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby_postcode_anywhere.rb +21 -3
- data/ruby_postcode_anywhere.gemspec +1 -1
- metadata +1 -1
@@ -7,7 +7,11 @@ module PostcodeAnywhere
|
|
7
7
|
attr_accessor :errors, :response
|
8
8
|
|
9
9
|
def success?
|
10
|
-
|
10
|
+
!fail?
|
11
|
+
end
|
12
|
+
|
13
|
+
def fail?
|
14
|
+
response.first["IsCorrect"] == "False" || errors.any?
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
@@ -17,13 +21,27 @@ module PostcodeAnywhere
|
|
17
21
|
|
18
22
|
end
|
19
23
|
|
20
|
-
def self.
|
24
|
+
def self.validate_bank_details(account_number, sortcode)
|
25
|
+
requestUrl = "http://services.postcodeanywhere.co.uk/BankAccountValidation/Interactive/Validate/v2.00/xmle.ws?"
|
26
|
+
requestUrl += "&key=#{key}"
|
27
|
+
requestUrl += "&accountnumber=#{account_number}"
|
28
|
+
requestUrl += "&sortcode=#{sortcode}"
|
21
29
|
|
22
|
-
|
30
|
+
PostcodeAnywhere.query(requestUrl)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.lookup(postcode)
|
23
34
|
requestUrl = "http://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/RetrieveByParts/v1.00/xmle.ws?"
|
24
35
|
requestUrl += "&key=#{PostcodeAnywhere.key}"
|
25
36
|
requestUrl += "&postcode=#{URI.encode_www_form_component(postcode)}"
|
26
37
|
|
38
|
+
PostcodeAnywhere.query(requestUrl)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def self.query(requestUrl)
|
44
|
+
result = Response.new
|
27
45
|
xml_results = Net::HTTP.get_response(URI.parse(requestUrl))
|
28
46
|
|
29
47
|
results = REXML::Document.new(xml_results.body)
|