Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

error handling

  • Loading branch information...
commit 3ed5434199dec1d94b3ca718a6f1da109563a0d4 1 parent 7191bc0
Morgan Christiansson authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/postcode_anywhere/bank_account_validation.rb
View
7 lib/postcode_anywhere/bank_account_validation.rb
@@ -6,12 +6,14 @@ module PostcodeAnywhere
class BankAccountValidation
include HTTParty
base_uri 'https://services.postcodeanywhere.co.uk/BankAccountValidation/Interactive/Validate/v2.00/json3.ws'
+ format :html
def initialize(key)
self.class.default_params :Key => key
end
def validate(sort_code, account_number)
- r = self.class.get('', :query => {:SortCode => sort_code, :AccountNumber => account_number})
- r = JSON.parse(r)
+ http_response = self.class.get('', :query => {:SortCode => sort_code, :AccountNumber => account_number})
+
+ r = JSON.parse(http_response)
raise unless r.length == 1
r = r["Items"]
raise unless r.length == 1
@@ -25,6 +27,7 @@ def validate(sort_code, account_number)
r2
end
end
+
class BankAccountResult
ATTRIBUTES = [:is_correct,
:is_direct_debit_capable,
Please sign in to comment.
Something went wrong with that request. Please try again.