Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
syntaxic simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Stephany committed Sep 28, 2011
1 parent 8dbc155 commit ac69969
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions lib/vies_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
require 'savon'

module VatValidator
class ViesChecker

class << self
def check(country_code, vat_number, vies_host='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')
client = Savon::Client.new(vies_host)
class ViesChecker
def self.check(country_code, vat_number, vies_host='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')
client = Savon::Client.new(vies_host)

begin
response = client.request :check_vat do
soap.body = {
:country_code => country_code,
:vat_number => vat_number
}
end
rescue
raise ViesContactError
begin
response = client.request :check_vat do
soap.body = {
:country_code => country_code,
:vat_number => vat_number
}
end
rescue
raise ViesContactError
end

if response.success?
return response[:check_vat_response][:valid]
else
raise ViesContactError
end
if response.success?
return response[:check_vat_response][:valid]
else
raise ViesContactError
end
end
end
Expand Down

0 comments on commit ac69969

Please sign in to comment.