ruby_postcode_anywhere 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,11 @@ module PostcodeAnywhere
7
7
  attr_accessor :errors, :response
8
8
 
9
9
  def success?
10
- errors.empty?
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.lookup(postcode)
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
- result = Response.new
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)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ruby_postcode_anywhere'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = '2012-11-29'
5
5
  s.summary = "PostcodeAnywhere wrapper"
6
6
  s.description = "A simple wrapper for PostcodeAnywhere/Interactive/RetrieveByParts"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_postcode_anywhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: