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/active_support.rb,
lib/iban_calculator/iban_validator_response.rb
Overview
these are methods implemented in active_support 4 which are required to run this gem with active_support 3
Defined Under Namespace
Classes: Bank, BicCandidate, IbanBic, IbanValidatorResponse, InvalidData
Constant Summary
collapse
- ServiceError =
Class.new(StandardError)
- VERSION =
"0.2.1"
Class Method Summary
collapse
Class Method Details
.calculate_iban(attributes = {}) ⇒ Object
29
30
31
32
|
# File 'lib/iban_calculator.rb', line 29
def self.calculate_iban(attributes = {})
client = IbanBic.new(config)
client.calculate_iban(attributes)
end
|
.config_accessor(*names) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# 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
|
.execute(method, options = {}) ⇒ Object
39
40
41
42
43
44
45
|
# 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
|
.old_config_accessor ⇒ Object
24
|
# File 'lib/iban_calculator/active_support.rb', line 24
alias_method :old_config_accessor, :config_accessor
|
.validate_iban(iban) ⇒ Object
34
35
36
37
|
# 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
|