module IbanCalculator
these are methods implemented in active_support 4 which are required to run this gem with active_support 3
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
Constants
- ServiceError
Errors
- VERSION
Public Class Methods
calculate_iban(attributes = {})
click to toggle source
# File lib/iban_calculator.rb, line 29 def self.calculate_iban(attributes = {}) client = IbanBic.new(config) client.calculate_iban(attributes) end
config_accessor(*names) { || ... }
click to toggle source
# File lib/iban_calculator/active_support.rb, line 26 def config_accessor(*names) old_config_accessor(*names) return unless block_given? names.each do |name| send("#{name}=", yield) end end
Also aliased as: old_config_accessor
execute(method, options = {})
click to toggle source
# File lib/iban_calculator.rb, line 39 def self.execute(method, options = {}) client = Savon.client(wsdl: config.url, logger: config.logger, read_timeout: config.read_timeout, open_timeout: config.open_timeout) 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)
click to toggle source
# File lib/iban_calculator.rb, line 34 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
Public Instance Methods
deep_stringify_keys!()
click to toggle source
# File lib/iban_calculator/active_support.rb, line 9 def deep_stringify_keys! deep_transform_keys!{ |key| key.to_s } end
deep_transform_keys!() { |key| ... }
click to toggle source
# File lib/iban_calculator/active_support.rb, line 13 def deep_transform_keys!(&block) keys.each do |key| value = delete(key) self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value end self end