Module: IbanCalculator

Includes:
ActiveSupport::Configurable
Defined in:
lib/iban_calculator/iban_bic.rb,
lib/iban_calculator.rb,
lib/iban_calculator/bank.rb,
lib/iban_calculator/version.rb,
lib/iban_calculator/invalid_data.rb,
lib/iban_calculator/bic_candidate.rb,
lib/iban_calculator/iban_validator_response.rb

Overview

Return codes and their meaning:

0 = all checks were successful

1 = sub account number has been added automatically 2 = account number did not include a checksum 4 = checksum has not been checked 8 = bank code has not been checked

32 = A sub account number might be required, but could not be determined autoamtically

128 = checksum for account_number is invalid 256 = bank_code could not be found is database 512 = account_number has an invalid length 1024 = bank_code has an invalid length 4096 = data is missing (i.e. country code) 8192= country is not yet supported

Defined Under Namespace

Classes: Bank, BicCandidate, IbanBic, IbanValidatorResponse, InvalidData

Constant Summary collapse

ServiceError =

Errors

Class.new(StandardError)
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.calculate_iban(attributes = {}) ⇒ Object



25
26
27
28
# File 'lib/iban_calculator.rb', line 25

def self.calculate_iban(attributes = {})
  client = IbanBic.new(config.user, config.password, config.url, config.logger)
  client.calculate_iban(attributes)
end

.execute(method, options = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/iban_calculator.rb', line 35

def self.execute(method, options = {})
  client = Savon.client(wsdl: config.url, logger: config.logger)
  client.call(method, message: options).tap do |response|
    status = response.body[:"#{method}_response"][:return][:result]
    fail(ServiceError, status) unless response.body[:"#{method}_response"][:return][:return_code]
  end
end

.validate_iban(iban) ⇒ Object



30
31
32
33
# File 'lib/iban_calculator.rb', line 30

def self.validate_iban(iban)
  response = execute(:validate_iban, iban: iban, user: config.user, password: config.password)
  IbanValidatorResponse.new(response.body[:validate_iban_response][:return])
end